#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*/ strcmp(char *, char *);
int usage(char *, char *);
int main(int argc, char **argv) {
  char *progname;
  if (argc < 2)
    return usage(argv[0], "Too few arguments");
  argv++;
  if (!strcmp(argv[0], "arg0name"))
    return usage(argv[0], "Don't call arg0name on itself");
  progname = argv[0];
  if (argc > 2)
    argv++;
  execvp(progname, argv);
  return 0;
}


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)
cmpl   $0x2,-0x8(%rbp)
jge    116b <main+0x3b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xea2(%rip),%rsi
call   1040 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    11e3 <main+0xb3>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe8d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11ae <main+0x7e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe7a(%rip),%rsi
call   1040 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    11e3 <main+0xb3>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    11cf <main+0x9f>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <execvp@plt>
movl   $0x0,-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,%rbx
cmp    $0x1,%edi
jg     1148 <main+0x18>
mov    (%rbx),%rdi
lea    0xeba(%rip),%rsi
jmp    118c <main+0x5c>
mov    %edi,%ebp
mov    0x8(%rbx),%r14
lea    0xebd(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1182 <main+0x52>
lea    0x8(%rbx),%rax
add    $0x10,%rbx
cmp    $0x3,%ebp
cmovb  %rax,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <execvp@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe92(%rip),%rsi
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <usage@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"Too few arguments\00"
@.str.1 = [9 x i8] c"arg0name\00"
@.str.2 = [30 x i8] c"Don't call arg0name on itself\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 @usage(i8* %12, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %3
br label %40
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i32 1
store i8** %16, i8*** %5
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @strcmp(i8* %19, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp ne i32 %20, 0
br i1 %21, label %27, label %22
22: ; preds = %14
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = call i32 @usage(i8* %25, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
store i32 %26, i32* %3
br label %40
27: ; preds = %14
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
store i8* %30, i8** %6
%31 = load i32, i32* %4
%32 = icmp sgt i32 %31, 2
br i1 %32, label %33, label %36
33: ; preds = %27
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i32 1
store i8** %35, i8*** %5
br label %36
36: ; preds = %33, %27
%37 = load i8*, i8** %6
%38 = load i8**, i8*** %5
%39 = call i32 @execvp(i8* %37, i8** %38)
store i32 0, i32* %3
br label %40
40: ; preds = %36, %22, %9
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [18 x i8] c"Too few arguments\00"
@.str.1 = [9 x i8] c"arg0name\00"
@.str.2 = [30 x i8] c"Don't call arg0name on itself\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @usage(i8* %5, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %19
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 @usage(i8* %9, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %19
14: ; preds = %7
%15 = icmp ugt i32 %0, 2
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = select i1 %15, i8** %16, i8** %8
%18 = tail call i32 @execvp(i8* %9, i8** %17)
br label %19
19: ; preds = %14, %12, %4
%20 = phi i32 [ %6, %4 ], [ 0, %14 ], [ %13, %12 ]
ret i32 %20
}