#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getopt(int, char **, char *);
char *optarg;
int /*<<< orphan*/ sscanf(char *, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage(char *);
int /*<<< orphan*/ writeS19(char *, int, int);
int main(int argc, char **argv) {
  char *optstr = "f:s:h?n:";
  int startAddr, max;
  char *fileName;
  fileName = NULL;
  startAddr = 0;
  max = 32;
  while (1) {
    int result = getopt(argc, argv, optstr);
    if (result == -1)
      break;
    switch (result) {
    case 'f':
      fileName = optarg;
      break;
    case 'n':
      sscanf(optarg, "%d", &max);
      break;
    case 's':
      sscanf(optarg, "%x", (unsigned int *)&startAddr);
      break;
    case '?':
    case 'h':
      usage(argv[0]);
      exit(0);
    }
  }
  if (fileName == NULL) {
    fprintf(stderr, "Please specify a filename with -f<filename>\n");
    usage(argv[0]);
    exit(1);
  }
  writeS19(fileName, startAddr, max);
  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)
lea    0xe83(%rip),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x20,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    11b9 <main+0x59>
jmp    127e <main+0x11e>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
sub    $0x3f,%eax
je     1266 <main+0x106>
jmp    11cd <main+0x6d>
mov    -0x30(%rbp),%eax
sub    $0x66,%eax
je     1211 <main+0xb1>
jmp    11de <main+0x7e>
mov    -0x30(%rbp),%eax
sub    $0x68,%eax
je     1266 <main+0x106>
jmp    11ef <main+0x8f>
mov    -0x30(%rbp),%eax
sub    $0x6e,%eax
je     1224 <main+0xc4>
jmp    1200 <main+0xa0>
mov    -0x30(%rbp),%eax
sub    $0x73,%eax
je     1245 <main+0xe5>
jmp    1279 <main+0x119>
mov    0x2de0(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1279 <main+0x119>
mov    0x2dcd(%rip),%rax
mov    (%rax),%rdi
lea    0xdd4(%rip),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1050 <sscanf@plt>
jmp    1279 <main+0x119>
mov    0x2dac(%rip),%rax
mov    (%rax),%rdi
lea    0xdb6(%rip),%rsi
lea    -0x1c(%rbp),%rdx
mov    $0x0,%al
call   1050 <sscanf@plt>
jmp    1279 <main+0x119>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <usage@plt>
xor    %edi,%edi
call   1080 <exit@plt>
jmp    1197 <main+0x37>
cmpq   $0x0,-0x28(%rbp)
jne    12b4 <main+0x154>
mov    0x2d48(%rip),%rax
mov    (%rax),%edi
lea    0xd76(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <usage@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1030 <writeS19@plt>
xor    %eax,%eax
add    $0x30,%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    %rsi,%rbx
mov    %edi,%ebp
movl   $0x0,0xc(%rsp)
movl   $0x20,0x8(%rsp)
lea    0xeae(%rip),%r15
lea    0xe6f(%rip),%r13
mov    0x2e60(%rip),%r14
lea    0xc(%rsp),%r12
xor    %eax,%eax
jmp    11b3 <main+0x53>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14),%rax
mov    %rax,0x10(%rsp)
jmp    11d6 <main+0x76>
nopw   0x0(%rax,%rax,1)
mov    (%r14),%rdi
lea    0xe77(%rip),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1050 <sscanf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1070 <getopt@plt>
lea    -0x66(%rax),%ecx
cmp    $0xd,%ecx
ja     1204 <main+0xa4>
movslq 0x0(%r13,%rcx,4),%rax
add    %r13,%rax
jmp    *%rax
mov    (%r14),%rdi
lea    0xe45(%rip),%rsi
mov    %r12,%rdx
jmp    11cf <main+0x6f>
cmp    $0xffffffff,%eax
je     121d <main+0xbd>
cmp    $0x3f,%eax
jne    11d6 <main+0x76>
mov    (%rbx),%rdi
call   1060 <usage@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    0x10(%rsp),%rdi
test   %rdi,%rdi
je     1245 <main+0xe5>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
call   1030 <writeS19@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d8c(%rip),%rax
mov    (%rax),%edi
lea    0xdf2(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%rdi
call   1060 <usage@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"f:s:h?n:\00"
@optarg = global i8* null
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%x\00"
@stderr = global i32 0
@.str.3 = [45 x i8] c"Please specify a filename with -f<filename>\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %6
store i8* null, i8** %9
store i32 0, i32* %7
store i32 32, i32* %8
br label %11
11: ; preds = %2, %35
%12 = load i32, i32* %4
%13 = load i8**, i8*** %5
%14 = load i8*, i8** %6
%15 = call i32 @getopt(i32 %12, i8** %13, i8* %14)
store i32 %15, i32* %10
%16 = load i32, i32* %10
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %19
18: ; preds = %11
br label %36
19: ; preds = %11
%20 = load i32, i32* %10
switch i32 %20, label %35 [
i32 102, label %21
i32 110, label %23
i32 115, label %26
i32 63, label %29
i32 104, label %29
]
21: ; preds = %19
%22 = load i8*, i8** @optarg
store i8* %22, i8** %9
br label %35
23: ; preds = %19
%24 = load i8*, i8** @optarg
%25 = call i32 (i8*, i8*, ...) @sscanf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
br label %35
26: ; preds = %19
%27 = load i8*, i8** @optarg
%28 = call i32 (i8*, i8*, ...) @sscanf(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
br label %35
29: ; preds = %19, %19
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 0
%32 = load i8*, i8** %31
%33 = call i32 @usage(i8* %32)
%34 = call i32 @exit(i32 0)
unreachable
35: ; preds = %19, %26, %23, %21
br label %11
36: ; preds = %18
%37 = load i8*, i8** %9
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %47
39: ; preds = %36
%40 = load i32, i32* @stderr
%41 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 0
%44 = load i8*, i8** %43
%45 = call i32 @usage(i8* %44)
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %36
%48 = load i8*, i8** %9
%49 = load i32, i32* %7
%50 = load i32, i32* %8
%51 = call i32 @writeS19(i8* %48, i32 %49, i32 %50)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"f:s:h?n:\00"
@optarg = global i8* null
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%x\00"
@stderr = global i32 0
@.str.3 = [45 x i8] c"Please specify a filename with -f<filename>\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %3
store i32 32, i32* %4
br label %7
7: ; preds = %11, %2
%8 = phi i8* [ %12, %11 ], [ null, %2 ]
br label %9
9: ; preds = %16, %7
%10 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
switch i32 %10, label %16 [
i32 -1, label %24
i32 102, label %11
i32 110, label %13
i32 115, label %17
i32 63, label %20
i32 104, label %20
]
11: ; preds = %9
%12 = load i8*, i8** @optarg
br label %7
13: ; preds = %9
%14 = load i8*, i8** @optarg
%15 = call i32 (i8*, i8*, ...) @sscanf(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
br label %16
16: ; preds = %13, %17, %9
br label %9
17: ; preds = %9
%18 = load i8*, i8** @optarg
%19 = call i32 (i8*, i8*, ...) @sscanf(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
br label %16
20: ; preds = %9, %9
%21 = load i8*, i8** %1
%22 = call i32 @usage(i8* %21)
%23 = call i32 @exit(i32 0)
unreachable
24: ; preds = %9
%25 = icmp eq i8* %8, null
br i1 %25, label %26, label %32
26: ; preds = %24
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
%29 = load i8*, i8** %1
%30 = call i32 @usage(i8* %29)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %24
%33 = load i32, i32* %3
%34 = load i32, i32* %4
%35 = call i32 @writeS19(i8* %8, i32 %33, i32 %34)
ret i32 0
}