#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 sparse_array {
  int dummy;
};
typedef int /*<<< orphan*/ i;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sparse_array_free(struct sparse_array *);
scalar_t__ sparse_array_get(struct sparse_array *, int, size_t *);
struct sparse_array *sparse_array_init(int, int const);
int /*<<< orphan*/ sparse_array_set(struct sparse_array *, int, int *, int);
int test_array_set() {
  int i;
  const int array_size = 130;
  struct sparse_array *arr = NULL;
  arr = sparse_array_init(sizeof(int), array_size);
  if (!(arr)) {
    printf("%i: ", 107);
    return 0;
  };
  for (i = 0; i < array_size; i++) {
    int *returned = NULL;
    size_t siz = 0;
    if (!(sparse_array_set(arr, i, &i, sizeof(i)))) {
      printf("%i: ", 112);
      return 0;
    };
    returned = (int *)sparse_array_get(arr, i, &siz);
    if (!(*returned == i)) {
      printf("%i: ", 114);
      return 0;
    };
    if (!(siz == sizeof(int))) {
      printf("%i: ", 115);
      return 0;
    };
  }
  for (i = 0; i < array_size; i++) {
    int *returned = NULL;
    size_t siz = 0;
    returned = (int *)sparse_array_get(arr, i, &siz);
    if (!(*returned == i)) {
      printf("%i: ", 123);
      return 0;
    };
    if (!(siz == sizeof(int))) {
      printf("%i: ", 124);
      return 0;
    };
  }
  if (!(sparse_array_free(arr))) {
    printf("%i: ", 127);
    return 0;
  };
  return 1;
}


x86 assembly (clang, -O0):
<test_array_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x82,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
mov    $0x4,%edi
mov    $0x82,%esi
call   1070 <sparse_array_init@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a2 <test_array_set+0x52>
lea    0xe74(%rip),%rdi
mov    $0x6b,%esi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1351 <test_array_set+0x201>
movl   $0x0,-0x8(%rbp)
cmpl   $0x82,-0x8(%rbp)
jge    127c <test_array_set+0x12c>
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
lea    -0x8(%rbp),%rdx
mov    $0x4,%ecx
call   1030 <sparse_array_set@plt>
cmp    $0x0,%eax
jne    1201 <test_array_set+0xb1>
lea    0xe15(%rip),%rdi
mov    $0x70,%esi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1351 <test_array_set+0x201>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
lea    -0x28(%rbp),%rdx
call   1060 <sparse_array_get@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
je     1241 <test_array_set+0xf1>
lea    0xdd5(%rip),%rdi
mov    $0x72,%esi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1351 <test_array_set+0x201>
cmpq   $0x4,-0x28(%rbp)
je     1269 <test_array_set+0x119>
lea    0xdad(%rip),%rdi
mov    $0x73,%esi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1351 <test_array_set+0x201>
jmp    126e <test_array_set+0x11e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a9 <test_array_set+0x59>
movl   $0x0,-0x8(%rbp)
cmpl   $0x82,-0x8(%rbp)
jge    131b <test_array_set+0x1cb>
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
lea    -0x38(%rbp),%rdx
call   1060 <sparse_array_get@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
je     12e0 <test_array_set+0x190>
lea    0xd36(%rip),%rdi
mov    $0x7b,%esi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1351 <test_array_set+0x201>
cmpq   $0x4,-0x38(%rbp)
je     1308 <test_array_set+0x1b8>
lea    0xd0e(%rip),%rdi
mov    $0x7c,%esi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1351 <test_array_set+0x201>
jmp    130d <test_array_set+0x1bd>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1283 <test_array_set+0x133>
mov    -0x18(%rbp),%rdi
call   1050 <sparse_array_free@plt>
cmp    $0x0,%eax
jne    134a <test_array_set+0x1fa>
lea    0xccc(%rip),%rdi
mov    $0x7f,%esi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1351 <test_array_set+0x201>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_array_set>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0x4,%edi
mov    $0x82,%esi
call   1070 <sparse_array_init@plt>
test   %rax,%rax
je     1253 <test_array_set+0x103>
mov    %rax,%rbx
movl   $0x0,0x4(%rsp)
xor    %esi,%esi
lea    0x4(%rsp),%r14
lea    0x8(%rsp),%r15
nopl   0x0(%rax,%rax,1)
movq   $0x0,0x8(%rsp)
mov    %rbx,%rdi
mov    %r14,%rdx
mov    $0x4,%ecx
call   1030 <sparse_array_set@plt>
test   %eax,%eax
je     1261 <test_array_set+0x111>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
mov    %r15,%rdx
call   1060 <sparse_array_get@plt>
mov    (%rax),%eax
cmp    0x4(%rsp),%eax
jne    126f <test_array_set+0x11f>
cmpq   $0x4,0x8(%rsp)
jne    127d <test_array_set+0x12d>
lea    0x1(%rax),%esi
mov    %esi,0x4(%rsp)
cmp    $0x81,%eax
jl     1190 <test_array_set+0x40>
movl   $0x0,0x4(%rsp)
xor    %esi,%esi
lea    0x8(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nop
movq   $0x0,0x8(%rsp)
mov    %rbx,%rdi
mov    %r14,%rdx
call   1060 <sparse_array_get@plt>
mov    (%rax),%eax
cmp    0x4(%rsp),%eax
jne    128b <test_array_set+0x13b>
cmpq   $0x4,0x8(%rsp)
jne    1299 <test_array_set+0x149>
lea    0x1(%rax),%esi
mov    %esi,0x4(%rsp)
cmp    $0x81,%eax
jl     1200 <test_array_set+0xb0>
mov    %rbx,%rdi
call   1050 <sparse_array_free@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
jne    12ac <test_array_set+0x15c>
lea    0xdb4(%rip),%rdi
mov    $0x7f,%esi
jmp    12a5 <test_array_set+0x155>
lea    0xda6(%rip),%rdi
mov    $0x6b,%esi
jmp    12a5 <test_array_set+0x155>
lea    0xd98(%rip),%rdi
mov    $0x70,%esi
jmp    12a5 <test_array_set+0x155>
lea    0xd8a(%rip),%rdi
mov    $0x72,%esi
jmp    12a5 <test_array_set+0x155>
lea    0xd7c(%rip),%rdi
mov    $0x73,%esi
jmp    12a5 <test_array_set+0x155>
lea    0xd6e(%rip),%rdi
mov    $0x7b,%esi
jmp    12a5 <test_array_set+0x155>
lea    0xd60(%rip),%rdi
mov    $0x7c,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sparse_array = type { i32 }
@.str = [5 x i8] c"%i: \00"
define i32 @test_array_set() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.sparse_array*
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i32*
%8 = alloca i64
store i32 130, i32* %3
store %struct.sparse_array* null, %struct.sparse_array** %4
%9 = call %struct.sparse_array* @sparse_array_init(i32 4, i32 130)
store %struct.sparse_array* %9, %struct.sparse_array** %4
%10 = load %struct.sparse_array*, %struct.sparse_array** %4
%11 = icmp ne %struct.sparse_array* %10, null
br i1 %11, label %14, label %12
12: ; preds = %0
%13 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 107)
store i32 0, i32* %1
br label %76
14: ; preds = %0
store i32 0, i32* %2
br label %15
15: ; preds = %42, %14
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 130
br i1 %17, label %18, label %45
18: ; preds = %15
store i32* null, i32** %5
store i64 0, i64* %6
%19 = load %struct.sparse_array*, %struct.sparse_array** %4
%20 = load i32, i32* %2
%21 = call i32 @sparse_array_set(%struct.sparse_array* %19, i32 %20, i32* %2, i32 4)
%22 = icmp ne i32 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %18
%24 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 112)
store i32 0, i32* %1
br label %76
25: ; preds = %18
%26 = load %struct.sparse_array*, %struct.sparse_array** %4
%27 = load i32, i32* %2
%28 = call i64 @sparse_array_get(%struct.sparse_array* %26, i32 %27, i64* %6)
%29 = inttoptr i64 %28 to i32*
store i32* %29, i32** %5
%30 = load i32*, i32** %5
%31 = load i32, i32* %30
%32 = load i32, i32* %2
%33 = icmp eq i32 %31, %32
br i1 %33, label %36, label %34
34: ; preds = %25
%35 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 114)
store i32 0, i32* %1
br label %76
36: ; preds = %25
%37 = load i64, i64* %6
%38 = icmp eq i64 %37, 4
br i1 %38, label %41, label %39
39: ; preds = %36
%40 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 115)
store i32 0, i32* %1
br label %76
41: ; preds = %36
br label %42
42: ; preds = %41
%43 = load i32, i32* %2
%44 = add nsw i32 %43, 1
store i32 %44, i32* %2
br label %15
45: ; preds = %15
store i32 0, i32* %2
br label %46
46: ; preds = %66, %45
%47 = load i32, i32* %2
%48 = icmp slt i32 %47, 130
br i1 %48, label %49, label %69
49: ; preds = %46
store i32* null, i32** %7
store i64 0, i64* %8
%50 = load %struct.sparse_array*, %struct.sparse_array** %4
%51 = load i32, i32* %2
%52 = call i64 @sparse_array_get(%struct.sparse_array* %50, i32 %51, i64* %8)
%53 = inttoptr i64 %52 to i32*
store i32* %53, i32** %7
%54 = load i32*, i32** %7
%55 = load i32, i32* %54
%56 = load i32, i32* %2
%57 = icmp eq i32 %55, %56
br i1 %57, label %60, label %58
58: ; preds = %49
%59 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 123)
store i32 0, i32* %1
br label %76
60: ; preds = %49
%61 = load i64, i64* %8
%62 = icmp eq i64 %61, 4
br i1 %62, label %65, label %63
63: ; preds = %60
%64 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 124)
store i32 0, i32* %1
br label %76
65: ; preds = %60
br label %66
66: ; preds = %65
%67 = load i32, i32* %2
%68 = add nsw i32 %67, 1
store i32 %68, i32* %2
br label %46
69: ; preds = %46
%70 = load %struct.sparse_array*, %struct.sparse_array** %4
%71 = call i32 @sparse_array_free(%struct.sparse_array* %70)
%72 = icmp ne i32 %71, 0
br i1 %72, label %75, label %73
73: ; preds = %69
%74 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 127)
store i32 0, i32* %1
br label %76
75: ; preds = %69
store i32 1, i32* %1
br label %76
76: ; preds = %75, %73, %63, %58, %39, %34, %23, %12
%77 = load i32, i32* %1
ret i32 %77
}

LLVM IR (-O2):
%struct.sparse_array = type { i32 }
@.str = [5 x i8] c"%i: \00"
define i32 @test_array_set() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = bitcast i32* %1 to i8*
%5 = tail call %struct.sparse_array* @sparse_array_init(i32 4, i32 130)
%6 = icmp eq %struct.sparse_array* %5, null
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = bitcast i64* %2 to i8*
store i32 0, i32* %1
br label %13
9: ; preds = %0
%10 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 107)
br label %58
11: ; preds = %33
%12 = bitcast i64* %3 to i8*
store i32 0, i32* %1
br label %36
13: ; preds = %7, %33
%14 = phi i32 [ 0, %7 ], [ %34, %33 ]
store i64 0, i64* %2
%15 = call i32 @sparse_array_set(%struct.sparse_array* %5, i32 %14, i32* %1, i32 4)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 112)
br label %58
19: ; preds = %13
%20 = load i32, i32* %1
%21 = call i64 @sparse_array_get(%struct.sparse_array* %5, i32 %20, i64* %2)
%22 = inttoptr i64 %21 to i32*
%23 = load i32, i32* %22
%24 = load i32, i32* %1
%25 = icmp eq i32 %23, %24
br i1 %25, label %28, label %26
26: ; preds = %19
%27 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 114)
br label %58
28: ; preds = %19
%29 = load i64, i64* %2
%30 = icmp eq i64 %29, 4
br i1 %30, label %33, label %31
31: ; preds = %28
%32 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 115)
br label %58
33: ; preds = %28
%34 = add nsw i32 %23, 1
store i32 %34, i32* %1
%35 = icmp slt i32 %23, 129
br i1 %35, label %13, label %11
36: ; preds = %11, %50
%37 = phi i32 [ 0, %11 ], [ %51, %50 ]
store i64 0, i64* %3
%38 = call i64 @sparse_array_get(%struct.sparse_array* %5, i32 %37, i64* %3)
%39 = inttoptr i64 %38 to i32*
%40 = load i32, i32* %39
%41 = load i32, i32* %1
%42 = icmp eq i32 %40, %41
br i1 %42, label %45, label %43
43: ; preds = %36
%44 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 123)
br label %58
45: ; preds = %36
%46 = load i64, i64* %3
%47 = icmp eq i64 %46, 4
br i1 %47, label %50, label %48
48: ; preds = %45
%49 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 124)
br label %58
50: ; preds = %45
%51 = add nsw i32 %40, 1
store i32 %51, i32* %1
%52 = icmp slt i32 %40, 129
br i1 %52, label %36, label %53
53: ; preds = %50
%54 = call i32 @sparse_array_free(%struct.sparse_array* %5)
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 127)
br label %58
58: ; preds = %53, %43, %48, %17, %26, %31, %56, %9
%59 = phi i32 [ 0, %56 ], [ 0, %9 ], [ 0, %31 ], [ 0, %26 ], [ 0, %17 ], [ 0, %48 ], [ 0, %43 ], [ 1, %53 ]
ret i32 %59
}