#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ realloc(int *, int);
int /*<<< orphan*/ stderr;
void add_to_int_array(int **array, int num_entries, int val) {
  if (!(num_entries % 10)) {
    *array = (int *)realloc(*array, sizeof(int) * (num_entries + 10));
    if (!(*array)) {
      fprintf(stderr, "[Error] Couldn't allocate memory for syntax checks!\n");
      exit(1);
    }
  }
  (*array)[num_entries] = val;
}


x86 assembly (clang, -O0):
<add_to_int_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11ac <add_to_int_array+0x7c>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0xc(%rbp),%eax
add    $0xa,%eax
cltq
shl    $0x2,%rax
mov    %eax,%esi
call   1040 <realloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11a7 <add_to_int_array+0x77>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    11ac <add_to_int_array+0x7c>
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_to_int_array>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebx
imul   $0xcccccccd,%esi,%ecx
add    $0x19999998,%ecx
ror    %ecx
mov    (%rdi),%rax
cmp    $0x19999998,%ecx
ja     116d <add_to_int_array+0x3d>
mov    %rdi,%rbp
lea    0x28(,%rbx,4),%esi
mov    %rax,%rdi
call   1040 <realloc@plt>
mov    %rax,0x0(%rbp)
test   %rax,%rax
je     1179 <add_to_int_array+0x49>
movslq %ebx,%rcx
mov    %r14d,(%rax,%rcx,4)
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    0xe77(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [53 x i8] c"[Error] Couldn't allocate memory for syntax checks!\0A\00"
define void @add_to_int_array(i32** %0, i32 %1, i32 %2) {
%4 = alloca i32**
%5 = alloca i32
%6 = alloca i32
store i32** %0, i32*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %5
%8 = srem i32 %7, 10
%9 = icmp ne i32 %8, 0
br i1 %9, label %29, label %10
10: ; preds = %3
%11 = load i32**, i32*** %4
%12 = load i32*, i32** %11
%13 = load i32, i32* %5
%14 = add nsw i32 %13, 10
%15 = sext i32 %14 to i64
%16 = mul i64 4, %15
%17 = trunc i64 %16 to i32
%18 = call i64 @realloc(i32* %12, i32 %17)
%19 = inttoptr i64 %18 to i32*
%20 = load i32**, i32*** %4
store i32* %19, i32** %20
%21 = load i32**, i32*** %4
%22 = load i32*, i32** %21
%23 = icmp ne i32* %22, null
br i1 %23, label %28, label %24
24: ; preds = %10
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %10
br label %29
29: ; preds = %28, %3
%30 = load i32, i32* %6
%31 = load i32**, i32*** %4
%32 = load i32*, i32** %31
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
store i32 %30, i32* %35
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [53 x i8] c"[Error] Couldn't allocate memory for syntax checks!\0A\00"
define void @add_to_int_array(i32** nocapture %0, i32 %1, i32 %2) {
%4 = srem i32 %1, 10
%5 = icmp eq i32 %4, 0
%6 = load i32*, i32** %0
br i1 %5, label %7, label %17
7: ; preds = %3
%8 = shl i32 %1, 2
%9 = add i32 %8, 40
%10 = tail call i64 @realloc(i32* %6, i32 %9)
%11 = inttoptr i64 %10 to i32*
store i32* %11, i32** %0
%12 = icmp eq i64 %10, 0
br i1 %12, label %13, label %17
13: ; preds = %7
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %3, %7
%18 = phi i32* [ %11, %7 ], [ %6, %3 ]
%19 = sext i32 %1 to i64
%20 = getelementptr inbounds i32, i32* %18, i64 %19
store i32 %2, i32* %20
ret void
}