#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 expression {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ oom();
struct expression *parse_expression(int /*<<< orphan*/);
struct expression **realloc(struct expression **, size_t);
struct expression **parse_program(void) {
  size_t alloc = 0;
  size_t n = 0;
  struct expression **program = NULL;
  do {
    if (n == alloc) {
      alloc = alloc ? alloc * 2 : 1;
      program = realloc(program, alloc * sizeof *program);
      if (!program)
        oom();
    }
    program[n] = parse_expression(0);
  } while (program[n++]);
  return program;
}


x86 assembly (clang, -O0):
<parse_program>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jne    11bc <parse_program+0x8c>
cmpq   $0x0,-0x8(%rbp)
je     117a <parse_program+0x4a>
mov    -0x8(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1188 <parse_program+0x58>
mov    $0x1,%eax
mov    %rax,-0x20(%rbp)
jmp    1188 <parse_program+0x58>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
shl    $0x3,%rsi
call   1050 <realloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b7 <parse_program+0x87>
mov    $0x0,%al
call   1030 <oom@plt>
jmp    11bc <parse_program+0x8c>
xor    %edi,%edi
call   1040 <parse_expression@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
cmpq   $0x0,(%rax,%rcx,8)
jne    1150 <parse_program+0x20>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_program>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x1,%r14d
xor    %r12d,%r12d
xor    %ebx,%ebx
xor    %r15d,%r15d
jmp    1174 <parse_program+0x44>
xor    %eax,%eax
call   1030 <oom@plt>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %edi,%edi
call   1040 <parse_expression@plt>
mov    %rax,(%r15,%rbx,8)
add    $0x1,%rbx
test   %rax,%rax
je     119e <parse_program+0x6e>
cmp    %r12,%rbx
jne    1160 <parse_program+0x30>
test   %r12,%r12
lea    (%r12,%r12,1),%r12
cmove  %r14,%r12
lea    0x0(,%r12,8),%rsi
mov    %r15,%rdi
call   1050 <realloc@plt>
test   %rax,%rax
je     1148 <parse_program+0x18>
mov    %rax,%r15
jmp    1160 <parse_program+0x30>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.expression = type { i32 }
define %struct.expression** @parse_program() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca %struct.expression**
store i64 0, i64* %1
store i64 0, i64* %2
store %struct.expression** null, %struct.expression*** %3
br label %4
4: ; preds = %31, %0
%5 = load i64, i64* %2
%6 = load i64, i64* %1
%7 = icmp eq i64 %5, %6
br i1 %7, label %8, label %26
8: ; preds = %4
%9 = load i64, i64* %1
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i64, i64* %1
%13 = mul i64 %12, 2
br label %15
14: ; preds = %8
br label %15
15: ; preds = %14, %11
%16 = phi i64 [ %13, %11 ], [ 1, %14 ]
store i64 %16, i64* %1
%17 = load %struct.expression**, %struct.expression*** %3
%18 = load i64, i64* %1
%19 = mul i64 %18, 8
%20 = call %struct.expression** @realloc(%struct.expression** %17, i64 %19)
store %struct.expression** %20, %struct.expression*** %3
%21 = load %struct.expression**, %struct.expression*** %3
%22 = icmp ne %struct.expression** %21, null
br i1 %22, label %25, label %23
23: ; preds = %15
%24 = call i32 (...) @oom()
br label %25
25: ; preds = %23, %15
br label %26
26: ; preds = %25, %4
%27 = call %struct.expression* @parse_expression(i32 0)
%28 = load %struct.expression**, %struct.expression*** %3
%29 = load i64, i64* %2
%30 = getelementptr inbounds %struct.expression*, %struct.expression** %28, i64 %29
store %struct.expression* %27, %struct.expression** %30
br label %31
31: ; preds = %26
%32 = load %struct.expression**, %struct.expression*** %3
%33 = load i64, i64* %2
%34 = add i64 %33, 1
store i64 %34, i64* %2
%35 = getelementptr inbounds %struct.expression*, %struct.expression** %32, i64 %33
%36 = load %struct.expression*, %struct.expression** %35
%37 = icmp ne %struct.expression* %36, null
br i1 %37, label %4, label %38
38: ; preds = %31
%39 = load %struct.expression**, %struct.expression*** %3
ret %struct.expression** %39
}

LLVM IR (-O2):
%struct.expression = type { i32 }
define noalias %struct.expression** @parse_program() {
br label %1
1: ; preds = %15, %0
%2 = phi i64 [ 0, %0 ], [ %16, %15 ]
%3 = phi i64 [ 0, %0 ], [ %20, %15 ]
%4 = phi %struct.expression** [ null, %0 ], [ %17, %15 ]
%5 = icmp eq i64 %3, %2
br i1 %5, label %6, label %15
6: ; preds = %1
%7 = icmp eq i64 %2, 0
%8 = shl i64 %2, 1
%9 = select i1 %7, i64 1, i64 %8
%10 = shl i64 %9, 3
%11 = tail call %struct.expression** @realloc(%struct.expression** %4, i64 %10)
%12 = icmp eq %struct.expression** %11, null
br i1 %12, label %13, label %15
13: ; preds = %6
%14 = tail call i32 (...) @oom()
br label %15
15: ; preds = %6, %13, %1
%16 = phi i64 [ %9, %6 ], [ %9, %13 ], [ %2, %1 ]
%17 = phi %struct.expression** [ %11, %6 ], [ null, %13 ], [ %4, %1 ]
%18 = tail call %struct.expression* @parse_expression(i32 0)
%19 = getelementptr inbounds %struct.expression*, %struct.expression** %17, i64 %3
store %struct.expression* %18, %struct.expression** %19
%20 = add i64 %3, 1
%21 = icmp eq %struct.expression* %18, null
br i1 %21, label %22, label %1
22: ; preds = %15
ret %struct.expression** %17
}