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

/* Variables and functions */
int /*<<< orphan*/ fork();
scalar_t__ getpid();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ write(int, char *, int);
int main() {
  pid_t oid = getpid();
  fork();
  pid_t nid = getpid();
  if (oid == nid) {
    int i;
    for (i = 0; i < 10; i++) {
      write(1, "*", 1);
      sleep(1);
    }
  } else {
    int i;
    for (i = 0; i < 20; i++) {
      write(1, "#", 1);
      sleep(1);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <fork@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    11bb <main+0x7b>
movl   $0x0,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    11b6 <main+0x76>
mov    $0x1,%edx
lea    0xe69(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1181 <main+0x41>
jmp    11fc <main+0xbc>
movl   $0x0,-0x20(%rbp)
cmpl   $0x14,-0x20(%rbp)
jge    11f7 <main+0xb7>
mov    $0x1,%edx
lea    0xe2a(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c2 <main+0x82>
jmp    11fc <main+0xbc>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <fork@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
cmp    %rax,%rbx
jne    116a <main+0x2a>
lea    0xe9b(%rip),%rbx
jmp    1289 <main+0x149>
lea    0xe91(%rip),%rbx
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"*\00"
@.str.1 = [2 x i8] c"#\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i64 (...) @getpid()
store i64 %6, i64* %2
%7 = call i32 (...) @fork()
%8 = call i64 (...) @getpid()
store i64 %8, i64* %3
%9 = load i64, i64* %2
%10 = load i64, i64* %3
%11 = icmp eq i64 %9, %10
br i1 %11, label %12, label %23
12: ; preds = %0
store i32 0, i32* %4
br label %13
13: ; preds = %19, %12
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 10
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%18 = call i32 @sleep(i32 1)
br label %19
19: ; preds = %16
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %13
22: ; preds = %13
br label %34
23: ; preds = %0
store i32 0, i32* %5
br label %24
24: ; preds = %30, %23
%25 = load i32, i32* %5
%26 = icmp slt i32 %25, 20
br i1 %26, label %27, label %33
27: ; preds = %24
%28 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%29 = call i32 @sleep(i32 1)
br label %30
30: ; preds = %27
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %24
33: ; preds = %24
br label %34
34: ; preds = %33, %22
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@.str = [2 x i8] c"*\00"
@.str.1 = [2 x i8] c"#\00"
define i32 @main() {
%1 = tail call i64 (...) @getpid()
%2 = tail call i32 (...) @fork()
%3 = tail call i64 (...) @getpid()
%4 = icmp eq i64 %1, %3
br i1 %4, label %26, label %5
5: ; preds = %0
%6 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%7 = tail call i32 @sleep(i32 1)
%8 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%9 = tail call i32 @sleep(i32 1)
%10 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%11 = tail call i32 @sleep(i32 1)
%12 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%13 = tail call i32 @sleep(i32 1)
%14 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%15 = tail call i32 @sleep(i32 1)
%16 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%17 = tail call i32 @sleep(i32 1)
%18 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%19 = tail call i32 @sleep(i32 1)
%20 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%21 = tail call i32 @sleep(i32 1)
%22 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%23 = tail call i32 @sleep(i32 1)
%24 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%25 = tail call i32 @sleep(i32 1)
br label %26
26: ; preds = %0, %5
%27 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %0 ]
%28 = tail call i32 @write(i32 1, i8* %27, i32 1)
%29 = tail call i32 @sleep(i32 1)
%30 = tail call i32 @write(i32 1, i8* %27, i32 1)
%31 = tail call i32 @sleep(i32 1)
%32 = tail call i32 @write(i32 1, i8* %27, i32 1)
%33 = tail call i32 @sleep(i32 1)
%34 = tail call i32 @write(i32 1, i8* %27, i32 1)
%35 = tail call i32 @sleep(i32 1)
%36 = tail call i32 @write(i32 1, i8* %27, i32 1)
%37 = tail call i32 @sleep(i32 1)
%38 = tail call i32 @write(i32 1, i8* %27, i32 1)
%39 = tail call i32 @sleep(i32 1)
%40 = tail call i32 @write(i32 1, i8* %27, i32 1)
%41 = tail call i32 @sleep(i32 1)
%42 = tail call i32 @write(i32 1, i8* %27, i32 1)
%43 = tail call i32 @sleep(i32 1)
%44 = tail call i32 @write(i32 1, i8* %27, i32 1)
%45 = tail call i32 @sleep(i32 1)
%46 = tail call i32 @write(i32 1, i8* %27, i32 1)
%47 = tail call i32 @sleep(i32 1)
ret i32 0
}