#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*/ errno;
int /*<<< orphan*/ execvp(char *, char **);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    fprintf(stderr, "usage: %s command [argv0 [arg ...]]\n",
            argc ? argv[0] : "exec-as");
  } else {
    execvp(argv[1], &argv[2]);
    fprintf(stderr, "%s: execvp %s: %s\n", argv[0], argv[1], strerror(errno));
  }
  return 138;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11a0 <main+0x70>
mov    0x2e89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1176 <main+0x46>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1186 <main+0x56>
lea    0xea8(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1186 <main+0x56>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rdx
lea    0xe6c(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1202 <main+0xd2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rsi
add    $0x10,%rsi
call   1040 <execvp@plt>
mov    0x2e24(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    %rax,%r8
lea    0xe32(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x8a,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     1150 <main+0x20>
mov    %edi,%eax
mov    0x2e9b(%rip),%rcx
mov    (%rcx),%edi
test   %eax,%eax
je     1196 <main+0x66>
mov    (%rbx),%rdx
jmp    119d <main+0x6d>
mov    0x8(%rbx),%rdi
lea    0x10(%rbx),%rsi
call   1040 <execvp@plt>
mov    0x2e7c(%rip),%rax
mov    (%rax),%ebp
mov    (%rbx),%r14
mov    0x8(%rbx),%rbx
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xeab(%rip),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    11ab <main+0x7b>
lea    0xe88(%rip),%rdx
lea    0xe5c(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x8a,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [37 x i8] c"usage: %s command [argv0 [arg ...]]\0A\00"
@.str.1 = [8 x i8] c"exec-as\00"
@.str.2 = [19 x i8] c"%s: execvp %s: %s\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %20
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
br label %17
16: ; preds = %8
br label %17
17: ; preds = %16, %12
%18 = phi i8* [ %15, %12 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %16 ]
%19 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %37
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = call i32 @execvp(i8* %23, i8** %25)
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = load i32, i32* @errno
%35 = call i8* @strerror(i32 %34)
%36 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %30, i8* %33, i8* %35)
br label %37
37: ; preds = %20, %17
ret i32 138
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [37 x i8] c"usage: %s command [argv0 [arg ...]]\0A\00"
@.str.1 = [8 x i8] c"exec-as\00"
@.str.2 = [19 x i8] c"%s: execvp %s: %s\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %12
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = icmp eq i32 %0, 0
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = load i8*, i8** %1
br label %9
9: ; preds = %4, %7
%10 = phi i8* [ %8, %7 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %4 ]
%11 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %23
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = tail call i32 @execvp(i8* %14, i8** %15)
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %1
%19 = load i8*, i8** %13
%20 = load i32, i32* @errno
%21 = tail call i8* @strerror(i32 %20)
%22 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %18, i8* %19, i8* %21)
br label %23
23: ; preds = %12, %9
ret i32 138
}