#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 a();
int atoi(char *);
int fork();
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int ret = 0;
  if (argc > 1)
    ret = atoi(argv[1]);
  switch (fork()) {
  case -1:
    return 1;
  default:
    wait(NULL);
  case 0:
    ret += a();
    break;
  }
  return ret ? 0 : 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1177 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
call   1060 <fork@plt>
mov    %eax,%ecx
mov    %ecx,-0x18(%rbp)
sub    $0xffffffff,%eax
je     11a1 <main+0x61>
jmp    1191 <main+0x51>
mov    -0x18(%rbp),%eax
test   %eax,%eax
je     11b6 <main+0x76>
jmp    11ad <main+0x6d>
movl   $0x1,-0x4(%rbp)
jmp    11d6 <main+0x96>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <wait@plt>
mov    $0x0,%al
call   1030 <a@plt>
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %ebx,%ebx
cmp    $0x2,%edi
jl     1153 <main+0x13>
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <fork@plt>
cmp    $0xffffffff,%eax
je     117c <main+0x3c>
test   %eax,%eax
je     116a <main+0x2a>
xor    %edi,%edi
call   1050 <wait@plt>
xor    %eax,%eax
call   1030 <a@plt>
mov    %eax,%ecx
xor    %eax,%eax
add    %ecx,%ebx
sete   %al
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @atoi(i8* %12)
store i32 %13, i32* %6
br label %14
14: ; preds = %9, %2
%15 = call i32 (...) @fork()
switch i32 %15, label %17 [
i32 -1, label %16
i32 0, label %19
]
16: ; preds = %14
store i32 1, i32* %3
br label %28
17: ; preds = %14
%18 = call i32 @wait(i32* null)
br label %19
19: ; preds = %14, %17
%20 = call i32 (...) @a()
%21 = load i32, i32* %6
%22 = add nsw i32 %21, %20
store i32 %22, i32* %6
br label %23
23: ; preds = %19
%24 = load i32, i32* %6
%25 = icmp ne i32 %24, 0
%26 = zext i1 %25 to i64
%27 = select i1 %25, i32 0, i32 1
store i32 %27, i32* %3
br label %28
28: ; preds = %23, %16
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
br label %8
8: ; preds = %4, %2
%9 = phi i32 [ %7, %4 ], [ 0, %2 ]
%10 = tail call i32 (...) @fork()
switch i32 %10, label %11 [
i32 -1, label %18
i32 0, label %13
]
11: ; preds = %8
%12 = tail call i32 @wait(i32* null)
br label %13
13: ; preds = %8, %11
%14 = tail call i32 (...) @a()
%15 = sub i32 0, %14
%16 = icmp eq i32 %9, %15
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %8, %13
%19 = phi i32 [ %17, %13 ], [ 1, %8 ]
ret i32 %19
}