#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 write(int, char *, int);
int main(int argc, char **argv) {
  if (argc < 2)
    return 99;
  if (write(1, "\n", 1) != 1) {
    perror("write");
    return 99;
  }
  (void)execvp(argv[1], argv + 1);
  perror(argv[1]);
  return 99;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    115c <main+0x2c>
movl   $0x63,-0x4(%rbp)
jmp    11b9 <main+0x89>
mov    $0x1,%edx
lea    0xe98(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
cmp    $0x1,%eax
je     1190 <main+0x60>
lea    0xe83(%rip),%rdi
call   1040 <perror@plt>
movl   $0x63,-0x4(%rbp)
jmp    11b9 <main+0x89>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1050 <execvp@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <perror@plt>
movl   $0x63,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
cmp    $0x2,%edi
jge    113b <main+0xb>
mov    $0x63,%eax
ret
push   %rbx
mov    %rsi,%rbx
lea    0xeba(%rip),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1030 <write@plt>
cmp    $0x1,%eax
jne    116d <main+0x3d>
lea    0x8(%rbx),%rsi
mov    0x8(%rbx),%rdi
call   1050 <execvp@plt>
mov    0x8(%rbx),%rdi
jmp    1174 <main+0x44>
lea    0xe8e(%rip),%rdi
call   1040 <perror@plt>
pop    %rbx
mov    $0x63,%eax
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [6 x i8] c"write\00"
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 %9
8: ; preds = %2
store i32 99, i32* %3
br label %25
9: ; preds = %2
%10 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%11 = icmp ne i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 99, i32* %3
br label %25
14: ; preds = %9
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = call i32 @execvp(i8* %17, i8** %19)
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @perror(i8* %23)
store i32 99, i32* %3
br label %25
25: ; preds = %14, %12, %8
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [6 x i8] c"write\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %15, label %4
4: ; preds = %2
%5 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %12
7: ; preds = %4
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @execvp(i8* %9, i8** %8)
%11 = load i8*, i8** %8
br label %12
12: ; preds = %4, %7
%13 = phi i8* [ %11, %7 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %4 ]
%14 = tail call i32 @perror(i8* %13)
br label %15
15: ; preds = %12, %2
ret i32 99
}