#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*/ execvp(char *, char **);
int /*<<< orphan*/ perror(char *);
int main(int argc, char **argv) {
  char *arguments[1000];
  int i;
  arguments[0] = argv[3];
  for (i = 1; i < argc; ++i)
    arguments[i] = argv[i + 3];
  execvp(arguments[0], arguments);
  perror(arguments[0]);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x1f50(%rbp)
movl   $0x1,-0x1f54(%rbp)
mov    -0x1f54(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1198 <main+0x78>
mov    -0x10(%rbp),%rax
mov    -0x1f54(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rcx
movslq -0x1f54(%rbp),%rax
mov    %rcx,-0x1f50(%rbp,%rax,8)
ff
mov    -0x1f54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1f54(%rbp)
jmp    1152 <main+0x32>
mov    -0x1f50(%rbp),%rdi
lea    -0x1f50(%rbp),%rsi
call   1040 <execvp@plt>
mov    -0x1f50(%rbp),%rdi
call   1030 <perror@plt>
mov    $0x1,%eax
add    $0x1f60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x1f40,%rsp
mov    0x18(%rsi),%rbx
mov    %rbx,(%rsp)
cmp    $0x2,%edi
jl     115c <main+0x2c>
mov    %edi,%edx
lea    0x8(%rsp),%rdi
add    $0x20,%rsi
add    $0xffffffff,%edx
shl    $0x3,%rdx
call   1030 <memcpy@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <execvp@plt>
mov    (%rsp),%rdi
call   1040 <perror@plt>
mov    $0x1,%eax
add    $0x1f40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1000 x i8*]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 3
%10 = load i8*, i8** %9
%11 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %6, i64 0, i64 0
store i8* %10, i8** %11
store i32 1, i32* %7
br label %12
12: ; preds = %26, %2
%13 = load i32, i32* %7
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %29
16: ; preds = %12
%17 = load i8**, i8*** %5
%18 = load i32, i32* %7
%19 = add nsw i32 %18, 3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %17, i64 %20
%22 = load i8*, i8** %21
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %6, i64 0, i64 %24
store i8* %22, i8** %25
br label %26
26: ; preds = %16
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %12
29: ; preds = %12
%30 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %6, i64 0, i64 0
%31 = load i8*, i8** %30
%32 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %6, i64 0, i64 0
%33 = call i32 @execvp(i8* %31, i8** %32)
%34 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %6, i64 0, i64 0
%35 = load i8*, i8** %34
%36 = call i32 @perror(i8* %35)
ret i32 1
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1000 x i8*]
%4 = bitcast [1000 x i8*]* %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 3
%6 = load i8*, i8** %5
%7 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %3, i64 0, i64 0
store i8* %6, i8** %7
%8 = icmp sgt i32 %0, 1
br i1 %8, label %9, label %17
9: ; preds = %2
%10 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %3, i64 0, i64 1
%11 = bitcast i8** %10 to i8*
%12 = getelementptr i8*, i8** %1, i64 4
%13 = bitcast i8** %12 to i8*
%14 = add nsw i32 %0, -1
%15 = zext i32 %14 to i64
%16 = shl nuw nsw i64 %15, 3
br label %17
17: ; preds = %9, %2
%18 = call i32 @execvp(i8* %6, i8** %7)
%19 = load i8*, i8** %7
%20 = call i32 @perror(i8* %19)
ret i32 1
}