#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 EXIT_FAILURE;
int EXIT_SUCCESS;
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ runchild();
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  pid_t pid;
  printf("Fork this process now!\n");
  pid = fork();
  if (pid == (pid_t)0) {
    runchild();
    return EXIT_SUCCESS;
  } else if (pid < (pid_t)0) {
    fprintf(stderr, "Fork failed.\n");
    return EXIT_FAILURE;
  } else {
  }
}


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)
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1190 <main+0x50>
mov    $0x0,%al
call   1050 <runchild@plt>
mov    0x2e4a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11cb <main+0x8b>
cmpq   $0x0,-0x18(%rbp)
jge    11c1 <main+0x81>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
lea    0xe6d(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11cb <main+0x8b>
jmp    11c6 <main+0x86>
jmp    11cb <main+0x8b>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec6(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
je     117b <main+0x3b>
jns    118b <main+0x4b>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e5f(%rip),%rax
jmp    1189 <main+0x49>
xor    %eax,%eax
call   1050 <runchild@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Fork this process now!\0A\00"
@EXIT_SUCCESS = global i32 0
@stderr = global i32 0
@.str.1 = [14 x i8] c"Fork failed.\0A\00"
@EXIT_FAILURE = global i32 0
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 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%8 = call i64 (...) @fork()
store i64 %8, i64* %6
%9 = load i64, i64* %6
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 (...) @runchild()
%13 = load i32, i32* @EXIT_SUCCESS
store i32 %13, i32* %3
br label %23
14: ; preds = %2
%15 = load i64, i64* %6
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
store i32 %20, i32* %3
br label %23
21: ; preds = %14
br label %22
22: ; preds = %21
br label %23
23: ; preds = %11, %17, %22
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@stderr = global i32 0
@.str.1 = [14 x i8] c"Fork failed.\0A\00"
@EXIT_FAILURE = global i32 0
@str = [23 x i8] c"Fork this process now!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%4 = tail call i64 (...) @fork()
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 (...) @runchild()
%8 = load i32, i32* @EXIT_SUCCESS
br label %15
9: ; preds = %2
%10 = icmp slt i64 %4, 0
br i1 %10, label %11, label %15
11: ; preds = %9
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
br label %15
15: ; preds = %9, %11, %6
%16 = phi i32 [ %8, %6 ], [ %14, %11 ], [ 0, %9 ]
ret i32 %16
}