#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 atoi(char *);
int /*<<< orphan*/ crashFail(char **, int);
int /*<<< orphan*/ print(char *, ...);
int main(int argc, char **argv, char **envp) {
  int num = 0;
  int loopCount = 0;
  int largc = argc;
  char **largv = argv;
  char **lenvp = envp;
  print("\nWelcome to tmpe!\n");
  print("Param count=%u\n", argc);
  for (int cnt = 0; cnt < argc; cnt++) {
    print("Param %u=%s\n", cnt, argv[cnt]);
  }
  print("\n");
  print("Environment @ 0x%08X:\n", &envp);
  for (int cnt = 0; cnt < 100; cnt++) {
    if (lenvp[cnt] != 0) {
      print("\t0x%08X: ", &lenvp[cnt]);
      print("\t%u: %s\n", cnt, lenvp[cnt]);
    }
  }
  print("end of environment ...\n\n");
  if (argc > 1)
    loopCount = atoi(argv[1]);
  else
    loopCount = 1;
  print("Looping %u times\n", loopCount - 1);
  crashFail(argv, loopCount);
  print("Bye bye now!!!\n");
  return 0x1234;
}


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)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <print@plt>
mov    -0x8(%rbp),%esi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <print@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11cb <main+0x9b>
mov    -0x3c(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <print@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1194 <main+0x64>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1040 <print@plt>
lea    0xe50(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <print@plt>
movl   $0x0,-0x40(%rbp)
cmpl   $0x64,-0x40(%rbp)
jge    125c <main+0x12c>
mov    -0x38(%rbp),%rax
movslq -0x40(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1249 <main+0x119>
mov    -0x38(%rbp),%rsi
movslq -0x40(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1040 <print@plt>
mov    -0x40(%rbp),%esi
mov    -0x38(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1040 <print@plt>
jmp    124e <main+0x11e>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11f2 <main+0xc2>
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1040 <print@plt>
cmpl   $0x1,-0x8(%rbp)
jle    1289 <main+0x159>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x20(%rbp)
jmp    1290 <main+0x160>
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%esi
sub    $0x1,%esi
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1040 <print@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1030 <crashFail@plt>
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1040 <print@plt>
mov    $0x1234,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbp
mov    %rsi,%r15
mov    %edi,%r13d
mov    %rdx,0x10(%rsp)
lea    0xead(%rip),%rdi
xor    %eax,%eax
call   1040 <print@plt>
lea    0xeb2(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <print@plt>
test   %r13d,%r13d
jle    1199 <main+0x69>
mov    %r13d,%r14d
lea    0xea9(%rip),%r12
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r15,%rbx,8),%rdx
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <print@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1180 <main+0x50>
mov    %r13d,0xc(%rsp)
lea    0xecc(%rip),%rdi
xor    %eax,%eax
call   1040 <print@plt>
lea    0xe7d(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <print@plt>
lea    0xe81(%rip),%r12
lea    0xe84(%rip),%r13
xor    %r14d,%r14d
xor    %ebx,%ebx
jmp    11ee <main+0xbe>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
add    $0x8,%r14
cmp    $0x64,%rbx
je     1217 <main+0xe7>
cmpq   $0x0,0x0(%rbp,%rbx,8)
je     11e0 <main+0xb0>
lea    (%r14,%rbp,1),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <print@plt>
mov    0x0(%rbp,%rbx,8),%rdx
mov    %r13,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <print@plt>
jmp    11e0 <main+0xb0>
lea    0xe3c(%rip),%rdi
xor    %eax,%eax
call   1040 <print@plt>
mov    $0x1,%ebx
cmpl   $0x1,0xc(%rsp)
jle    123c <main+0x10c>
mov    0x8(%r15),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
lea    -0x1(%rbx),%esi
lea    0xe2d(%rip),%rdi
xor    %eax,%eax
call   1040 <print@plt>
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <crashFail@plt>
lea    0xe27(%rip),%rdi
xor    %eax,%eax
call   1040 <print@plt>
mov    $0x1234,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"\0AWelcome to tmpe!\0A\00"
@.str.1 = [16 x i8] c"Param count=%u\0A\00"
@.str.2 = [13 x i8] c"Param %u=%s\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [23 x i8] c"Environment @ 0x%08X:\0A\00"
@.str.5 = [10 x i8] c"\090x%08X: \00"
@.str.6 = [9 x i8] c"\09%u: %s\0A\00"
@.str.7 = [25 x i8] c"end of environment ...\0A\0A\00"
@.str.8 = [18 x i8] c"Looping %u times\0A\00"
@.str.9 = [16 x i8] c"Bye bye now!!!\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8**
%12 = alloca i8**
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
store i32 0, i32* %8
store i32 0, i32* %9
%15 = load i32, i32* %5
store i32 %15, i32* %10
%16 = load i8**, i8*** %6
store i8** %16, i8*** %11
%17 = load i8**, i8*** %7
store i8** %17, i8*** %12
%18 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* %5
%20 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %19)
store i32 0, i32* %13
br label %21
21: ; preds = %33, %3
%22 = load i32, i32* %13
%23 = load i32, i32* %5
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %36
25: ; preds = %21
%26 = load i32, i32* %13
%27 = load i8**, i8*** %6
%28 = load i32, i32* %13
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %26, i8* %31)
br label %33
33: ; preds = %25
%34 = load i32, i32* %13
%35 = add nsw i32 %34, 1
store i32 %35, i32* %13
br label %21
36: ; preds = %21
%37 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%38 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8*** %7)
store i32 0, i32* %14
br label %39
39: ; preds = %63, %36
%40 = load i32, i32* %14
%41 = icmp slt i32 %40, 100
br i1 %41, label %42, label %66
42: ; preds = %39
%43 = load i8**, i8*** %12
%44 = load i32, i32* %14
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %43, i64 %45
%47 = load i8*, i8** %46
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %62
49: ; preds = %42
%50 = load i8**, i8*** %12
%51 = load i32, i32* %14
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %50, i64 %52
%54 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8** %53)
%55 = load i32, i32* %14
%56 = load i8**, i8*** %12
%57 = load i32, i32* %14
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %55, i8* %60)
br label %62
62: ; preds = %49, %42
br label %63
63: ; preds = %62
%64 = load i32, i32* %14
%65 = add nsw i32 %64, 1
store i32 %65, i32* %14
br label %39
66: ; preds = %39
%67 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%68 = load i32, i32* %5
%69 = icmp sgt i32 %68, 1
br i1 %69, label %70, label %75
70: ; preds = %66
%71 = load i8**, i8*** %6
%72 = getelementptr inbounds i8*, i8** %71, i64 1
%73 = load i8*, i8** %72
%74 = call i32 @atoi(i8* %73)
store i32 %74, i32* %9
br label %76
75: ; preds = %66
store i32 1, i32* %9
br label %76
76: ; preds = %75, %70
%77 = load i32, i32* %9
%78 = sub nsw i32 %77, 1
%79 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32 %78)
%80 = load i8**, i8*** %6
%81 = load i32, i32* %9
%82 = call i32 @crashFail(i8** %80, i32 %81)
%83 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
ret i32 4660
}

LLVM IR (-O2):
@.str = [19 x i8] c"\0AWelcome to tmpe!\0A\00"
@.str.1 = [16 x i8] c"Param count=%u\0A\00"
@.str.2 = [13 x i8] c"Param %u=%s\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [23 x i8] c"Environment @ 0x%08X:\0A\00"
@.str.5 = [10 x i8] c"\090x%08X: \00"
@.str.6 = [9 x i8] c"\09%u: %s\0A\00"
@.str.7 = [25 x i8] c"end of environment ...\0A\0A\00"
@.str.8 = [18 x i8] c"Looping %u times\0A\00"
@.str.9 = [16 x i8] c"Bye bye now!!!\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i8**
store i8** %2, i8*** %4
%5 = tail call i32 (i8*, ...) @print(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @print(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = zext i32 %0 to i64
br label %13
10: ; preds = %13, %3
%11 = tail call i32 (i8*, ...) @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8*** %4)
br label %24
13: ; preds = %8, %13
%14 = phi i64 [ 0, %8 ], [ %19, %13 ]
%15 = getelementptr inbounds i8*, i8** %1, i64 %14
%16 = load i8*, i8** %15
%17 = trunc i64 %14 to i32
%18 = tail call i32 (i8*, ...) @print(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %17, i8* %16)
%19 = add nuw nsw i64 %14, 1
%20 = icmp eq i64 %19, %9
br i1 %20, label %10, label %13
21: ; preds = %34
%22 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%23 = icmp sgt i32 %0, 1
br i1 %23, label %37, label %41
24: ; preds = %10, %34
%25 = phi i64 [ 0, %10 ], [ %35, %34 ]
%26 = getelementptr inbounds i8*, i8** %2, i64 %25
%27 = load i8*, i8** %26
%28 = icmp eq i8* %27, null
br i1 %28, label %34, label %29
29: ; preds = %24
%30 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8** %26)
%31 = load i8*, i8** %26
%32 = trunc i64 %25 to i32
%33 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %32, i8* %31)
br label %34
34: ; preds = %24, %29
%35 = add nuw nsw i64 %25, 1
%36 = icmp eq i64 %35, 100
br i1 %36, label %21, label %24
37: ; preds = %21
%38 = getelementptr inbounds i8*, i8** %1, i64 1
%39 = load i8*, i8** %38
%40 = call i32 @atoi(i8* %39)
br label %41
41: ; preds = %21, %37
%42 = phi i32 [ %40, %37 ], [ 1, %21 ]
%43 = add nsw i32 %42, -1
%44 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32 %43)
%45 = call i32 @crashFail(i8** %1, i32 %42)
%46 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
ret i32 4660
}