#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 */
int /*<<< orphan*/ execve(char *, char **, char **);
int main(int argc, char **argv, char **envp) {
  if (argc != 2)
    return 2;
  {
    char *args[] = {"echo", argv[1], NULL};
    execve("/bin/echo", args, envp);
  }
  return 1;
}


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    %rdx,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1140 <main+0x30>
movl   $0x2,-0x4(%rbp)
jmp    117a <main+0x6a>
lea    0xebe(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0x30(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe92(%rip),%rdi
call   1030 <execve@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    $0x2,%eax
cmp    $0x2,%edi
jne    1153 <main+0x43>
sub    $0x18,%rsp
lea    0xee0(%rip),%rax
mov    %rax,(%rsp)
mov    0x8(%rsi),%rax
mov    %rax,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xebe(%rip),%rdi
mov    %rsp,%rsi
call   1030 <execve@plt>
mov    $0x1,%eax
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"echo\00"
@.str.1 = [10 x i8] c"/bin/echo\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** %2) {
%4 = alloca [3 x i8*]
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = bitcast [3 x i8*]* %4 to i8*
%8 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 1
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
store i8* %11, i8** %9
%12 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 2
store i8* null, i8** %12
%13 = call i32 @execve(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %8, i8** %2)
br label %14
14: ; preds = %3, %6
%15 = phi i32 [ 1, %6 ], [ 2, %3 ]
ret i32 %15
}