#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*/ execv(char *, char **);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ waitpid(scalar_t__, int /*<<< orphan*/, int /*<<< orphan*/);
int main() {
  pid_t pid = fork();
  if (pid == 0) {
    static char *argv[] = {"echo", "Foo is my name.", NULL};
    execv("/bin/echo", argv);
    exit(127);
  } else {
    waitpid(pid, 0, 0);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1182 <main+0x42>
lea    0xea4(%rip),%rdi
lea    0x2edd(%rip),%rsi
call   1050 <execv@plt>
mov    $0x7f,%edi
call   1040 <exit@plt>
mov    -0x10(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1030 <waitpid@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
je     115d <main+0x1d>
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <waitpid@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xeac(%rip),%rdi
lea    0x2ee5(%rip),%rsi
call   1050 <execv@plt>
mov    $0x7f,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@main.argv = internal global [3 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str = [5 x i8] c"echo\00"
@.str.1 = [16 x i8] c"Foo is my name.\00"
@.str.2 = [10 x i8] c"/bin/echo\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
store i32 0, i32* %1
%3 = call i64 (...) @fork()
store i64 %3, i64* %2
%4 = load i64, i64* %2
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i32 @execv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @main.argv, i64 0, i64 0))
%8 = call i32 @exit(i32 127)
unreachable
9: ; preds = %0
%10 = load i64, i64* %2
%11 = call i32 @waitpid(i64 %10, i32 0, i32 0)
br label %12
12: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@main.argv = internal global [3 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str = [5 x i8] c"echo\00"
@.str.1 = [16 x i8] c"Foo is my name.\00"
@.str.2 = [10 x i8] c"/bin/echo\00"
define i32 @main() {
%1 = tail call i64 (...) @fork()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 @execv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @main.argv, i64 0, i64 0))
%5 = tail call i32 @exit(i32 127)
unreachable
6: ; preds = %0
%7 = tail call i32 @waitpid(i64 %1, i32 0, i32 0)
ret i32 0
}