#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 *realloc(int *, int);
void push_on_pile(int **pile, int value) {
  *pile = realloc(*pile, sizeof(**pile) * (pile[0][0] + 1));
  pile[0][pile[0][0]] = value;
  pile[0][0] += 1;
}


x86 assembly (clang, -O0):
<push_on_pile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%eax
add    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%esi
call   1030 <realloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rcx
movslq (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<push_on_pile>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    (%rdi),%rdi
mov    (%rdi),%eax
lea    0x4(,%rax,4),%esi
call   1030 <realloc@plt>
mov    %rax,(%rbx)
movslq (%rax),%rcx
mov    %ebp,(%rax,%rcx,4)
addl   $0x1,(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @push_on_pile(i32** %0, i32 %1) {
%3 = alloca i32**
%4 = alloca i32
store i32** %0, i32*** %3
store i32 %1, i32* %4
%5 = load i32**, i32*** %3
%6 = load i32*, i32** %5
%7 = load i32**, i32*** %3
%8 = getelementptr inbounds i32*, i32** %7, i64 0
%9 = load i32*, i32** %8
%10 = getelementptr inbounds i32, i32* %9, i64 0
%11 = load i32, i32* %10
%12 = add nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = mul i64 4, %13
%15 = trunc i64 %14 to i32
%16 = call i32* @realloc(i32* %6, i32 %15)
%17 = load i32**, i32*** %3
store i32* %16, i32** %17
%18 = load i32, i32* %4
%19 = load i32**, i32*** %3
%20 = getelementptr inbounds i32*, i32** %19, i64 0
%21 = load i32*, i32** %20
%22 = load i32**, i32*** %3
%23 = getelementptr inbounds i32*, i32** %22, i64 0
%24 = load i32*, i32** %23
%25 = getelementptr inbounds i32, i32* %24, i64 0
%26 = load i32, i32* %25
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %21, i64 %27
store i32 %18, i32* %28
%29 = load i32**, i32*** %3
%30 = getelementptr inbounds i32*, i32** %29, i64 0
%31 = load i32*, i32** %30
%32 = getelementptr inbounds i32, i32* %31, i64 0
%33 = load i32, i32* %32
%34 = add nsw i32 %33, 1
store i32 %34, i32* %32
ret void
}

LLVM IR (-O2):
define void @push_on_pile(i32** nocapture %0, i32 %1) {
%3 = load i32*, i32** %0
%4 = load i32, i32* %3
%5 = shl i32 %4, 2
%6 = add i32 %5, 4
%7 = tail call i32* @realloc(i32* %3, i32 %6)
store i32* %7, i32** %0
%8 = load i32, i32* %7
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i32, i32* %7, i64 %9
store i32 %1, i32* %10
%11 = load i32, i32* %7
%12 = add nsw i32 %11, 1
store i32 %12, i32* %7
ret void
}