#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*/ EXIT_SUCCESS;
int /*<<< orphan*/ err_sys(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ print_message_function(char *);
int /*<<< orphan*/ printf(char *);
int main(void) {
  pid_t pid;
  char *message1 = "Goodbye";
  char *message2 = "World";
  if ((pid = fork()) < 0) {
    err_sys("fork error");
  } else if (pid == 0) {
    print_message_function(message1);
    exit(EXIT_SUCCESS);
  }
  if ((pid = fork()) < 0) {
    err_sys("fork error");
  } else if (pid == 0) {
    print_message_function(message2);
    printf("\n");
    exit(EXIT_SUCCESS);
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe97(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jge    119b <main+0x4b>
lea    0xe7d(%rip),%rdi
call   1030 <err_sys@plt>
jmp    11c2 <main+0x72>
cmpq   $0x0,-0x10(%rbp)
jne    11bd <main+0x6d>
mov    -0x18(%rbp),%rdi
call   1050 <print_message_function@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
jmp    11c2 <main+0x72>
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jge    11e8 <main+0x98>
lea    0xe30(%rip),%rdi
call   1030 <err_sys@plt>
jmp    121b <main+0xcb>
cmpq   $0x0,-0x10(%rbp)
jne    1216 <main+0xc6>
mov    -0x20(%rbp),%rdi
call   1050 <print_message_function@plt>
lea    0xe16(%rip),%rdi
call   1040 <printf@plt>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
jmp    121b <main+0xcb>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
jns    116b <main+0x1b>
lea    0xeaa(%rip),%rdi
call   1040 <err_sys@plt>
jmp    117b <main+0x2b>
jne    117b <main+0x2b>
lea    0xe8c(%rip),%rdi
call   1050 <print_message_function@plt>
jmp    11ad <main+0x5d>
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
jns    1195 <main+0x45>
lea    0xe80(%rip),%rdi
call   1040 <err_sys@plt>
jmp    11ad <main+0x5d>
jne    11ad <main+0x5d>
lea    0xe6a(%rip),%rdi
call   1050 <print_message_function@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

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

LLVM IR (-O2):
@.str = [8 x i8] c"Goodbye\00"
@.str.1 = [6 x i8] c"World\00"
@.str.2 = [11 x i8] c"fork error\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i64 (...) @fork()
%2 = icmp slt i64 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @err_sys(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %11
5: ; preds = %0
%6 = icmp eq i64 %1, 0
br i1 %6, label %7, label %11
7: ; preds = %5
%8 = tail call i32 @print_message_function(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @EXIT_SUCCESS
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %5, %3
%12 = tail call i64 (...) @fork()
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @err_sys(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %23
16: ; preds = %11
%17 = icmp eq i64 %12, 0
br i1 %17, label %18, label %23
18: ; preds = %16
%19 = tail call i32 @print_message_function(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%20 = tail call i32 @putchar(i32 10)
%21 = load i32, i32* @EXIT_SUCCESS
%22 = tail call i32 @exit(i32 %21)
unreachable
23: ; preds = %16, %14
%24 = load i32, i32* @EXIT_SUCCESS
%25 = tail call i32 @exit(i32 %24)
unreachable
}