#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 */

/* Variables and functions */
int clxns_count(void *);
int /*<<< orphan*/ clxns_free(void *, int /*<<< orphan*/);
int /*<<< orphan*/ clxns_iter_free(void *);
char *clxns_iter_get_next(void *);
scalar_t__ clxns_iter_move_next(void *);
void *clxns_iter_new(void *);
void *resize_array(int /*<<< orphan*/);
int /*<<< orphan*/ resize_array_add(void *, char *);
int /*<<< orphan*/ resize_array_insert(void *, int, char *);
int /*<<< orphan*/ sprintf(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strcmp(char *, char *);
char *ra_insert() {
  void *array = resize_array(0);
  resize_array_add(array, "string1");
  resize_array_add(array, "string2");
  resize_array_add(array, "string3");
  resize_array_add(array, "string5");
  resize_array_add(array, "string6");
  resize_array_add(array, "string7");
  resize_array_add(array, "string8");
  resize_array_insert(array, 0, "string0");
  resize_array_insert(array, 4, "string4");
  resize_array_insert(array, 9, "string9");
  int s = clxns_count(array);
  do {
    if (!(s == 10))
      return "Wrong number of items in array after insert";
  } while (0);
  char buf[16];
  int i = 0;
  void *iter = clxns_iter_new(array);
  while (clxns_iter_move_next(iter)) {
    char *res = clxns_iter_get_next(iter);
    sprintf(buf, "string%d", i++);
    do {
      if (!(!strcmp(res, buf)))
        return "Incorrect data in iter after insert";
    } while (0);
  }
  do {
    if (!(i == 10))
      return "Incorrect iter count after insert";
  } while (0);
  clxns_iter_free(iter);
  clxns_free(array, 0);
  return 0;
}


x86 assembly (clang, -O0):
<ra_insert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
xor    %edi,%edi
call   1060 <resize_array@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe32(%rip),%rsi
call   10d0 <resize_array_add@plt>
mov    -0x10(%rbp),%rdi
lea    0xe2a(%rip),%rsi
call   10d0 <resize_array_add@plt>
mov    -0x10(%rbp),%rdi
lea    0xe22(%rip),%rsi
call   10d0 <resize_array_add@plt>
mov    -0x10(%rbp),%rdi
lea    0xe1a(%rip),%rsi
call   10d0 <resize_array_add@plt>
mov    -0x10(%rbp),%rdi
lea    0xe12(%rip),%rsi
call   10d0 <resize_array_add@plt>
mov    -0x10(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   10d0 <resize_array_add@plt>
mov    -0x10(%rbp),%rdi
lea    0xe02(%rip),%rsi
call   10d0 <resize_array_add@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
lea    0xdf8(%rip),%rdx
call   1070 <resize_array_insert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
lea    0xdeb(%rip),%rdx
call   1070 <resize_array_insert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x9,%esi
lea    0xdde(%rip),%rdx
call   1070 <resize_array_insert@plt>
mov    -0x10(%rbp),%rdi
call   1090 <clxns_count@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
je     1295 <ra_insert+0xe5>
lea    0xdc4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1359 <ra_insert+0x1a9>
jmp    129a <ra_insert+0xea>
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <clxns_iter_new@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
call   1050 <clxns_iter_move_next@plt>
cmp    $0x0,%rax
je     1319 <ra_insert+0x169>
mov    -0x40(%rbp),%rdi
call   10b0 <clxns_iter_get_next@plt>
mov    %rax,-0x48(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
lea    0xd98(%rip),%rsi
call   10c0 <sprintf@plt>
mov    -0x48(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
je     130f <ra_insert+0x15f>
lea    0xd7f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1359 <ra_insert+0x1a9>
jmp    1314 <ra_insert+0x164>
jmp    12ae <ra_insert+0xfe>
jmp    131e <ra_insert+0x16e>
cmpl   $0xa,-0x34(%rbp)
je     1338 <ra_insert+0x188>
lea    0xd7a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1359 <ra_insert+0x1a9>
jmp    133d <ra_insert+0x18d>
mov    -0x40(%rbp),%rdi
call   1040 <clxns_iter_free@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   10a0 <clxns_free@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ra_insert>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %ebx,%ebx
xor    %edi,%edi
call   1060 <resize_array@plt>
mov    %rax,%r14
lea    0xe2f(%rip),%rsi
mov    %rax,%rdi
call   10d0 <resize_array_add@plt>
lea    0xe28(%rip),%rsi
mov    %r14,%rdi
call   10d0 <resize_array_add@plt>
lea    0xe21(%rip),%rsi
mov    %r14,%rdi
call   10d0 <resize_array_add@plt>
lea    0xe1a(%rip),%rsi
mov    %r14,%rdi
call   10d0 <resize_array_add@plt>
lea    0xe13(%rip),%rsi
mov    %r14,%rdi
call   10d0 <resize_array_add@plt>
lea    0xe0c(%rip),%rsi
mov    %r14,%rdi
call   10d0 <resize_array_add@plt>
lea    0xe05(%rip),%rsi
mov    %r14,%rdi
call   10d0 <resize_array_add@plt>
lea    0xdfe(%rip),%rdx
mov    %r14,%rdi
xor    %esi,%esi
call   1070 <resize_array_insert@plt>
lea    0xdf5(%rip),%rdx
mov    %r14,%rdi
mov    $0x4,%esi
call   1070 <resize_array_insert@plt>
lea    0xde9(%rip),%rdx
mov    %r14,%rdi
mov    $0x9,%esi
call   1070 <resize_array_insert@plt>
mov    %r14,%rdi
call   1090 <clxns_count@plt>
cmp    $0xa,%eax
jne    12d8 <ra_insert+0x128>
mov    %r14,%rdi
call   1030 <clxns_iter_new@plt>
mov    %rax,%r12
mov    %rsp,%rbp
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1050 <clxns_iter_move_next@plt>
test   %rax,%rax
je     12e1 <ra_insert+0x131>
mov    %r12,%rdi
call   10b0 <clxns_iter_get_next@plt>
mov    %rax,%r15
lea    0x1(%rbx),%r13d
mov    %rbp,%rdi
lea    0xdc6(%rip),%rsi
mov    %ebx,%edx
call   10c0 <sprintf@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1080 <strcmp@plt>
mov    %r13d,%ebx
test   %eax,%eax
je     1290 <ra_insert+0xe0>
lea    0xdaf(%rip),%rbx
jmp    1303 <ra_insert+0x153>
lea    0xd71(%rip),%rbx
jmp    1303 <ra_insert+0x153>
cmp    $0xa,%ebx
jne    12fc <ra_insert+0x14c>
mov    %r12,%rdi
call   1040 <clxns_iter_free@plt>
xor    %ebx,%ebx
mov    %r14,%rdi
xor    %esi,%esi
call   10a0 <clxns_free@plt>
jmp    1303 <ra_insert+0x153>
lea    0xda6(%rip),%rbx
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"string1\00"
@.str.1 = [8 x i8] c"string2\00"
@.str.2 = [8 x i8] c"string3\00"
@.str.3 = [8 x i8] c"string5\00"
@.str.4 = [8 x i8] c"string6\00"
@.str.5 = [8 x i8] c"string7\00"
@.str.6 = [8 x i8] c"string8\00"
@.str.7 = [8 x i8] c"string0\00"
@.str.8 = [8 x i8] c"string4\00"
@.str.9 = [8 x i8] c"string9\00"
@.str.10 = [44 x i8] c"Wrong number of items in array after insert\00"
@.str.11 = [9 x i8] c"string%d\00"
@.str.12 = [36 x i8] c"Incorrect data in iter after insert\00"
@.str.13 = [34 x i8] c"Incorrect iter count after insert\00"
define i8* @ra_insert() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [16 x i8]
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = call i8* @resize_array(i32 0)
store i8* %8, i8** %2
%9 = load i8*, i8** %2
%10 = call i32 @resize_array_add(i8* %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%11 = load i8*, i8** %2
%12 = call i32 @resize_array_add(i8* %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%13 = load i8*, i8** %2
%14 = call i32 @resize_array_add(i8* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%15 = load i8*, i8** %2
%16 = call i32 @resize_array_add(i8* %15, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%17 = load i8*, i8** %2
%18 = call i32 @resize_array_add(i8* %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%19 = load i8*, i8** %2
%20 = call i32 @resize_array_add(i8* %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%21 = load i8*, i8** %2
%22 = call i32 @resize_array_add(i8* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%23 = load i8*, i8** %2
%24 = call i32 @resize_array_insert(i8* %23, i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%25 = load i8*, i8** %2
%26 = call i32 @resize_array_insert(i8* %25, i32 4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%27 = load i8*, i8** %2
%28 = call i32 @resize_array_insert(i8* %27, i32 9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%29 = load i8*, i8** %2
%30 = call i32 @clxns_count(i8* %29)
store i32 %30, i32* %3
br label %31
31: ; preds = %0
%32 = load i32, i32* %3
%33 = icmp eq i32 %32, 10
br i1 %33, label %35, label %34
34: ; preds = %31
store i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.10, i64 0, i64 0), i8** %1
br label %69
35: ; preds = %31
br label %36
36: ; preds = %35
store i32 0, i32* %5
%37 = load i8*, i8** %2
%38 = call i8* @clxns_iter_new(i8* %37)
store i8* %38, i8** %6
br label %39
39: ; preds = %57, %36
%40 = load i8*, i8** %6
%41 = call i64 @clxns_iter_move_next(i8* %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %58
43: ; preds = %39
%44 = load i8*, i8** %6
%45 = call i8* @clxns_iter_get_next(i8* %44)
store i8* %45, i8** %7
%46 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%47 = load i32, i32* %5
%48 = add nsw i32 %47, 1
store i32 %48, i32* %5
%49 = call i32 @sprintf(i8* %46, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i32 %47)
br label %50
50: ; preds = %43
%51 = load i8*, i8** %7
%52 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%53 = call i32 @strcmp(i8* %51, i8* %52)
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %56
55: ; preds = %50
store i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0), i8** %1
br label %69
56: ; preds = %50
br label %57
57: ; preds = %56
br label %39
58: ; preds = %39
br label %59
59: ; preds = %58
%60 = load i32, i32* %5
%61 = icmp eq i32 %60, 10
br i1 %61, label %63, label %62
62: ; preds = %59
store i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.13, i64 0, i64 0), i8** %1
br label %69
63: ; preds = %59
br label %64
64: ; preds = %63
%65 = load i8*, i8** %6
%66 = call i32 @clxns_iter_free(i8* %65)
%67 = load i8*, i8** %2
%68 = call i32 @clxns_free(i8* %67, i32 0)
store i8* null, i8** %1
br label %69
69: ; preds = %64, %62, %55, %34
%70 = load i8*, i8** %1
ret i8* %70
}

LLVM IR (-O2):
@.str = [8 x i8] c"string1\00"
@.str.1 = [8 x i8] c"string2\00"
@.str.2 = [8 x i8] c"string3\00"
@.str.3 = [8 x i8] c"string5\00"
@.str.4 = [8 x i8] c"string6\00"
@.str.5 = [8 x i8] c"string7\00"
@.str.6 = [8 x i8] c"string8\00"
@.str.7 = [8 x i8] c"string0\00"
@.str.8 = [8 x i8] c"string4\00"
@.str.9 = [8 x i8] c"string9\00"
@.str.10 = [44 x i8] c"Wrong number of items in array after insert\00"
@.str.11 = [9 x i8] c"string%d\00"
@.str.12 = [36 x i8] c"Incorrect data in iter after insert\00"
@.str.13 = [34 x i8] c"Incorrect iter count after insert\00"
define i8* @ra_insert() {
%1 = alloca [16 x i8]
%2 = tail call i8* @resize_array(i32 0)
%3 = tail call i32 @resize_array_add(i8* %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @resize_array_add(i8* %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @resize_array_add(i8* %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @resize_array_add(i8* %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%7 = tail call i32 @resize_array_add(i8* %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%8 = tail call i32 @resize_array_add(i8* %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%9 = tail call i32 @resize_array_add(i8* %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%10 = tail call i32 @resize_array_insert(i8* %2, i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%11 = tail call i32 @resize_array_insert(i8* %2, i32 4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%12 = tail call i32 @resize_array_insert(i8* %2, i32 9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%13 = tail call i32 @clxns_count(i8* %2)
%14 = icmp eq i32 %13, 10
br i1 %14, label %15, label %35
15: ; preds = %0
%16 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%17 = tail call i8* @clxns_iter_new(i8* %2)
br label %18
18: ; preds = %22, %15
%19 = phi i32 [ 0, %15 ], [ %24, %22 ]
%20 = tail call i64 @clxns_iter_move_next(i8* %17)
%21 = icmp eq i64 %20, 0
br i1 %21, label %28, label %22
22: ; preds = %18
%23 = tail call i8* @clxns_iter_get_next(i8* %17)
%24 = add nuw nsw i32 %19, 1
%25 = call i32 @sprintf(i8* %16, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i32 %19)
%26 = call i32 @strcmp(i8* dereferenceable(1) %23, i8* %16)
%27 = icmp eq i32 %26, 0
br i1 %27, label %18, label %33
28: ; preds = %18
%29 = icmp eq i32 %19, 10
br i1 %29, label %30, label %33
30: ; preds = %28
%31 = tail call i32 @clxns_iter_free(i8* %17)
%32 = tail call i32 @clxns_free(i8* %2, i32 0)
br label %33
33: ; preds = %22, %28, %30
%34 = phi i8* [ null, %30 ], [ getelementptr inbounds ([34 x i8], [34 x i8]* @.str.13, i64 0, i64 0), %28 ], [ getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0), %22 ]
br label %35
35: ; preds = %0, %33
%36 = phi i8* [ %34, %33 ], [ getelementptr inbounds ([44 x i8], [44 x i8]* @.str.10, i64 0, i64 0), %0 ]
ret i8* %36
}