#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 /*<<< orphan*/ raise_error(int /*<<< orphan*/);
long long *realloc(long long *, long long);
void add_to_int_array(long long int **array, long long int sizeof_array,
                      long long int value, bool add_memory) {
  long long int *tmp;
  if (add_memory) {
    tmp = realloc(*array, (sizeof_array + 1) * sizeof(long long int));
    if (tmp == NULL) {
      raise_error(0);
    } else {
      *array = tmp;
    }
  }
  (*array)[sizeof_array] = value;
}


x86 assembly (clang, -O0):
<add_to_int_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1184 <add_to_int_array+0x64>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
shl    $0x3,%rsi
call   1030 <realloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1174 <add_to_int_array+0x54>
xor    %edi,%edi
call   1040 <raise_error@plt>
jmp    117f <add_to_int_array+0x5f>
mov    -0x28(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
jmp    1184 <add_to_int_array+0x64>
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_to_int_array>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
test   %ecx,%ecx
je     1153 <add_to_int_array+0x33>
mov    (%rbx),%rdi
lea    0x8(,%r15,8),%rsi
call   1030 <realloc@plt>
test   %rax,%rax
je     114c <add_to_int_array+0x2c>
mov    %rax,(%rbx)
jmp    1153 <add_to_int_array+0x33>
xor    %edi,%edi
call   1040 <raise_error@plt>
mov    (%rbx),%rax
mov    %r14,(%rax,%r15,8)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @add_to_int_array(i64** %0, i64 %1, i64 %2, i32 %3) {
%5 = alloca i64**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i64*
store i64** %0, i64*** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i32 %3, i32* %8
%10 = load i32, i32* %8
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %27
12: ; preds = %4
%13 = load i64**, i64*** %5
%14 = load i64*, i64** %13
%15 = load i64, i64* %6
%16 = add nsw i64 %15, 1
%17 = mul i64 %16, 8
%18 = call i64* @realloc(i64* %14, i64 %17)
store i64* %18, i64** %9
%19 = load i64*, i64** %9
%20 = icmp eq i64* %19, null
br i1 %20, label %21, label %23
21: ; preds = %12
%22 = call i32 @raise_error(i32 0)
br label %26
23: ; preds = %12
%24 = load i64*, i64** %9
%25 = load i64**, i64*** %5
store i64* %24, i64** %25
br label %26
26: ; preds = %23, %21
br label %27
27: ; preds = %26, %4
%28 = load i64, i64* %7
%29 = load i64**, i64*** %5
%30 = load i64*, i64** %29
%31 = load i64, i64* %6
%32 = getelementptr inbounds i64, i64* %30, i64 %31
store i64 %28, i64* %32
ret void
}

LLVM IR (-O2):
define void @add_to_int_array(i64** nocapture %0, i64 %1, i64 %2, i32 %3) {
%5 = icmp eq i32 %3, 0
br i1 %5, label %15, label %6
6: ; preds = %4
%7 = load i64*, i64** %0
%8 = shl i64 %1, 3
%9 = add i64 %8, 8
%10 = tail call i64* @realloc(i64* %7, i64 %9)
%11 = icmp eq i64* %10, null
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = tail call i32 @raise_error(i32 0)
br label %15
14: ; preds = %6
store i64* %10, i64** %0
br label %15
15: ; preds = %12, %14, %4
%16 = load i64*, i64** %0
%17 = getelementptr inbounds i64, i64* %16, i64 %1
store i64 %2, i64* %17
ret void
}