#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*/ dumpProg();
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ run();
int /*<<< orphan*/ strcasecmp(char const *, char *);
int main(int argc, const char *argv[]) {
  printf("Args length: %d\n", argc);
  for (int i = 0; i < argc; ++i)
    printf("argv[%d]: %s\n", i, argv[i]);
  if (argc >= 2) {
    if (!strcasecmp(argv[1], "--dump")) {
      dumpProg();
      return 0;
    }
  }
  run();
  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)
mov    -0x8(%rbp),%esi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a5 <main+0x65>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116e <main+0x2e>
cmpl   $0x2,-0x8(%rbp)
jl     11e4 <main+0xa4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe61(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11df <main+0x9f>
mov    $0x0,%al
call   1060 <dumpProg@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f2 <main+0xb2>
jmp    11e4 <main+0xa4>
mov    $0x0,%al
call   1040 <run@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebx
lea    0xeac(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebx,%ebx
jle    11a3 <main+0x63>
mov    %ebx,%r12d
lea    0xea6(%rip),%r14
xor    %ebx,%ebx
nopl   (%rax)
mov    (%r15,%rbx,8),%rdx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1170 <main+0x30>
cmp    $0x1,%r12d
jle    11a3 <main+0x63>
mov    0x8(%r15),%rdi
lea    0xe85(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11b8 <main+0x78>
xor    %eax,%eax
call   1040 <run@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
xor    %eax,%eax
call   1060 <dumpProg@plt>
jmp    11aa <main+0x6a>

LLVM IR (-O0):
@.str = [17 x i8] c"Args length: %d\0A\00"
@.str.1 = [14 x i8] c"argv[%d]: %s\0A\00"
@.str.2 = [7 x i8] c"--dump\00"
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
%7 = load i32, i32* %4
%8 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %7)
store i32 0, i32* %6
br label %9
9: ; preds = %21, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %24
13: ; preds = %9
%14 = load i32, i32* %6
%15 = load i8**, i8*** %5
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %14, i8* %19)
br label %21
21: ; preds = %13
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
br label %9
24: ; preds = %9
%25 = load i32, i32* %4
%26 = icmp sge i32 %25, 2
br i1 %26, label %27, label %36
27: ; preds = %24
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @strcasecmp(i8* %30, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%32 = icmp ne i32 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %27
%34 = call i32 (...) @dumpProg()
store i32 0, i32* %3
br label %38
35: ; preds = %27
br label %36
36: ; preds = %35, %24
%37 = call i32 (...) @run()
store i32 0, i32* %3
br label %38
38: ; preds = %36, %33
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [17 x i8] c"Args length: %d\0A\00"
@.str.1 = [14 x i8] c"argv[%d]: %s\0A\00"
@.str.2 = [7 x i8] c"--dump\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %0)
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %24
5: ; preds = %2
%6 = zext i32 %0 to i64
br label %9
7: ; preds = %9
%8 = icmp sgt i32 %0, 1
br i1 %8, label %17, label %24
9: ; preds = %5, %9
%10 = phi i64 [ 0, %5 ], [ %15, %9 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = trunc i64 %10 to i32
%14 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %13, i8* %12)
%15 = add nuw nsw i64 %10, 1
%16 = icmp eq i64 %15, %6
br i1 %16, label %7, label %9
17: ; preds = %7
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = tail call i32 @strcasecmp(i8* %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = tail call i32 (...) @dumpProg()
br label %26
24: ; preds = %2, %17, %7
%25 = tail call i32 (...) @run()
br label %26
26: ; preds = %24, %22
ret i32 0
}