#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 /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int /*<<< orphan*/);
int main(int argc, char const *argv[]) {
  pid_t pid = fork();
  if (pid == 0) {
    write(STDOUT_FILENO, "Hello ", strlen("Hello "));
  } else {
    wait(NULL);
    write(STDOUT_FILENO, "world !\n", strlen("world !\n"));
  }
  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    119a <main+0x5a>
mov    0x2e7d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
lea    0xe81(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%edx
lea    0xe70(%rip),%rsi
call   1030 <write@plt>
jmp    11cc <main+0x8c>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <wait@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
lea    0xe51(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%edi
mov    %eax,%edx
lea    0xe40(%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     115f <main+0x1f>
xor    %edi,%edi
call   1050 <wait@plt>
lea    0xeaa(%rip),%rbx
jmp    1166 <main+0x26>
lea    0xe9a(%rip),%rbx
mov    0x2e83(%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 = [7 x i8] c"Hello \00"
@.str.1 = [9 x i8] c"world !\0A\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 %14
10: ; preds = %2
%11 = load i32, i32* @STDOUT_FILENO
%12 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @write(i32 %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %19
14: ; preds = %2
%15 = call i32 @wait(i32* null)
%16 = load i32, i32* @STDOUT_FILENO
%17 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @write(i32 %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %14, %10
ret i32 0
}

LLVM IR (-O2):
@STDOUT_FILENO = global i32 0
@.str = [7 x i8] c"Hello \00"
@.str.1 = [9 x i8] c"world !\0A\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 %7, label %5
5: ; preds = %2
%6 = tail call i32 @wait(i32* null)
br label %7
7: ; preds = %2, %5
%8 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %2 ]
%9 = load i32, i32* @STDOUT_FILENO
%10 = tail call i32 @strlen(i8* %8)
%11 = tail call i32 @write(i32 %9, i8* %8, i32 %10)
ret i32 0
}