#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 /*<<< orphan*/ STDOUT_FILENO;
scalar_t__ fork();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
int main(void) {
  write(STDOUT_FILENO, "1", 1);
  if (fork() > 0) {
    sleep(1);
    write(STDOUT_FILENO, "2", 1);
    sleep(1);
    write(STDOUT_FILENO, "3", 1);
    sleep(1);
  } else {
    sleep(1);
    write(STDOUT_FILENO, "4", 1);
    sleep(1);
    write(STDOUT_FILENO, "5", 1);
    sleep(1);
  }
  write(STDOUT_FILENO, "\n", 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eaa(%rip),%rax
mov    (%rax),%edi
lea    0xeb1(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x0,%al
call   1050 <fork@plt>
cmp    $0x0,%rax
jle    11c1 <main+0x91>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
lea    0xe7e(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe5c(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
jmp    1213 <main+0xe3>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
lea    0xe2b(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
lea    0xe09(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
lea    0xde7(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2eb5(%rip),%r14
mov    (%r14),%edi
lea    0xebb(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
xor    %eax,%eax
call   1050 <fork@plt>
mov    %rax,%rbx
mov    $0x1,%edi
call   1040 <sleep@plt>
test   %rbx,%rbx
mov    (%r14),%edi
lea    0xe92(%rip),%rax
lea    0xe8f(%rip),%rsi
cmovg  %rax,%rsi
lea    0xe82(%rip),%rax
lea    0xe7f(%rip),%rbx
cmovg  %rax,%rbx
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    (%r14),%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    (%r14),%edi
lea    0xe45(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@STDOUT_FILENO = global i32 0
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"2\00"
@.str.2 = [2 x i8] c"3\00"
@.str.3 = [2 x i8] c"4\00"
@.str.4 = [2 x i8] c"5\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = load i32, i32* @STDOUT_FILENO
%3 = call i32 @write(i32 %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%4 = call i64 (...) @fork()
%5 = icmp sgt i64 %4, 0
br i1 %5, label %6, label %14
6: ; preds = %0
%7 = call i32 @sleep(i32 1)
%8 = load i32, i32* @STDOUT_FILENO
%9 = call i32 @write(i32 %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%10 = call i32 @sleep(i32 1)
%11 = load i32, i32* @STDOUT_FILENO
%12 = call i32 @write(i32 %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%13 = call i32 @sleep(i32 1)
br label %22
14: ; preds = %0
%15 = call i32 @sleep(i32 1)
%16 = load i32, i32* @STDOUT_FILENO
%17 = call i32 @write(i32 %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%18 = call i32 @sleep(i32 1)
%19 = load i32, i32* @STDOUT_FILENO
%20 = call i32 @write(i32 %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1)
%21 = call i32 @sleep(i32 1)
br label %22
22: ; preds = %14, %6
%23 = load i32, i32* @STDOUT_FILENO
%24 = call i32 @write(i32 %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1)
ret i32 0
}

LLVM IR (-O2):
@STDOUT_FILENO = global i32 0
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"2\00"
@.str.2 = [2 x i8] c"3\00"
@.str.3 = [2 x i8] c"4\00"
@.str.4 = [2 x i8] c"5\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = load i32, i32* @STDOUT_FILENO
%2 = tail call i32 @write(i32 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%3 = tail call i64 (...) @fork()
%4 = icmp sgt i64 %3, 0
%5 = tail call i32 @sleep(i32 1)
%6 = load i32, i32* @STDOUT_FILENO
%7 = select i1 %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%8 = select i1 %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0)
%9 = tail call i32 @write(i32 %6, i8* %7, i32 1)
%10 = tail call i32 @sleep(i32 1)
%11 = load i32, i32* @STDOUT_FILENO
%12 = tail call i32 @write(i32 %11, i8* %8, i32 1)
%13 = tail call i32 @sleep(i32 1)
%14 = load i32, i32* @STDOUT_FILENO
%15 = tail call i32 @write(i32 %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1)
ret i32 0
}