#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 NR_OPEN;
int /*<<< orphan*/ close(int /*<<< orphan*/);
int /*<<< orphan*/ execvp(char *, char **);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int fd = 3;
  if (argc < 2) {
    fprintf(stderr, "Usage: %s program [args]\n", argv[0]);
    return 1;
  }
  while (fd < NR_OPEN)
    close(fd++);
  execvp(argv[1], argv + 1);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    117f <main+0x4f>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe92(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c7 <main+0x97>
jmp    1184 <main+0x54>
mov    -0x14(%rbp),%eax
mov    0x2e4a(%rip),%rcx
cmp    (%rcx),%eax
jge    11ab <main+0x7b>
mov    -0x14(%rbp),%edi
mov    %edi,%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
call   1030 <close@plt>
jmp    1184 <main+0x54>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1050 <execvp@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
cmp    $0x2,%edi
jge    1156 <main+0x26>
mov    0x2e9d(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xeb1(%rip),%rsi
call   1040 <fprintf@plt>
jmp    118e <main+0x5e>
mov    0x2e7b(%rip),%rbx
cmpl   $0x4,(%rbx)
jl     117e <main+0x4e>
mov    $0x3,%edi
nopw   0x0(%rax,%rax,1)
lea    0x1(%rdi),%ebp
call   1030 <close@plt>
mov    %ebp,%edi
cmp    (%rbx),%ebp
jl     1170 <main+0x40>
mov    0x8(%r14),%rdi
add    $0x8,%r14
mov    %r14,%rsi
call   1050 <execvp@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"Usage: %s program [args]\0A\00"
@NR_OPEN = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 3, i32* %6
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 1, i32* %3
br label %31
15: ; preds = %2
br label %16
16: ; preds = %20, %15
%17 = load i32, i32* %6
%18 = load i32, i32* @NR_OPEN
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
%23 = call i32 @close(i32 %21)
br label %16
24: ; preds = %16
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = call i32 @execvp(i8* %27, i8** %29)
store i32 1, i32* %3
br label %31
31: ; preds = %24, %9
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"Usage: %s program [args]\0A\00"
@NR_OPEN = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i32, i32* @NR_OPEN
%6 = icmp sgt i32 %5, 3
br i1 %6, label %11, label %17
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %1
%10 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %21
11: ; preds = %4, %11
%12 = phi i32 [ %13, %11 ], [ 3, %4 ]
%13 = add nuw nsw i32 %12, 1
%14 = tail call i32 @close(i32 %12)
%15 = load i32, i32* @NR_OPEN
%16 = icmp slt i32 %13, %15
br i1 %16, label %11, label %17
17: ; preds = %11, %4
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = tail call i32 @execvp(i8* %19, i8** %18)
br label %21
21: ; preds = %17, %7
ret i32 1
}