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

/* 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 /*<<< orphan*/,
                            size_t *);
struct sparse_array *sparse_array_init(int, int);
int /*<<< orphan*/ sparse_array_set(struct sparse_array *, int /*<<< orphan*/,
                                    int const *, int);
int test_array_get() {
  struct sparse_array *arr = NULL;
  const int test_num = 666;
  size_t item_size = 0;
  arr = sparse_array_init(sizeof(int), 200);
  if (!(arr)) {
    printf("%i: ", 172);
    return 0;
  };
  if (!(sparse_array_set(arr, 0, &test_num, sizeof(test_num)))) {
    printf("%i: ", 174);
    return 0;
  };
  if (!(*(const int *)sparse_array_get(arr, 0, &item_size) == 666)) {
    printf("%i: ", 175);
    return 0;
  };
  if (!(item_size == sizeof(int))) {
    printf("%i: ", 176);
    return 0;
  };
  if (!(sparse_array_free(arr))) {
    printf("%i: ", 178);
    return 0;
  };
  return 1;
}


x86 assembly (clang, -O0):
<test_array_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x10(%rbp)
movl   $0x29a,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
mov    $0x4,%edi
mov    $0xc8,%esi
call   1070 <sparse_array_init@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11aa <test_array_get+0x5a>
lea    0xe6c(%rip),%rdi
mov    $0xac,%esi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    127a <test_array_get+0x12a>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
lea    -0x14(%rbp),%rdx
mov    $0x4,%ecx
call   1030 <sparse_array_set@plt>
cmp    $0x0,%eax
jne    11e4 <test_array_get+0x94>
lea    0xe32(%rip),%rdi
mov    $0xae,%esi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    127a <test_array_get+0x12a>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
lea    -0x20(%rbp),%rdx
call   1060 <sparse_array_get@plt>
cmpl   $0x29a,(%rax)
je     121c <test_array_get+0xcc>
lea    0xdfa(%rip),%rdi
mov    $0xaf,%esi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    127a <test_array_get+0x12a>
cmpq   $0x4,-0x20(%rbp)
je     1244 <test_array_get+0xf4>
lea    0xdd2(%rip),%rdi
mov    $0xb0,%esi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    127a <test_array_get+0x12a>
mov    -0x10(%rbp),%rdi
call   1050 <sparse_array_free@plt>
cmp    $0x0,%eax
jne    1273 <test_array_get+0x123>
lea    0xda3(%rip),%rdi
mov    $0xb2,%esi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    127a <test_array_get+0x12a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_array_get>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movl   $0x29a,0xc(%rsp)
movq   $0x0,0x10(%rsp)
mov    $0x4,%edi
mov    $0xc8,%esi
call   1070 <sparse_array_init@plt>
test   %rax,%rax
je     11d6 <test_array_get+0x86>
mov    %rax,%rbx
xor    %ebp,%ebp
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x4,%ecx
call   1030 <sparse_array_set@plt>
test   %eax,%eax
je     11e4 <test_array_get+0x94>
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <sparse_array_get@plt>
cmpl   $0x29a,(%rax)
jne    11f7 <test_array_get+0xa7>
cmpq   $0x4,0x10(%rsp)
jne    1205 <test_array_get+0xb5>
mov    %rbx,%rdi
call   1050 <sparse_array_free@plt>
mov    $0x1,%ebp
test   %eax,%eax
jne    1218 <test_array_get+0xc8>
lea    0xe31(%rip),%rdi
mov    $0xb2,%esi
jmp    1211 <test_array_get+0xc1>
lea    0xe23(%rip),%rdi
mov    $0xac,%esi
jmp    1211 <test_array_get+0xc1>
lea    0xe15(%rip),%rdi
mov    $0xae,%esi
call   1040 <printf@plt>
jmp    1218 <test_array_get+0xc8>
lea    0xe02(%rip),%rdi
mov    $0xaf,%esi
jmp    1211 <test_array_get+0xc1>
lea    0xdf4(%rip),%rdi
mov    $0xb0,%esi
call   1040 <printf@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.sparse_array = type { i32 }
@.str = [5 x i8] c"%i: \00"
define i32 @test_array_get() {
%1 = alloca i32
%2 = alloca %struct.sparse_array*
%3 = alloca i32
%4 = alloca i64
store %struct.sparse_array* null, %struct.sparse_array** %2
store i32 666, i32* %3
store i64 0, i64* %4
%5 = call %struct.sparse_array* @sparse_array_init(i32 4, i32 200)
store %struct.sparse_array* %5, %struct.sparse_array** %2
%6 = load %struct.sparse_array*, %struct.sparse_array** %2
%7 = icmp ne %struct.sparse_array* %6, null
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 172)
store i32 0, i32* %1
br label %36
10: ; preds = %0
%11 = load %struct.sparse_array*, %struct.sparse_array** %2
%12 = call i32 @sparse_array_set(%struct.sparse_array* %11, i32 0, i32* %3, i32 4)
%13 = icmp ne i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 174)
store i32 0, i32* %1
br label %36
16: ; preds = %10
%17 = load %struct.sparse_array*, %struct.sparse_array** %2
%18 = call i64 @sparse_array_get(%struct.sparse_array* %17, i32 0, i64* %4)
%19 = inttoptr i64 %18 to i32*
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 666
br i1 %21, label %24, label %22
22: ; preds = %16
%23 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 175)
store i32 0, i32* %1
br label %36
24: ; preds = %16
%25 = load i64, i64* %4
%26 = icmp eq i64 %25, 4
br i1 %26, label %29, label %27
27: ; preds = %24
%28 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 176)
store i32 0, i32* %1
br label %36
29: ; preds = %24
%30 = load %struct.sparse_array*, %struct.sparse_array** %2
%31 = call i32 @sparse_array_free(%struct.sparse_array* %30)
%32 = icmp ne i32 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %29
%34 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 178)
store i32 0, i32* %1
br label %36
35: ; preds = %29
store i32 1, i32* %1
br label %36
36: ; preds = %35, %33, %27, %22, %14, %8
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
%struct.sparse_array = type { i32 }
@.str = [5 x i8] c"%i: \00"
define i32 @test_array_get() {
%1 = alloca i32
%2 = alloca i64
%3 = bitcast i32* %1 to i8*
store i32 666, i32* %1
%4 = bitcast i64* %2 to i8*
store i64 0, i64* %2
%5 = tail call %struct.sparse_array* @sparse_array_init(i32 4, i32 200)
%6 = icmp eq %struct.sparse_array* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 172)
br label %31
9: ; preds = %0
%10 = call i32 @sparse_array_set(%struct.sparse_array* %5, i32 0, i32* %1, i32 4)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 174)
br label %31
14: ; preds = %9
%15 = call i64 @sparse_array_get(%struct.sparse_array* %5, i32 0, i64* %2)
%16 = inttoptr i64 %15 to i32*
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 666
br i1 %18, label %21, label %19
19: ; preds = %14
%20 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 175)
br label %31
21: ; preds = %14
%22 = load i64, i64* %2
%23 = icmp eq i64 %22, 4
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 176)
br label %31
26: ; preds = %21
%27 = call i32 @sparse_array_free(%struct.sparse_array* %5)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 178)
br label %31
31: ; preds = %26, %29, %24, %19, %12, %7
%32 = phi i32 [ 0, %29 ], [ 0, %24 ], [ 0, %19 ], [ 0, %12 ], [ 0, %7 ], [ 1, %26 ]
ret i32 %32
}