#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int FindOption(char *, int, int, int, int, char **);
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SH2Disasm(unsigned int, unsigned char *, long, char *);
int /*<<< orphan*/ ShowHelp();
scalar_t__ calloc(long, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fread(char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  FILE *fp;
  long fsize, file, mode;
  unsigned start, len, calc_len = 0, org, do_org, i, j = 0;
  char *buffer;
  char *mark;
  if (argc == 1)
    ShowHelp();
  if (FindOption("-?", 0, 0, 0, argc, argv) ||
      FindOption("-h", 0, 0, 0, argc, argv))
    ShowHelp();
  if (FindOption("-sh1", 0, 0, 0, argc, argv))
    mode = 1;
  else
    mode = 0;
  if (FindOption("-sh2", 0, 0, 0, argc, argv))
    mode = 0;
  start = FindOption("-s", 1, 1, 0, argc, argv);
  org = FindOption("-o", 1, 1, 0, argc, argv);
  if (!(len = FindOption("-l", 1, 0, 0, argc, argv))) {
    if (FindOption("-l", 0, 0, 0, argc, argv))
      return 0;
    calc_len = 1;
  }
  if (FindOption("-o", 0, 0, 0, argc, argv))
    do_org = 1;
  else
    do_org = 0;
  if (!(file = FindOption(NULL, 0, 0, 1, argc, argv))) {
    fprintf(stderr, "sh2d: No input file specified. Try "
                    "\"sh2d -h\" for usage instructions\n");
    exit(1);
  }
  if ((fp = fopen(argv[file], "rb")) == NULL) {
    fprintf(stderr, "sh2d: Failed to open file: %s\n", argv[file]);
    exit(1);
  }
  fseek(fp, 0, SEEK_END);
  fsize = ftell(fp);
  rewind(fp);
  if ((buffer = (char *)calloc(fsize * 2, sizeof(unsigned short))) == NULL) {
    fprintf(stderr,
            "sh2d: Not enough memory to load input "
            "file: %s, %lu bytes\n",
            argv[file], fsize);
    exit(1);
  }
  fread(buffer, sizeof(unsigned char), fsize, fp);
  fclose(fp);
  if (calc_len)
    len = fsize - start;
  mark = buffer + fsize;
  for (i = start; i < (unsigned)fsize && j < len; i += 2) {
    if (do_org) {
      SH2Disasm(org, (unsigned char *)&buffer[i], mode, &mark[i]);
      org += 2;
    } else
      SH2Disasm(i, (unsigned char *)&buffer[i], mode, &mark[i]);
    j += 2;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x4c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11f5 <main+0x35>
mov    $0x0,%al
call   1050 <ShowHelp@plt>
mov    -0x8(%rbp),%r8d
mov    -0x10(%rbp),%r9
lea    0xdfc(%rip),%rdi
xor    %ecx,%ecx
mov    %ecx,%esi
mov    %ecx,%edx
call   1070 <FindOption@plt>
cmp    $0x0,%eax
jne    123b <main+0x7b>
mov    -0x8(%rbp),%r8d
mov    -0x10(%rbp),%r9
lea    0xddc(%rip),%rdi
xor    %ecx,%ecx
mov    %ecx,%esi
mov    %ecx,%edx
call   1070 <FindOption@plt>
cmp    $0x0,%eax
je     1242 <main+0x82>
mov    $0x0,%al
call   1050 <ShowHelp@plt>
mov    -0x8(%rbp),%r8d
mov    -0x10(%rbp),%r9
lea    0xdb5(%rip),%rdi
xor    %ecx,%ecx
mov    %ecx,%esi
mov    %ecx,%edx
call   1070 <FindOption@plt>
cmp    $0x0,%eax
je     1272 <main+0xb2>
movq   $0x1,-0x30(%rbp)
jmp    127a <main+0xba>
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%r8d
mov    -0x10(%rbp),%r9
lea    0xd82(%rip),%rdi
xor    %ecx,%ecx
mov    %ecx,%esi
mov    %ecx,%edx
call   1070 <FindOption@plt>
cmp    $0x0,%eax
je     12a5 <main+0xe5>
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%r8d
mov    -0x10(%rbp),%r9
lea    0xd5c(%rip),%rdi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    %edx,%esi
call   1070 <FindOption@plt>
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%r8d
mov    -0x10(%rbp),%r9
lea    0xd3f(%rip),%rdi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    %edx,%esi
call   1070 <FindOption@plt>
mov    %eax,-0x40(%rbp)
mov    -0x8(%rbp),%r8d
mov    -0x10(%rbp),%r9
lea    0xd22(%rip),%rdi
mov    $0x1,%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1070 <FindOption@plt>
mov    %eax,-0x38(%rbp)
cmp    $0x0,%eax
jne    1344 <main+0x184>
mov    -0x8(%rbp),%r8d
mov    -0x10(%rbp),%r9
lea    0xcf9(%rip),%rdi
xor    %ecx,%ecx
mov    %ecx,%esi
mov    %ecx,%edx
call   1070 <FindOption@plt>
cmp    $0x0,%eax
je     133d <main+0x17d>
movl   $0x0,-0x4(%rbp)
jmp    1583 <main+0x3c3>
movl   $0x1,-0x3c(%rbp)
mov    -0x8(%rbp),%r8d
mov    -0x10(%rbp),%r9
lea    0xcc0(%rip),%rdi
xor    %ecx,%ecx
mov    %ecx,%esi
mov    %ecx,%edx
call   1070 <FindOption@plt>
cmp    $0x0,%eax
je     1373 <main+0x1b3>
movl   $0x1,-0x44(%rbp)
jmp    137a <main+0x1ba>
movl   $0x0,-0x44(%rbp)
mov    -0x8(%rbp),%r8d
mov    -0x10(%rbp),%r9
xor    %eax,%eax
mov    %eax,%edi
xor    %edx,%edx
mov    $0x1,%ecx
mov    %edx,%esi
call   1070 <FindOption@plt>
cltq
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    13c5 <main+0x205>
mov    0x2c2d(%rip),%rax
mov    (%rax),%edi
lea    0xc65(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xc86(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1418 <main+0x258>
mov    0x2be6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xc5a(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    0x2bc5(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   10b0 <ftell@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <rewind@plt>
mov    -0x20(%rbp),%rdi
shl    $0x1,%rdi
mov    $0x2,%esi
call   1080 <calloc@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
jne    1493 <main+0x2d3>
mov    0x2b6f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x20(%rbp),%rcx
lea    0xbfe(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x58(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
cmpl   $0x0,-0x3c(%rbp)
je     14c9 <main+0x309>
mov    -0x20(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    %rcx,%rax
mov    %eax,-0x38(%rbp)
mov    -0x58(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %eax,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x61(%rbp)
jae    14fd <main+0x33d>
mov    -0x4c(%rbp),%eax
cmp    -0x38(%rbp),%eax
setb   %al
mov    %al,-0x61(%rbp)
mov    -0x61(%rbp),%al
test   $0x1,%al
jne    150d <main+0x34d>
jmp    157c <main+0x3bc>
cmpl   $0x0,-0x44(%rbp)
je     1545 <main+0x385>
mov    -0x40(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    -0x48(%rbp),%eax
add    %rax,%rsi
mov    -0x30(%rbp),%rdx
mov    -0x60(%rbp),%rcx
mov    -0x48(%rbp),%eax
add    %rax,%rcx
call   1090 <SH2Disasm@plt>
mov    -0x40(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x40(%rbp)
jmp    1565 <main+0x3a5>
mov    -0x48(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    -0x48(%rbp),%eax
add    %rax,%rsi
mov    -0x30(%rbp),%rdx
mov    -0x60(%rbp),%rcx
mov    -0x48(%rbp),%eax
add    %rax,%rcx
call   1090 <SH2Disasm@plt>
mov    -0x4c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x48(%rbp)
jmp    14db <main+0x31b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r12
mov    %edi,%r15d
cmp    $0x1,%edi
jne    11e0 <main+0x20>
xor    %eax,%eax
call   1050 <ShowHelp@plt>
lea    0xe19(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r15d,%r8d
mov    %r12,%r9
call   1070 <FindOption@plt>
test   %eax,%eax
jne    1218 <main+0x58>
lea    0xe00(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r15d,%r8d
mov    %r12,%r9
call   1070 <FindOption@plt>
test   %eax,%eax
je     121f <main+0x5f>
xor    %eax,%eax
call   1050 <ShowHelp@plt>
lea    0xde0(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r15d,%r8d
mov    %r12,%r9
call   1070 <FindOption@plt>
test   %eax,%eax
setne  0x18(%rsp)
lea    0xdc6(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r15d,%r8d
mov    %r12,%r9
call   1070 <FindOption@plt>
test   %eax,%eax
sete   0xf(%rsp)
lea    0xdac(%rip),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    %r15d,%r8d
mov    %r12,%r9
call   1070 <FindOption@plt>
mov    %eax,%ebp
lea    0xd8f(%rip),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    %r15d,%r8d
mov    %r12,%r9
call   1070 <FindOption@plt>
mov    %eax,0x14(%rsp)
lea    0xd70(%rip),%rdi
mov    $0x1,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r15d,%r8d
mov    %r12,%r9
call   1070 <FindOption@plt>
mov    %eax,%ebx
test   %eax,%eax
je     1433 <main+0x273>
lea    0xd48(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r15d,%r8d
mov    %r12,%r9
call   1070 <FindOption@plt>
mov    %eax,0x24(%rsp)
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
mov    $0x1,%ecx
mov    %r15d,%r8d
mov    %r12,%r9
call   1070 <FindOption@plt>
test   %eax,%eax
je     1464 <main+0x2a4>
mov    %ebx,0x10(%rsp)
movslq %eax,%r13
mov    (%r12,%r13,8),%rdi
lea    0xd4e(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1485 <main+0x2c5>
mov    %rax,%rbx
mov    0x2cc0(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    %rbx,%rdi
call   10b0 <ftell@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1060 <rewind@plt>
lea    (%r14,%r14,1),%rdi
mov    $0x2,%esi
call   1080 <calloc@plt>
test   %rax,%rax
je     14aa <main+0x2ea>
mov    %rax,%r15
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14d,%eax
sub    %ebp,%eax
mov    0x10(%rsp),%r13d
test   %r13d,%r13d
cmovne %r13d,%eax
mov    %eax,0x10(%rsp)
cmp    %ebp,%r14d
jbe    1453 <main+0x293>
cmpl   $0x0,0x10(%rsp)
je     1453 <main+0x293>
mov    %r14,%rbx
mov    %r15,%r12
mov    0xf(%rsp),%al
and    0x18(%rsp),%al
movzbl %al,%eax
mov    %rax,0x18(%rsp)
mov    %r14,%r15
add    %r12,%r15
mov    $0x2,%r13d
nopw   0x0(%rax,%rax,1)
lea    -0x2(%rbp,%r13,1),%edi
lea    (%r12,%rdi,1),%rsi
lea    (%r15,%rdi,1),%rcx
cmpl   $0x0,0x24(%rsp)
je     1410 <main+0x250>
mov    0x14(%rsp),%r14d
mov    %r14d,%edi
mov    0x18(%rsp),%rdx
call   1090 <SH2Disasm@plt>
add    $0x2,%r14d
mov    %r14d,0x14(%rsp)
jmp    141a <main+0x25a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x18(%rsp),%rdx
call   1090 <SH2Disasm@plt>
lea    0x0(%rbp,%r13,1),%eax
cmp    %ebx,%eax
jae    1453 <main+0x293>
lea    0x2(%r13),%eax
cmp    0x10(%rsp),%r13d
mov    %eax,%r13d
jb     13d0 <main+0x210>
jmp    1453 <main+0x293>
lea    0xbdc(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r15d,%r8d
mov    %r12,%r9
call   1070 <FindOption@plt>
test   %eax,%eax
je     12c4 <main+0x104>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b6d(%rip),%rax
mov    (%rax),%edi
lea    0xba5(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    0x2b4c(%rip),%rax
mov    (%rax),%edi
mov    (%r12,%r13,8),%rdx
lea    0xbc8(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    0x2b27(%rip),%rax
mov    (%rax),%edi
mov    (%r12,%r13,8),%rdx
lea    0xbc2(%rip),%rsi
mov    %r14,%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-?\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [5 x i8] c"-sh1\00"
@.str.3 = [5 x i8] c"-sh2\00"
@.str.4 = [3 x i8] c"-s\00"
@.str.5 = [3 x i8] c"-o\00"
@.str.6 = [3 x i8] c"-l\00"
@stderr = global i32 0
@.str.7 = [69 x i8] c"sh2d: No input file specified. Try \22sh2d -h\22 for usage instructions\0A\00"
@.str.8 = [3 x i8] c"rb\00"
@.str.9 = [31 x i8] c"sh2d: Failed to open file: %s\0A\00"
@SEEK_END = global i32 0
@.str.10 = [59 x i8] c"sh2d: Not enough memory to load input file: %s, %lu bytes\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i8*
%18 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %12
store i32 0, i32* %16
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %23
21: ; preds = %2
%22 = call i32 (...) @ShowHelp()
br label %23
23: ; preds = %21, %2
%24 = load i32, i32* %4
%25 = load i8**, i8*** %5
%26 = call i32 @FindOption(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 0, i32 0, i32 0, i32 %24, i8** %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %33, label %28
28: ; preds = %23
%29 = load i32, i32* %4
%30 = load i8**, i8*** %5
%31 = call i32 @FindOption(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 0, i32 0, i32 %29, i8** %30)
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %28, %23
%34 = call i32 (...) @ShowHelp()
br label %35
35: ; preds = %33, %28
%36 = load i32, i32* %4
%37 = load i8**, i8*** %5
%38 = call i32 @FindOption(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 0, i32 0, i32 %36, i8** %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %35
store i64 1, i64* %9
br label %42
41: ; preds = %35
store i64 0, i64* %9
br label %42
42: ; preds = %41, %40
%43 = load i32, i32* %4
%44 = load i8**, i8*** %5
%45 = call i32 @FindOption(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 0, i32 0, i32 %43, i8** %44)
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %42
store i64 0, i64* %9
br label %48
48: ; preds = %47, %42
%49 = load i32, i32* %4
%50 = load i8**, i8*** %5
%51 = call i32 @FindOption(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 1, i32 0, i32 %49, i8** %50)
store i32 %51, i32* %10
%52 = load i32, i32* %4
%53 = load i8**, i8*** %5
%54 = call i32 @FindOption(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 1, i32 1, i32 0, i32 %52, i8** %53)
store i32 %54, i32* %13
%55 = load i32, i32* %4
%56 = load i8**, i8*** %5
%57 = call i32 @FindOption(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 1, i32 0, i32 0, i32 %55, i8** %56)
store i32 %57, i32* %11
%58 = icmp ne i32 %57, 0
br i1 %58, label %66, label %59
59: ; preds = %48
%60 = load i32, i32* %4
%61 = load i8**, i8*** %5
%62 = call i32 @FindOption(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 0, i32 0, i32 0, i32 %60, i8** %61)
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %65
64: ; preds = %59
store i32 0, i32* %3
br label %187
65: ; preds = %59
store i32 1, i32* %12
br label %66
66: ; preds = %65, %48
%67 = load i32, i32* %4
%68 = load i8**, i8*** %5
%69 = call i32 @FindOption(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 0, i32 0, i32 0, i32 %67, i8** %68)
%70 = icmp ne i32 %69, 0
br i1 %70, label %71, label %72
71: ; preds = %66
store i32 1, i32* %14
br label %73
72: ; preds = %66
store i32 0, i32* %14
br label %73
73: ; preds = %72, %71
%74 = load i32, i32* %4
%75 = load i8**, i8*** %5
%76 = call i32 @FindOption(i8* null, i32 0, i32 0, i32 1, i32 %74, i8** %75)
%77 = sext i32 %76 to i64
store i64 %77, i64* %8
%78 = icmp ne i64 %77, 0
br i1 %78, label %83, label %79
79: ; preds = %73
%80 = load i32, i32* @stderr
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.7, i64 0, i64 0))
%82 = call i32 @exit(i32 1)
unreachable
83: ; preds = %73
%84 = load i8**, i8*** %5
%85 = load i64, i64* %8
%86 = getelementptr inbounds i8*, i8** %84, i64 %85
%87 = load i8*, i8** %86
%88 = call i32* @fopen(i8* %87, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
store i32* %88, i32** %6
%89 = icmp eq i32* %88, null
br i1 %89, label %90, label %98
90: ; preds = %83
%91 = load i32, i32* @stderr
%92 = load i8**, i8*** %5
%93 = load i64, i64* %8
%94 = getelementptr inbounds i8*, i8** %92, i64 %93
%95 = load i8*, i8** %94
%96 = call i32 (i32, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i8* %95)
%97 = call i32 @exit(i32 1)
unreachable
98: ; preds = %83
%99 = load i32*, i32** %6
%100 = load i32, i32* @SEEK_END
%101 = call i32 @fseek(i32* %99, i32 0, i32 %100)
%102 = load i32*, i32** %6
%103 = call i64 @ftell(i32* %102)
store i64 %103, i64* %7
%104 = load i32*, i32** %6
%105 = call i32 @rewind(i32* %104)
%106 = load i64, i64* %7
%107 = mul nsw i64 %106, 2
%108 = call i64 @calloc(i64 %107, i32 2)
%109 = inttoptr i64 %108 to i8*
store i8* %109, i8** %17
%110 = icmp eq i8* %109, null
br i1 %110, label %111, label %120
111: ; preds = %98
%112 = load i32, i32* @stderr
%113 = load i8**, i8*** %5
%114 = load i64, i64* %8
%115 = getelementptr inbounds i8*, i8** %113, i64 %114
%116 = load i8*, i8** %115
%117 = load i64, i64* %7
%118 = call i32 (i32, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.10, i64 0, i64 0), i8* %116, i64 %117)
%119 = call i32 @exit(i32 1)
unreachable
120: ; preds = %98
%121 = load i8*, i8** %17
%122 = load i64, i64* %7
%123 = load i32*, i32** %6
%124 = call i32 @fread(i8* %121, i32 1, i64 %122, i32* %123)
%125 = load i32*, i32** %6
%126 = call i32 @fclose(i32* %125)
%127 = load i32, i32* %12
%128 = icmp ne i32 %127, 0
br i1 %128, label %129, label %135
129: ; preds = %120
%130 = load i64, i64* %7
%131 = load i32, i32* %10
%132 = zext i32 %131 to i64
%133 = sub nsw i64 %130, %132
%134 = trunc i64 %133 to i32
store i32 %134, i32* %11
br label %135
135: ; preds = %129, %120
%136 = load i8*, i8** %17
%137 = load i64, i64* %7
%138 = getelementptr inbounds i8, i8* %136, i64 %137
store i8* %138, i8** %18
%139 = load i32, i32* %10
store i32 %139, i32* %15
br label %140
140: ; preds = %183, %135
%141 = load i32, i32* %15
%142 = load i64, i64* %7
%143 = trunc i64 %142 to i32
%144 = icmp ult i32 %141, %143
br i1 %144, label %145, label %149
145: ; preds = %140
%146 = load i32, i32* %16
%147 = load i32, i32* %11
%148 = icmp ult i32 %146, %147
br label %149
149: ; preds = %145, %140
%150 = phi i1 [ false, %140 ], [ %148, %145 ]
br i1 %150, label %151, label %186
151: ; preds = %149
%152 = load i32, i32* %14
%153 = icmp ne i32 %152, 0
br i1 %153, label %154, label %168
154: ; preds = %151
%155 = load i32, i32* %13
%156 = load i8*, i8** %17
%157 = load i32, i32* %15
%158 = zext i32 %157 to i64
%159 = getelementptr inbounds i8, i8* %156, i64 %158
%160 = load i64, i64* %9
%161 = load i8*, i8** %18
%162 = load i32, i32* %15
%163 = zext i32 %162 to i64
%164 = getelementptr inbounds i8, i8* %161, i64 %163
%165 = call i32 @SH2Disasm(i32 %155, i8* %159, i64 %160, i8* %164)
%166 = load i32, i32* %13
%167 = add i32 %166, 2
store i32 %167, i32* %13
br label %180
168: ; preds = %151
%169 = load i32, i32* %15
%170 = load i8*, i8** %17
%171 = load i32, i32* %15
%172 = zext i32 %171 to i64
%173 = getelementptr inbounds i8, i8* %170, i64 %172
%174 = load i64, i64* %9
%175 = load i8*, i8** %18
%176 = load i32, i32* %15
%177 = zext i32 %176 to i64
%178 = getelementptr inbounds i8, i8* %175, i64 %177
%179 = call i32 @SH2Disasm(i32 %169, i8* %173, i64 %174, i8* %178)
br label %180
180: ; preds = %168, %154
%181 = load i32, i32* %16
%182 = add i32 %181, 2
store i32 %182, i32* %16
br label %183
183: ; preds = %180
%184 = load i32, i32* %15
%185 = add i32 %184, 2
store i32 %185, i32* %15
br label %140
186: ; preds = %149
store i32 0, i32* %3
br label %187
187: ; preds = %186, %64
%188 = load i32, i32* %3
ret i32 %188
}

LLVM IR (-O2):
@.str = [3 x i8] c"-?\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [5 x i8] c"-sh1\00"
@.str.3 = [5 x i8] c"-sh2\00"
@.str.4 = [3 x i8] c"-s\00"
@.str.5 = [3 x i8] c"-o\00"
@.str.6 = [3 x i8] c"-l\00"
@stderr = global i32 0
@.str.7 = [69 x i8] c"sh2d: No input file specified. Try \22sh2d -h\22 for usage instructions\0A\00"
@.str.8 = [3 x i8] c"rb\00"
@.str.9 = [31 x i8] c"sh2d: Failed to open file: %s\0A\00"
@SEEK_END = global i32 0
@.str.10 = [59 x i8] c"sh2d: Not enough memory to load input file: %s, %lu bytes\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @ShowHelp()
br label %6
6: ; preds = %4, %2
%7 = tail call i32 @FindOption(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 0, i32 0, i32 0, i32 %0, i8** %1)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = tail call i32 @FindOption(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 0, i32 0, i32 %0, i8** %1)
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9, %6
%13 = tail call i32 (...) @ShowHelp()
br label %14
14: ; preds = %12, %9
%15 = tail call i32 @FindOption(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 0, i32 0, i32 %0, i8** %1)
%16 = icmp ne i32 %15, 0
%17 = tail call i32 @FindOption(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 0, i32 0, i32 %0, i8** %1)
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i1 %16, i1 false
%20 = zext i1 %19 to i64
%21 = tail call i32 @FindOption(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 1, i32 0, i32 %0, i8** %1)
%22 = tail call i32 @FindOption(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 1, i32 1, i32 0, i32 %0, i8** %1)
%23 = tail call i32 @FindOption(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 1, i32 0, i32 0, i32 %0, i8** %1)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %14
%26 = tail call i32 @FindOption(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 0, i32 0, i32 0, i32 %0, i8** %1)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %91
28: ; preds = %25, %14
%29 = tail call i32 @FindOption(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 0, i32 0, i32 0, i32 %0, i8** %1)
%30 = icmp eq i32 %29, 0
%31 = tail call i32 @FindOption(i8* null, i32 0, i32 0, i32 1, i32 %0, i8** %1)
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %28
%34 = load i32, i32* @stderr
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.7, i64 0, i64 0))
%36 = tail call i32 @exit(i32 1)
unreachable
37: ; preds = %28
%38 = sext i32 %31 to i64
%39 = getelementptr inbounds i8*, i8** %1, i64 %38
%40 = load i8*, i8** %39
%41 = tail call i32* @fopen(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %48
43: ; preds = %37
%44 = load i32, i32* @stderr
%45 = load i8*, i8** %39
%46 = tail call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i8* %45)
%47 = tail call i32 @exit(i32 1)
unreachable
48: ; preds = %37
%49 = load i32, i32* @SEEK_END
%50 = tail call i32 @fseek(i32* %41, i32 0, i32 %49)
%51 = tail call i64 @ftell(i32* %41)
%52 = tail call i32 @rewind(i32* %41)
%53 = shl nsw i64 %51, 1
%54 = tail call i64 @calloc(i64 %53, i32 2)
%55 = inttoptr i64 %54 to i8*
%56 = icmp eq i64 %54, 0
br i1 %56, label %57, label %62
57: ; preds = %48
%58 = load i32, i32* @stderr
%59 = load i8*, i8** %39
%60 = tail call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.10, i64 0, i64 0), i8* %59, i64 %51)
%61 = tail call i32 @exit(i32 1)
unreachable
62: ; preds = %48
%63 = tail call i32 @fread(i8* %55, i32 1, i64 %51, i32* %41)
%64 = tail call i32 @fclose(i32* %41)
%65 = trunc i64 %51 to i32
%66 = sub i32 %65, %21
%67 = select i1 %24, i32 %66, i32 %23
%68 = getelementptr inbounds i8, i8* %55, i64 %51
%69 = icmp ult i32 %21, %65
%70 = icmp ne i32 %67, 0
%71 = select i1 %69, i1 %70, i1 false
br i1 %71, label %72, label %91
72: ; preds = %62, %84
%73 = phi i32 [ %86, %84 ], [ 0, %62 ]
%74 = phi i32 [ %87, %84 ], [ %21, %62 ]
%75 = phi i32 [ %85, %84 ], [ %22, %62 ]
%76 = zext i32 %74 to i64
%77 = getelementptr inbounds i8, i8* %55, i64 %76
%78 = getelementptr inbounds i8, i8* %68, i64 %76
br i1 %30, label %82, label %79
79: ; preds = %72
%80 = tail call i32 @SH2Disasm(i32 %75, i8* %77, i64 %20, i8* %78)
%81 = add i32 %75, 2
br label %84
82: ; preds = %72
%83 = tail call i32 @SH2Disasm(i32 %74, i8* %77, i64 %20, i8* %78)
br label %84
84: ; preds = %82, %79
%85 = phi i32 [ %81, %79 ], [ %75, %82 ]
%86 = add i32 %73, 2
%87 = add i32 %74, 2
%88 = icmp ult i32 %87, %65
%89 = icmp ult i32 %86, %67
%90 = select i1 %88, i1 %89, i1 false
br i1 %90, label %72, label %91
91: ; preds = %84, %62, %25
ret i32 0
}