#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 pid_t;

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int iaddv(int, int);
int wait(int *);
int main(void) {
  pid_t child = fork();
  int status = 0;
  if (child == 0) {
    volatile int x = iaddv(0x7fffffff, 1);
    exit(0);
  } else if (child == -1)
    return 0;
  if (wait(&status) == child && status == 0)
    abort();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <fork@plt>
mov    %eax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1193 <main+0x43>
mov    $0x7fffffff,%edi
mov    $0x1,%esi
call   1040 <iaddv@plt>
mov    %eax,-0x10(%rbp)
xor    %edi,%edi
call   1050 <exit@plt>
cmpl   $0xffffffff,-0x8(%rbp)
jne    11a9 <main+0x59>
movl   $0x0,-0x4(%rbp)
jmp    11d8 <main+0x88>
jmp    11ae <main+0x5e>
lea    -0xc(%rbp),%rdi
call   1060 <wait@plt>
cmp    -0x8(%rbp),%eax
jne    11d1 <main+0x81>
cmpl   $0x0,-0xc(%rbp)
jne    11d1 <main+0x81>
mov    $0x0,%al
call   1030 <abort@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1070 <fork@plt>
movl   $0x0,0x8(%rsp)
cmp    $0xffffffff,%eax
je     1184 <main+0x34>
mov    %eax,%ebx
test   %eax,%eax
je     118c <main+0x3c>
lea    0x8(%rsp),%rdi
call   1060 <wait@plt>
cmp    %ebx,%eax
jne    1184 <main+0x34>
cmpl   $0x0,0x8(%rsp)
je     11a6 <main+0x56>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    $0x7fffffff,%edi
mov    $0x1,%esi
call   1040 <iaddv@plt>
mov    %eax,0xc(%rsp)
xor    %edi,%edi
call   1050 <exit@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (...) @fork()
store i32 %5, i32* %2
store i32 0, i32* %3
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 @iaddv(i32 2147483647, i32 1)
store volatile i32 %9, i32* %4
%10 = call i32 @exit(i32 0)
unreachable
11: ; preds = %0
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 0, i32* %1
br label %26
15: ; preds = %11
br label %16
16: ; preds = %15
%17 = call i32 @wait(i32* %3)
%18 = load i32, i32* %2
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 (...) @abort()
unreachable
25: ; preds = %20, %16
store i32 0, i32* %1
br label %26
26: ; preds = %25, %14
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = tail call i32 (...) @fork()
%4 = bitcast i32* %1 to i8*
store i32 0, i32* %1
switch i32 %3, label %9 [
i32 0, label %5
i32 -1, label %17
]
5: ; preds = %0
%6 = bitcast i32* %2 to i8*
%7 = tail call i32 @iaddv(i32 2147483647, i32 1)
store volatile i32 %7, i32* %2
%8 = tail call i32 @exit(i32 0)
unreachable
9: ; preds = %0
%10 = call i32 @wait(i32* %1)
%11 = icmp eq i32 %10, %3
%12 = load i32, i32* %1
%13 = icmp eq i32 %12, 0
%14 = select i1 %11, i1 %13, i1 false
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = call i32 (...) @abort()
unreachable
17: ; preds = %9, %0
ret i32 0
}