#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 */
scalar_t__ fork();
int /*<<< orphan*/ run_child();
int /*<<< orphan*/ run_parent();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ unlink(char *);
int /*<<< orphan*/ waitpid(scalar_t__, int /*<<< orphan*/ *,
                           int /*<<< orphan*/);
int main(int argc, char **argv) {
  pid_t pid;
  srand(time(NULL));
  unlink("number.txt");
  pid = fork();
  if (pid != 0) {
    run_parent();
    waitpid(pid, NULL, 0);
  } else {
    run_child();
  }
  return 0;
}


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)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xe63(%rip),%rdi
call   1030 <unlink@plt>
mov    $0x0,%al
call   1090 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11d3 <main+0x63>
mov    $0x0,%al
call   1050 <run_parent@plt>
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1070 <waitpid@plt>
jmp    11da <main+0x6a>
mov    $0x0,%al
call   1080 <run_child@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xe7a(%rip),%rdi
call   1030 <unlink@plt>
xor    %eax,%eax
call   1090 <fork@plt>
test   %rax,%rax
je     11af <main+0x3f>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <run_parent@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <waitpid@plt>
jmp    11b6 <main+0x46>
xor    %eax,%eax
call   1080 <run_child@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"number.txt\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @time(i32* null)
%8 = call i32 @srand(i32 %7)
%9 = call i32 @unlink(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%10 = call i64 (...) @fork()
store i64 %10, i64* %6
%11 = load i64, i64* %6
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = call i32 (...) @run_parent()
%15 = load i64, i64* %6
%16 = call i32 @waitpid(i64 %15, i32* null, i32 0)
br label %19
17: ; preds = %2
%18 = call i32 (...) @run_child()
br label %19
19: ; preds = %17, %13
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"number.txt\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = tail call i32 @unlink(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = tail call i64 (...) @fork()
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = tail call i32 (...) @run_parent()
%10 = tail call i32 @waitpid(i64 %6, i32* null, i32 0)
br label %13
11: ; preds = %2
%12 = tail call i32 (...) @run_child()
br label %13
13: ; preds = %11, %8
ret i32 0
}