#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 */

/* Variables and functions */
unsigned int _sys_fork();
unsigned int _sys_getpid();
int /*<<< orphan*/ print_hex(unsigned int);
int /*<<< orphan*/ print_string(char *);
int main() {
  int i;
  unsigned int pid = _sys_getpid();
  print_string("\nMy process ID is: ");
  print_hex(pid);
  print_string("\n");
  unsigned int frk = _sys_fork();
  print_string("\n");
  print_string("Fork returned: ");
  print_hex(frk);
  pid = _sys_getpid();
  print_string("(");
  print_hex(pid);
  print_string(")\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <_sys_getpid@plt>
mov    %eax,-0xc(%rbp)
lea    0xea0(%rip),%rdi
call   1030 <print_string@plt>
mov    -0xc(%rbp),%edi
call   1050 <print_hex@plt>
lea    0xeb3(%rip),%rdi
call   1030 <print_string@plt>
mov    $0x0,%al
call   1060 <_sys_fork@plt>
mov    %eax,-0x10(%rbp)
lea    0xe9d(%rip),%rdi
call   1030 <print_string@plt>
lea    0xe7e(%rip),%rdi
call   1030 <print_string@plt>
mov    -0x10(%rbp),%edi
call   1050 <print_hex@plt>
mov    $0x0,%al
call   1040 <_sys_getpid@plt>
mov    %eax,-0xc(%rbp)
lea    0xe70(%rip),%rdi
call   1030 <print_string@plt>
mov    -0xc(%rbp),%edi
call   1050 <print_hex@plt>
lea    0xe5e(%rip),%rdi
call   1030 <print_string@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <_sys_getpid@plt>
mov    %eax,%ebx
lea    0xead(%rip),%rdi
call   1030 <print_string@plt>
mov    %ebx,%edi
call   1050 <print_hex@plt>
lea    0xec1(%rip),%rbx
mov    %rbx,%rdi
call   1030 <print_string@plt>
xor    %eax,%eax
call   1060 <_sys_fork@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <print_string@plt>
lea    0xe8e(%rip),%rdi
call   1030 <print_string@plt>
mov    %ebp,%edi
call   1050 <print_hex@plt>
xor    %eax,%eax
call   1040 <_sys_getpid@plt>
mov    %eax,%ebx
lea    0xe82(%rip),%rdi
call   1030 <print_string@plt>
mov    %ebx,%edi
call   1050 <print_hex@plt>
lea    0xe71(%rip),%rdi
call   1030 <print_string@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"\0AMy process ID is: \00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [16 x i8] c"Fork returned: \00"
@.str.3 = [2 x i8] c"(\00"
@.str.4 = [3 x i8] c")\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (...) @_sys_getpid()
store i32 %5, i32* %3
%6 = call i32 @print_string(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %3
%8 = call i32 @print_hex(i32 %7)
%9 = call i32 @print_string(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (...) @_sys_fork()
store i32 %10, i32* %4
%11 = call i32 @print_string(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @print_string(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%13 = load i32, i32* %4
%14 = call i32 @print_hex(i32 %13)
%15 = call i32 (...) @_sys_getpid()
store i32 %15, i32* %3
%16 = call i32 @print_string(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%17 = load i32, i32* %3
%18 = call i32 @print_hex(i32 %17)
%19 = call i32 @print_string(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"\0AMy process ID is: \00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [16 x i8] c"Fork returned: \00"
@.str.3 = [2 x i8] c"(\00"
@.str.4 = [3 x i8] c")\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @_sys_getpid()
%2 = tail call i32 @print_string(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @print_hex(i32 %1)
%4 = tail call i32 @print_string(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 (...) @_sys_fork()
%6 = tail call i32 @print_string(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @print_string(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @print_hex(i32 %5)
%9 = tail call i32 (...) @_sys_getpid()
%10 = tail call i32 @print_string(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%11 = tail call i32 @print_hex(i32 %9)
%12 = tail call i32 @print_string(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}