#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*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ p32();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int wait(int *);
int main() {
  pid_t pid;
  int n;
  printf("p10\n");
  if ((pid = fork()) == -1)
    printf("can't fork");
  if (pid == 0) {
    p32();
  } else {
    printf("p11\n");
    while (wait((int *)0) != pid)
      ;
  }
  printf("p13\n");
  if ((pid = fork()) == -1)
    printf("can't fork");
  if (pid == 0) {
    printf("Please input a number between -128 and 127:\n");
    scanf("%d", &n);
    printf("p5\n");
    exit(0);
  } else {
    printf("p4\n");
    while (wait((int *)0) != pid)
      ;
  }
  printf("p14\n");
  return (n);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1080 <fork@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
jne    119a <main+0x3a>
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    11b0 <main+0x50>
mov    $0x0,%al
call   1050 <p32@plt>
jmp    11d8 <main+0x78>
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <wait@plt>
cmp    -0x8(%rbp),%eax
je     11d3 <main+0x73>
jmp    11bc <main+0x5c>
jmp    11d8 <main+0x78>
lea    0xe36(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1080 <fork@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
jne    1203 <main+0xa3>
lea    0xe07(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    123c <main+0xdc>
lea    0xe06(%rip),%rdi
call   1030 <printf@plt>
lea    0xe27(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe1a(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
lea    0xe0b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <wait@plt>
cmp    -0x8(%rbp),%eax
je     125f <main+0xff>
jmp    1248 <main+0xe8>
jmp    1264 <main+0x104>
lea    0xde7(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1090 <fork@plt>
test   %eax,%eax
je     11bd <main+0x4d>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    119f <main+0x2f>
lea    0xe66(%rip),%rdi
call   1040 <printf@plt>
lea    0xe6c(%rip),%rdi
call   1030 <puts@plt>
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
call   1080 <wait@plt>
cmp    %ebx,%eax
jne    11b0 <main+0x40>
jmp    11c4 <main+0x54>
xor    %eax,%eax
call   1060 <p32@plt>
lea    0xe4b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1090 <fork@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     1212 <main+0xa2>
test   %ebx,%ebx
jne    121e <main+0xae>
lea    0xe38(%rip),%rdi
call   1030 <puts@plt>
lea    0xe16(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xe47(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0xde7(%rip),%rdi
call   1040 <printf@plt>
lea    0xdf5(%rip),%rdi
call   1030 <puts@plt>
nopw   0x0(%rax,%rax,1)
xor    %edi,%edi
call   1080 <wait@plt>
cmp    %ebx,%eax
jne    1230 <main+0xc0>
lea    0xddb(%rip),%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"p10\0A\00"
@.str.1 = [11 x i8] c"can't fork\00"
@.str.2 = [5 x i8] c"p11\0A\00"
@.str.3 = [5 x i8] c"p13\0A\00"
@.str.4 = [45 x i8] c"Please input a number between -128 and 127:\0A\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [4 x i8] c"p5\0A\00"
@.str.7 = [4 x i8] c"p4\0A\00"
@.str.8 = [5 x i8] c"p14\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (...) @fork()
store i32 %5, i32* %2
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 (...) @p32()
br label %22
14: ; preds = %9
%15 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %20, %14
%17 = call i32 @wait(i32* null)
%18 = load i32, i32* %2
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %16
br label %16
21: ; preds = %16
br label %22
22: ; preds = %21, %12
%23 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 (...) @fork()
store i32 %24, i32* %2
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %26, %22
%29 = load i32, i32* %2
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %28
%32 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%35 = call i32 @exit(i32 0)
unreachable
36: ; preds = %28
%37 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %38
38: ; preds = %42, %36
%39 = call i32 @wait(i32* null)
%40 = load i32, i32* %2
%41 = icmp ne i32 %39, %40
br i1 %41, label %42, label %43
42: ; preds = %38
br label %38
43: ; preds = %38
br label %44
44: ; preds = %43
%45 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"can't fork\00"
@.str.5 = [3 x i8] c"%d\00"
@str = [4 x i8] c"p10\00"
@str.9 = [4 x i8] c"p11\00"
@str.10 = [4 x i8] c"p13\00"
@str.11 = [3 x i8] c"p4\00"
@str.12 = [4 x i8] c"p14\00"
@str.13 = [44 x i8] c"Please input a number between -128 and 127:\00"
@str.14 = [3 x i8] c"p5\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (...) @fork()
switch i32 %4, label %9 [
i32 -1, label %5
i32 0, label %7
]
5: ; preds = %0
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %9
7: ; preds = %0
%8 = tail call i32 (...) @p32()
br label %14
9: ; preds = %5, %0
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.9, i64 0, i64 0))
br label %11
11: ; preds = %11, %9
%12 = tail call i32 @wait(i32* null)
%13 = icmp eq i32 %12, %4
br i1 %13, label %14, label %11
14: ; preds = %11, %7
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.10, i64 0, i64 0))
%16 = tail call i32 (...) @fork()
switch i32 %16, label %24 [
i32 -1, label %17
i32 0, label %19
]
17: ; preds = %14
%18 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %24
19: ; preds = %14
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.13, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.14, i64 0, i64 0))
%23 = call i32 @exit(i32 0)
unreachable
24: ; preds = %17, %14
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.11, i64 0, i64 0))
br label %26
26: ; preds = %26, %24
%27 = tail call i32 @wait(i32* null)
%28 = icmp eq i32 %27, %16
br i1 %28, label %29, label %26
29: ; preds = %26
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.12, i64 0, i64 0))
ret i32 undef
}