+ /*
+ * Append `original_input_index` to `original_input_indices` if not
+ * there already. We process the `inputs` array in order, so if it is
+ * present, it has to be the last element.
+ */
+ if (bt_value_array_is_empty(res->original_input_indices)) {
+ append_index = true;
+ } else {
+ const bt_value *last_index_value;
+ uint64_t last_index;
+
+ last_index_value =
+ borrow_array_value_last_element_const(res->original_input_indices);
+ last_index = bt_value_integer_unsigned_get(last_index_value);
+
+ BT_ASSERT(last_index <= original_input_index);
+
+ append_index = (last_index != original_input_index);
+ }
+
+ if (append_index) {
+ append_status = bt_value_array_append_unsigned_integer_element(
+ res->original_input_indices, original_input_index);
+
+ if (append_status != BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) {
+ BT_CLI_LOGE_APPEND_CAUSE("Failed to append an unsigned integer value.");
+ goto error;
+ }
+ }