#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct json_object {
  int dummy;
};

/* Variables and functions */
struct json_object *json_object_array_get_idx(struct json_object *, int);
int json_object_array_length(struct json_object *);
int /*<<< orphan*/ parse_json_obj(char *, struct json_object *);
int /*<<< orphan*/ sprintf(char *, char *, char *, int);
void parse_value_array(char *key_str, struct json_object *obj_val) {
  struct json_object *ele_obj;
  int array_len = 0;
  int i = 0;
  char tmp_str[256] = {0};
  array_len = json_object_array_length(obj_val);
  for (i = 0; i < array_len; i++) {
    ele_obj = json_object_array_get_idx(obj_val, i);
    sprintf(tmp_str, "%s[%d]", key_str, i);
    parse_json_obj(tmp_str, ele_obj);
  }
}


x86 assembly (clang, -O0):
<parse_value_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
mov    -0x10(%rbp),%rdi
call   1040 <json_object_array_length@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11eb <parse_value_array+0x9b>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1050 <json_object_array_get_idx@plt>
mov    %rax,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x20(%rbp),%ecx
lea    0xe38(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <parse_json_obj@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1197 <parse_value_array+0x47>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_value_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %rsi,%rdi
call   1040 <json_object_array_length@plt>
test   %eax,%eax
jle    1214 <parse_value_array+0xd4>
mov    %eax,%r13d
xor    %ebx,%ebx
mov    %rsp,%rbp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    %ebx,%esi
call   1050 <json_object_array_get_idx@plt>
mov    %rax,%r12
mov    %rbp,%rdi
lea    0xe09(%rip),%rsi
mov    %r14,%rdx
mov    %ebx,%ecx
call   1060 <sprintf@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1030 <parse_json_obj@plt>
add    $0x1,%ebx
cmp    %ebx,%r13d
jne    11e0 <parse_value_array+0xa0>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.json_object = type { i32 }
@.str = [7 x i8] c"%s[%d]\00"
define void @parse_value_array(i8* %0, %struct.json_object* %1) {
%3 = alloca i8*
%4 = alloca %struct.json_object*
%5 = alloca %struct.json_object*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [256 x i8]
store i8* %0, i8** %3
store %struct.json_object* %1, %struct.json_object** %4
store i32 0, i32* %6
store i32 0, i32* %7
%9 = bitcast [256 x i8]* %8 to i8*
%10 = load %struct.json_object*, %struct.json_object** %4
%11 = call i32 @json_object_array_length(%struct.json_object* %10)
store i32 %11, i32* %6
store i32 0, i32* %7
br label %12
12: ; preds = %27, %2
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %30
16: ; preds = %12
%17 = load %struct.json_object*, %struct.json_object** %4
%18 = load i32, i32* %7
%19 = call %struct.json_object* @json_object_array_get_idx(%struct.json_object* %17, i32 %18)
store %struct.json_object* %19, %struct.json_object** %5
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%21 = load i8*, i8** %3
%22 = load i32, i32* %7
%23 = call i32 @sprintf(i8* %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %21, i32 %22)
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%25 = load %struct.json_object*, %struct.json_object** %5
%26 = call i32 @parse_json_obj(i8* %24, %struct.json_object* %25)
br label %27
27: ; preds = %16
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %12
30: ; preds = %12
ret void
}

LLVM IR (-O2):
%struct.json_object = type { i32 }
@.str = [7 x i8] c"%s[%d]\00"
define void @parse_value_array(i8* %0, %struct.json_object* %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @json_object_array_length(%struct.json_object* %1)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %2, %7
%8 = phi i32 [ %12, %7 ], [ 0, %2 ]
%9 = call %struct.json_object* @json_object_array_get_idx(%struct.json_object* %1, i32 %8)
%10 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %8)
%11 = call i32 @parse_json_obj(i8* %4, %struct.json_object* %9)
%12 = add nuw nsw i32 %8, 1
%13 = icmp eq i32 %12, %5
br i1 %13, label %14, label %7
14: ; preds = %7, %2
ret void
}