#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  int showHelp = 0;
  int serveIceCream = 0;
  int badSwitch = 0;
  int ind = 1;
  for (; ind < argc; ++ind) {
    if (strcmp(argv[ind], "--help") == 0)
      showHelp = 1;
    else if (strcmp(argv[ind], "-i") == 0)
      serveIceCream = 1;
    else if (strcmp(argv[ind], "--serve-icecream") == 0)
      serveIceCream = 1;
    else {
      badSwitch = 1;
      fprintf(stderr, "Unknown switch: '%s'\n", argv[ind]);
    }
  }
  if (badSwitch) {
    fprintf(stderr, "Aborting...\n");
    return EXIT_FAILURE;
  }
  if (showHelp) {
    printf("Usage: ./icecream OPTIONS...\n"
           "   -i, --serve-icecream  Not as exciting as it sounds\n"
           "\n");
    return EXIT_SUCCESS;
  }
  printf("Do you get icecream? ");
  if (serveIceCream)
    printf("YES!!!\n");
  else
    printf("Sorry, try again next-time.\n");
  return EXIT_SUCCESS;
}


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   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    123f <main+0x10f>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe7f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    119c <main+0x6c>
movl   $0x1,-0x14(%rbp)
jmp    122c <main+0xfc>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe58(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ca <main+0x9a>
movl   $0x1,-0x18(%rbp)
jmp    1227 <main+0xf7>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe2d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11f8 <main+0xc8>
movl   $0x1,-0x18(%rbp)
jmp    1222 <main+0xf2>
movl   $0x1,-0x1c(%rbp)
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe00(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1227 <main+0xf7>
jmp    122c <main+0xfc>
jmp    1231 <main+0x101>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1162 <main+0x32>
cmpl   $0x0,-0x1c(%rbp)
je     1271 <main+0x141>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
lea    0xdd8(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d71(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12d7 <main+0x1a7>
cmpl   $0x0,-0x14(%rbp)
je     1298 <main+0x168>
lea    0xdbc(%rip),%rdi
call   1030 <printf@plt>
mov    0x2d42(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12d7 <main+0x1a7>
lea    0xdf4(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x18(%rbp)
je     12bf <main+0x18f>
lea    0xdf4(%rip),%rdi
call   1030 <printf@plt>
jmp    12cb <main+0x19b>
lea    0xdeb(%rip),%rdi
call   1030 <printf@plt>
mov    0x2cfe(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jle    120b <main+0xcb>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x1,%r12d
lea    0xe9a(%rip),%r14
movl   $0x0,0x4(%rsp)
xor    %r13d,%r13d
xor    %r15d,%r15d
jmp    1193 <main+0x53>
cs nopw 0x0(%rax,%rax,1)
mov    $0x1,%r13d
add    $0x1,%r12
cmp    %r12,%rbp
je     122c <main+0xec>
mov    (%rbx,%r12,8),%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1200 <main+0xc0>
mov    (%rbx,%r12,8),%rdi
lea    0xe58(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1180 <main+0x40>
mov    (%rbx,%r12,8),%rdi
lea    0xe46(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1180 <main+0x40>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
mov    (%rbx,%r12,8),%rdx
lea    0xe39(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
movl   $0x1,0x4(%rsp)
jmp    1186 <main+0x46>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x1,%r15d
jmp    1186 <main+0x46>
lea    0xe2c(%rip),%rdi
call   1040 <printf@plt>
lea    0xe36(%rip),%rdi
call   1030 <puts@plt>
mov    0x2da6(%rip),%rax
jmp    1251 <main+0x111>
cmpl   $0x0,0x4(%rsp)
je     1262 <main+0x122>
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
lea    0xdee(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2d87(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
test   %r15d,%r15d
je     1270 <main+0x130>
lea    0xe09(%rip),%rdi
jmp    121e <main+0xde>
lea    0xdc7(%rip),%rdi
call   1040 <printf@plt>
test   %r13d,%r13d
je     1217 <main+0xd7>
lea    0xde8(%rip),%rdi
jmp    121e <main+0xde>

LLVM IR (-O0):
@.str = [7 x i8] c"--help\00"
@.str.1 = [3 x i8] c"-i\00"
@.str.2 = [17 x i8] c"--serve-icecream\00"
@stderr = global i32 0
@.str.3 = [22 x i8] c"Unknown switch: '%s'\0A\00"
@.str.4 = [13 x i8] c"Aborting...\0A\00"
@EXIT_FAILURE = global i32 0
@.str.5 = [85 x i8] c"Usage: ./icecream OPTIONS...\0A -i, --serve-icecream Not as exciting as it sounds\0A\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.6 = [22 x i8] c"Do you get icecream? \00"
@.str.7 = [8 x i8] c"YES!!!\0A\00"
@.str.8 = [29 x i8] c"Sorry, try again next-time.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 1, i32* %9
br label %10
10: ; preds = %52, %2
%11 = load i32, i32* %9
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %55
14: ; preds = %10
%15 = load i8**, i8*** %5
%16 = load i32, i32* %9
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %14
store i32 1, i32* %6
br label %51
23: ; preds = %14
%24 = load i8**, i8*** %5
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %23
store i32 1, i32* %7
br label %50
32: ; preds = %23
%33 = load i8**, i8*** %5
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %32
store i32 1, i32* %7
br label %49
41: ; preds = %32
store i32 1, i32* %8
%42 = load i32, i32* @stderr
%43 = load i8**, i8*** %5
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %43, i64 %45
%47 = load i8*, i8** %46
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %47)
br label %49
49: ; preds = %41, %40
br label %50
50: ; preds = %49, %31
br label %51
51: ; preds = %50, %22
br label %52
52: ; preds = %51
%53 = load i32, i32* %9
%54 = add nsw i32 %53, 1
store i32 %54, i32* %9
br label %10
55: ; preds = %10
%56 = load i32, i32* %8
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %62
58: ; preds = %55
%59 = load i32, i32* @stderr
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%61 = load i32, i32* @EXIT_FAILURE
store i32 %61, i32* %3
br label %78
62: ; preds = %55
%63 = load i32, i32* %6
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %68
65: ; preds = %62
%66 = call i32 @printf(i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str.5, i64 0, i64 0))
%67 = load i32, i32* @EXIT_SUCCESS
store i32 %67, i32* %3
br label %78
68: ; preds = %62
%69 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%70 = load i32, i32* %7
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %68
%73 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
br label %76
74: ; preds = %68
%75 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
br label %76
76: ; preds = %74, %72
%77 = load i32, i32* @EXIT_SUCCESS
store i32 %77, i32* %3
br label %78
78: ; preds = %76, %65, %58
%79 = load i32, i32* %3
ret i32 %79
}

LLVM IR (-O2):
@.str = [7 x i8] c"--help\00"
@.str.1 = [3 x i8] c"-i\00"
@.str.2 = [17 x i8] c"--serve-icecream\00"
@stderr = global i32 0
@.str.3 = [22 x i8] c"Unknown switch: '%s'\0A\00"
@.str.4 = [13 x i8] c"Aborting...\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@.str.6 = [22 x i8] c"Do you get icecream? \00"
@str = [28 x i8] c"Sorry, try again next-time.\00"
@str.9 = [7 x i8] c"YES!!!\00"
@str.10 = [84 x i8] c"Usage: ./icecream OPTIONS...\0A -i, --serve-icecream Not as exciting as it sounds\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %49
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %29
%9 = phi i64 [ 1, %6 ], [ %33, %29 ]
%10 = phi i32 [ 0, %6 ], [ %32, %29 ]
%11 = phi i32 [ 0, %6 ], [ %31, %29 ]
%12 = phi i32 [ 0, %6 ], [ %30, %29 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %9
%14 = load i8*, i8** %13
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %29, label %17
17: ; preds = %8
%18 = load i8*, i8** %13
%19 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %29, label %21
21: ; preds = %17
%22 = load i8*, i8** %13
%23 = tail call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %13
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %27)
br label %29
29: ; preds = %21, %17, %8, %25
%30 = phi i32 [ %12, %25 ], [ 1, %8 ], [ %12, %17 ], [ %12, %21 ]
%31 = phi i32 [ %11, %25 ], [ %11, %8 ], [ 1, %17 ], [ 1, %21 ]
%32 = phi i32 [ 1, %25 ], [ %10, %8 ], [ %10, %17 ], [ %10, %21 ]
%33 = add nuw nsw i64 %9, 1
%34 = icmp eq i64 %33, %7
br i1 %34, label %35, label %8
35: ; preds = %29
%36 = icmp eq i32 %32, 0
br i1 %36, label %40, label %37
37: ; preds = %35
%38 = load i32, i32* @stderr
%39 = tail call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %51
40: ; preds = %35
%41 = icmp eq i32 %30, 0
br i1 %41, label %44, label %42
42: ; preds = %40
%43 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([84 x i8], [84 x i8]* @str.10, i64 0, i64 0))
br label %51
44: ; preds = %40
%45 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%46 = icmp eq i32 %31, 0
br i1 %46, label %49, label %47
47: ; preds = %44
%48 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.9, i64 0, i64 0))
br label %51
49: ; preds = %4, %44
%50 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %51
51: ; preds = %47, %49, %42, %37
%52 = phi i32* [ @EXIT_FAILURE, %37 ], [ @EXIT_SUCCESS, %42 ], [ @EXIT_SUCCESS, %49 ], [ @EXIT_SUCCESS, %47 ]
%53 = load i32, i32* %52
ret i32 %53
}