#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*/ STDOUT_FILENO;
scalar_t__ fork();
int getppid();
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int /*<<< orphan*/);
int main(int argc, char const *argv[]) {
  pid_t pid = fork();
  if (pid == 0) {
    while (getppid() != 1) {
    }
    write(STDOUT_FILENO, "world !\n", strlen("world !\n"));
  } else {
    write(STDOUT_FILENO, "Hello ", strlen("Hello "));
  }
  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)
mov    $0x0,%al
call   1060 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b4 <main+0x74>
jmp    1171 <main+0x31>
mov    $0x0,%al
call   1050 <getppid@plt>
cmp    $0x1,%eax
je     1186 <main+0x46>
jmp    1171 <main+0x31>
mov    0x2e63(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
lea    0xe67(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%edx
lea    0xe56(%rip),%rsi
call   1030 <write@plt>
jmp    11dd <main+0x9d>
mov    0x2e35(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
lea    0xe42(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%edi
mov    %eax,%edx
lea    0xe31(%rip),%rsi
call   1030 <write@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
je     1158 <main+0x18>
lea    0xeb3(%rip),%rbx
jmp    116c <main+0x2c>
lea    0xea1(%rip),%rbx
nop
xor    %eax,%eax
call   1050 <getppid@plt>
cmp    $0x1,%eax
jne    1160 <main+0x20>
mov    0x2e7d(%rip),%rax
mov    (%rax),%ebp
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@STDOUT_FILENO = global i32 0
@.str = [9 x i8] c"world !\0A\00"
@.str.1 = [7 x i8] c"Hello \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 i64 (...) @fork()
store i64 %7, i64* %6
%8 = load i64, i64* %6
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %2
br label %11
11: ; preds = %14, %10
%12 = call i32 (...) @getppid()
%13 = icmp ne i32 %12, 1
br i1 %13, label %14, label %15
14: ; preds = %11
br label %11
15: ; preds = %11
%16 = load i32, i32* @STDOUT_FILENO
%17 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @write(i32 %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %23
19: ; preds = %2
%20 = load i32, i32* @STDOUT_FILENO
%21 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @write(i32 %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %19, %15
ret i32 0
}

LLVM IR (-O2):
@STDOUT_FILENO = global i32 0
@.str = [9 x i8] c"world !\0A\00"
@.str.1 = [7 x i8] c"Hello \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 (...) @fork()
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2, %5
%6 = tail call i32 (...) @getppid()
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %5
8: ; preds = %5, %2
%9 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %5 ]
%10 = load i32, i32* @STDOUT_FILENO
%11 = tail call i32 @strlen(i8* %9)
%12 = tail call i32 @write(i32 %10, i8* %9, i32 %11)
ret i32 0
}