#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*/ assert(int);
int /*<<< orphan*/ execv(char *, char **);
scalar_t__ fork();
scalar_t__ waitpid(scalar_t__, int *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  pid_t pid = fork();
  if (pid == 0) {
    execv("/usr/bin/say", &argv[0]);
  }
  int status;
  pid_t wpid = waitpid(pid, &status, 0);
  assert(pid == wpid);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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    117c <main+0x3c>
mov    -0x10(%rbp),%rsi
lea    0xe89(%rip),%rdi
call   1050 <execv@plt>
mov    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
xor    %edx,%edx
call   1040 <waitpid@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x28(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
xor    %eax,%eax
call   1060 <fork@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1165 <main+0x25>
lea    0xea3(%rip),%rdi
mov    %r14,%rsi
call   1050 <execv@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1040 <waitpid@plt>
xor    %edi,%edi
cmp    %rax,%rbx
sete   %dil
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"/usr/bin/say\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i64 (...) @fork()
store i64 %9, i64* %6
%10 = load i64, i64* %6
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = call i32 @execv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %14)
br label %16
16: ; preds = %12, %2
%17 = load i64, i64* %6
%18 = call i64 @waitpid(i64 %17, i32* %7, i32 0)
store i64 %18, i64* %8
%19 = load i64, i64* %6
%20 = load i64, i64* %8
%21 = icmp eq i64 %19, %20
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"/usr/bin/say\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = tail call i64 (...) @fork()
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @execv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %1)
br label %8
8: ; preds = %6, %2
%9 = bitcast i32* %3 to i8*
%10 = call i64 @waitpid(i64 %4, i32* %3, i32 0)
%11 = icmp eq i64 %4, %10
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
ret i32 0
}