#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 UINT_MAX;
int atoi(char *);
int /*<<< orphan*/ printUsage(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
scalar_t__ strlen(char *);
int main(int argc, char *argv[]) {
  if (argc < 5) {
    printUsage(argv[0]);
  }
  unsigned int x = 0;
  if (strcmp(argv[1], "-i") == 0) {
    int temp = atoi(argv[2]);
    if (temp > UINT_MAX || temp < 0) {
      printf("error: integer (%d) must be between %u and %u\n\n", temp, 0,
             UINT_MAX);
      printUsage(argv[0]);
    }
    x = (unsigned int)temp;
  } else {
    printf("error: -i expected\n");
    printUsage(argv[0]);
  }
  char *string;
  if (strcmp(argv[3], "-s") == 0) {
    string = argv[4];
  } else {
    printf("error: -s expected\n");
    printUsage(argv[0]);
  }
  printf("Your integer: %u\n", x);
  printf("Your string: %s (%d chars)\n", string, (int)strlen(string));
  int i;
  int len = (int)strlen(string);
  for (i = 0; i < len; i++) {
    printf("%d: %c\n", i, string[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    117c <main+0x2c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <printUsage@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6e(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1200 <main+0xb0>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e2d(%rip),%rcx
cmp    (%rcx),%eax
jg     11cd <main+0x7d>
cmpl   $0x0,-0x18(%rbp)
jge    11f5 <main+0xa5>
mov    -0x18(%rbp),%esi
mov    0x2e11(%rip),%rax
mov    (%rax),%ecx
lea    0xe23(%rip),%rdi
xor    %edx,%edx
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <printUsage@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    121a <main+0xca>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <printUsage@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe1e(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1249 <main+0xf9>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1263 <main+0x113>
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <printUsage@plt>
mov    -0x14(%rbp),%esi
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    12e3 <main+0x193>
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12ac <main+0x15c>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x4,%edi
jg     1177 <main+0x17>
mov    (%rbx),%rdi
call   1070 <printUsage@plt>
mov    0x8(%rbx),%rdi
lea    0xe7e(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     119c <main+0x3c>
lea    0xed9(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
jmp    11ca <main+0x6a>
mov    0x10(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebp
mov    0x2e3a(%rip),%rax
mov    (%rax),%ecx
test   %ebp,%ebp
js     11b8 <main+0x58>
cmp    %ecx,%ebp
jle    11d2 <main+0x72>
lea    0xe44(%rip),%rdi
mov    %ebp,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%rdi
call   1070 <printUsage@plt>
mov    0x18(%rbx),%rdi
lea    0xe56(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11fd <main+0x9d>
lea    0xe91(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%rdi
call   1070 <printUsage@plt>
jmp    1201 <main+0xa1>
mov    0x20(%rbx),%r15
lea    0xe2e(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
lea    0xe28(%rip),%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    126a <main+0x10a>
mov    %eax,%ebx
lea    0xe23(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%r15,%rbp,1),%edx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1250 <main+0xf0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-i\00"
@UINT_MAX = global i32 0
@.str.1 = [48 x i8] c"error: integer (%d) must be between %u and %u\0A\0A\00"
@.str.2 = [20 x i8] c"error: -i expected\0A\00"
@.str.3 = [3 x i8] c"-s\00"
@.str.4 = [20 x i8] c"error: -s expected\0A\00"
@.str.5 = [18 x i8] c"Your integer: %u\0A\00"
@.str.6 = [28 x i8] c"Your string: %s (%d chars)\0A\00"
@.str.7 = [8 x i8] c"%d: %c\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 i8*
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 5
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @printUsage(i8* %16)
br label %18
18: ; preds = %13, %2
store i32 0, i32* %6
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %45
24: ; preds = %18
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %7
%29 = load i32, i32* %7
%30 = load i32, i32* @UINT_MAX
%31 = icmp sgt i32 %29, %30
br i1 %31, label %35, label %32
32: ; preds = %24
%33 = load i32, i32* %7
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %43
35: ; preds = %32, %24
%36 = load i32, i32* %7
%37 = load i32, i32* @UINT_MAX
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 %36, i32 0, i32 %37)
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 0
%41 = load i8*, i8** %40
%42 = call i32 @printUsage(i8* %41)
br label %43
43: ; preds = %35, %32
%44 = load i32, i32* %7
store i32 %44, i32* %6
br label %51
45: ; preds = %18
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 0
%49 = load i8*, i8** %48
%50 = call i32 @printUsage(i8* %49)
br label %51
51: ; preds = %45, %43
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 3
%54 = load i8*, i8** %53
%55 = call i64 @strcmp(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %61
57: ; preds = %51
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 4
%60 = load i8*, i8** %59
store i8* %60, i8** %8
br label %67
61: ; preds = %51
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 0
%65 = load i8*, i8** %64
%66 = call i32 @printUsage(i8* %65)
br label %67
67: ; preds = %61, %57
%68 = load i32, i32* %6
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %68)
%70 = load i8*, i8** %8
%71 = load i8*, i8** %8
%72 = call i64 @strlen(i8* %71)
%73 = trunc i64 %72 to i32
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %70, i32 %73)
%75 = load i8*, i8** %8
%76 = call i64 @strlen(i8* %75)
%77 = trunc i64 %76 to i32
store i32 %77, i32* %10
store i32 0, i32* %9
br label %78
78: ; preds = %91, %67
%79 = load i32, i32* %9
%80 = load i32, i32* %10
%81 = icmp slt i32 %79, %80
br i1 %81, label %82, label %94
82: ; preds = %78
%83 = load i32, i32* %9
%84 = load i8*, i8** %8
%85 = load i32, i32* %9
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8, i8* %84, i64 %86
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 %83, i32 %89)
br label %91
91: ; preds = %82
%92 = load i32, i32* %9
%93 = add nsw i32 %92, 1
store i32 %93, i32* %9
br label %78
94: ; preds = %78
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"-i\00"
@UINT_MAX = global i32 0
@.str.1 = [48 x i8] c"error: integer (%d) must be between %u and %u\0A\0A\00"
@.str.3 = [3 x i8] c"-s\00"
@.str.5 = [18 x i8] c"Your integer: %u\0A\00"
@.str.6 = [28 x i8] c"Your string: %s (%d chars)\0A\00"
@.str.7 = [8 x i8] c"%d: %c\0A\00"
@str = [19 x i8] c"error: -i expected\00"
@str.8 = [19 x i8] c"error: -s expected\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 5
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printUsage(i8* %5)
br label %7
7: ; preds = %4, %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %7
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = load i32, i32* @UINT_MAX
%17 = icmp sgt i32 %15, %16
%18 = icmp slt i32 %15, 0
%19 = or i1 %18, %17
br i1 %19, label %20, label %28
20: ; preds = %12
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 0, i32 %16)
br label %24
22: ; preds = %7
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %24
24: ; preds = %22, %20
%25 = phi i32 [ %15, %20 ], [ 0, %22 ]
%26 = load i8*, i8** %1
%27 = tail call i32 @printUsage(i8* %26)
br label %28
28: ; preds = %24, %12
%29 = phi i32 [ %15, %12 ], [ %25, %24 ]
%30 = getelementptr inbounds i8*, i8** %1, i64 3
%31 = load i8*, i8** %30
%32 = tail call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %28
%35 = getelementptr inbounds i8*, i8** %1, i64 4
%36 = load i8*, i8** %35
br label %41
37: ; preds = %28
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.8, i64 0, i64 0))
%39 = load i8*, i8** %1
%40 = tail call i32 @printUsage(i8* %39)
br label %41
41: ; preds = %37, %34
%42 = phi i8* [ %36, %34 ], [ undef, %37 ]
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %29)
%44 = tail call i64 @strlen(i8* dereferenceable(1) %42)
%45 = trunc i64 %44 to i32
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %42, i32 %45)
%47 = tail call i64 @strlen(i8* dereferenceable(1) %42)
%48 = trunc i64 %47 to i32
%49 = icmp sgt i32 %48, 0
br i1 %49, label %50, label %61
50: ; preds = %41
%51 = and i64 %47, 4294967295
br label %52
52: ; preds = %50, %52
%53 = phi i64 [ 0, %50 ], [ %59, %52 ]
%54 = getelementptr inbounds i8, i8* %42, i64 %53
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = trunc i64 %53 to i32
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 %57, i32 %56)
%59 = add nuw nsw i64 %53, 1
%60 = icmp eq i64 %59, %51
br i1 %60, label %61, label %52
61: ; preds = %52, %41
ret i32 0
}