#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 EOF;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
unsigned int ftell(int /*<<< orphan*/ *);
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ printf(char *, unsigned char);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
int strtoul(int /*<<< orphan*/, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int c;
  FILE *f;
  char filename[256];
  int help = 0;
  int offset = 0;
  filename[0] = 0;
  while ((c = getopt(argc, argv, "hf:o:")) != EOF) {
    switch (c) {
    case 'h':
      help = 1;
      break;
    case 'o':
      offset = strtoul(optarg, NULL, 0);
    case 'f':
      strcpy(filename, optarg);
      break;
    }
  }
  if (filename[0] == '\0' || help) {
    fprintf(stderr, "Options:\n");
    fprintf(stderr, " -f inputFile\n");
    fprintf(stderr, " -o offset\n");
    return help ? 0 : 1;
  }
  f = fopen(filename, "rb");
  if (f) {
    int i, w, s;
    unsigned int size;
    unsigned int words;
    unsigned char buf;
    unsigned char data;
    fseek(f, 0, SEEK_END);
    size = ftell(f);
    rewind(f);
    fseek(f, offset, SEEK_SET);
    for (i = 0; i < size + 1; i += 4) {
      fread(&buf, 1, 1, f);
      data = buf;
      printf("%x\n", data);
      fread(&buf, 1, 1, f);
      fread(&buf, 1, 1, f);
      fread(&buf, 1, 1, f);
    }
    fclose(f);
    return 0;
  } else {
    fprintf(stderr, "Could not open file %s\n", filename);
    return 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x124(%rbp)
movl   $0x0,-0x128(%rbp)
movb   $0x0,-0x120(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe0e(%rip),%rdx
call   10c0 <getopt@plt>
mov    %eax,-0x14(%rbp)
mov    0x2dd7(%rip),%rcx
cmp    (%rcx),%eax
je     128b <main+0xdb>
mov    -0x14(%rbp),%eax
mov    %eax,-0x144(%rbp)
sub    $0x66,%eax
je     1271 <main+0xc1>
jmp    1220 <main+0x70>
mov    -0x144(%rbp),%eax
sub    $0x68,%eax
je     1248 <main+0x98>
jmp    1234 <main+0x84>
mov    -0x144(%rbp),%eax
sub    $0x6f,%eax
je     1257 <main+0xa7>
jmp    1286 <main+0xd6>
movl   $0x1,-0x124(%rbp)
jmp    1286 <main+0xd6>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10d0 <strtoul@plt>
mov    %eax,-0x128(%rbp)
lea    -0x120(%rbp),%rdi
mov    0x2d79(%rip),%rax
mov    (%rax),%esi
call   1030 <strcpy@plt>
jmp    11e4 <main+0x34>
movsbl -0x120(%rbp),%eax
cmp    $0x0,%eax
je     12a8 <main+0xf8>
cmpl   $0x0,-0x124(%rbp)
je     1308 <main+0x158>
mov    0x2d19(%rip),%rax
mov    (%rax),%edi
lea    0xd4e(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2d02(%rip),%rax
mov    (%rax),%edi
lea    0xd41(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2ceb(%rip),%rax
mov    (%rax),%edi
lea    0xd39(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x124(%rbp),%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1458 <main+0x2a8>
lea    -0x120(%rbp),%rdi
lea    0xd15(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1433 <main+0x283>
mov    -0x20(%rbp),%rdi
mov    0x2cab(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1090 <ftell@plt>
mov    %eax,-0x138(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <rewind@plt>
mov    -0x20(%rbp),%rdi
mov    -0x128(%rbp),%esi
mov    0x2c59(%rip),%rax
mov    (%rax),%edx
call   10a0 <fseek@plt>
movl   $0x0,-0x12c(%rbp)
mov    -0x12c(%rbp),%eax
mov    -0x138(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jae    141e <main+0x26e>
mov    -0x20(%rbp),%rcx
lea    -0x13d(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <fread@plt>
mov    -0x13d(%rbp),%al
mov    %al,-0x13e(%rbp)
lea    0xc75(%rip),%rdi
movzbl -0x13e(%rbp),%esi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rcx
lea    -0x13d(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <fread@plt>
mov    -0x20(%rbp),%rcx
lea    -0x13d(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <fread@plt>
mov    -0x20(%rbp),%rcx
lea    -0x13d(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <fread@plt>
mov    -0x12c(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x12c(%rbp)
jmp    1378 <main+0x1c8>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    1458 <main+0x2a8>
mov    0x2b8e(%rip),%rax
mov    (%rax),%edi
lea    -0x120(%rbp),%rdx
lea    0xbe8(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movb   $0x0,0x10(%rsp)
lea    0xe2e(%rip),%rdx
call   10c0 <getopt@plt>
mov    0x2dfa(%rip),%r14
xor    %r13d,%r13d
mov    $0x0,%r15d
cmp    (%r14),%eax
jne    123d <main+0x8d>
mov    0x2dd5(%rip),%rbx
mov    (%rbx),%edi
lea    0xe0a(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe04(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe03(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
xor    $0x1,%r15b
movzbl %r15b,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2db4(%rip),%r15
lea    0xdb5(%rip),%r12
movl   $0x0,0xc(%rsp)
jmp    128f <main+0xdf>
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15),%edi
xor    %esi,%esi
xor    %edx,%edx
call   10d0 <strtoul@plt>
mov    %eax,0xc(%rsp)
mov    (%r15),%esi
lea    0x10(%rsp),%rdi
call   1030 <strcpy@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   10c0 <getopt@plt>
cmp    (%r14),%eax
je     12a6 <main+0xf6>
cmp    $0x66,%eax
je     1270 <main+0xc0>
cmp    $0x6f,%eax
je     1260 <main+0xb0>
cmp    $0x68,%eax
jne    127d <main+0xcd>
mov    $0x1,%r13d
jmp    127d <main+0xcd>
test   %r13d,%r13d
setne  %r15b
cmpb   $0x0,0x10(%rsp)
je     11ec <main+0x3c>
test   %r13d,%r13d
jne    11ec <main+0x3c>
lea    0xd63(%rip),%rsi
lea    0x10(%rsp),%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13a8 <main+0x1f8>
mov    %rax,%rbx
mov    0x2cfb(%rip),%rax
mov    (%rax),%edx
xor    %ebp,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    %rbx,%rdi
call   1090 <ftell@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1070 <rewind@plt>
mov    0x2cb3(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    0xc(%rsp),%esi
call   10a0 <fseek@plt>
inc    %r15d
je     1399 <main+0x1e9>
lea    0xb(%rsp),%r12
lea    0xd02(%rip),%r14
nopl   0x0(%rax)
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
movzbl 0xb(%rsp),%esi
mov    %r14,%rdi
call   1060 <printf@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
add    $0x4,%ebp
cmp    %r15d,%ebp
jb     1330 <main+0x180>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    122b <main+0x7b>
mov    0x2c19(%rip),%rax
mov    (%rax),%edi
lea    0xc7a(%rip),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%eax
jmp    122b <main+0x7b>

LLVM IR (-O0):
@.str = [6 x i8] c"hf:o:\00"
@EOF = global i32 0
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [10 x i8] c"Options:\0A\00"
@.str.2 = [15 x i8] c" -f inputFile\0A\00"
@.str.3 = [12 x i8] c" -o offset\0A\00"
@.str.4 = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.5 = [4 x i8] c"%x\0A\00"
@.str.6 = [24 x i8] c"Could not open file %s\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 [256 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8
%17 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
store i32 0, i32* %10
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
store i8 0, i8* %18
br label %19
19: ; preds = %35, %2
%20 = load i32, i32* %4
%21 = load i8**, i8*** %5
%22 = call i32 @getopt(i32 %20, i8** %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %22, i32* %6
%23 = load i32, i32* @EOF
%24 = icmp ne i32 %22, %23
br i1 %24, label %25, label %36
25: ; preds = %19
%26 = load i32, i32* %6
switch i32 %26, label %35 [
i32 104, label %27
i32 111, label %28
i32 102, label %31
]
27: ; preds = %25
store i32 1, i32* %9
br label %35
28: ; preds = %25
%29 = load i32, i32* @optarg
%30 = call i32 @strtoul(i32 %29, i32* null, i32 0)
store i32 %30, i32* %10
br label %31
31: ; preds = %25, %28
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%33 = load i32, i32* @optarg
%34 = call i32 @strcpy(i8* %32, i32 %33)
br label %35
35: ; preds = %25, %31, %27
br label %19
36: ; preds = %19
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 0
br i1 %40, label %44, label %41
41: ; preds = %36
%42 = load i32, i32* %9
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %55
44: ; preds = %41, %36
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%49 = load i32, i32* @stderr
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%51 = load i32, i32* %9
%52 = icmp ne i32 %51, 0
%53 = zext i1 %52 to i64
%54 = select i1 %52, i32 0, i32 1
store i32 %54, i32* %3
br label %99
55: ; preds = %41
%56 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%57 = call i32* @fopen(i8* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %57, i32** %7
%58 = load i32*, i32** %7
%59 = icmp ne i32* %58, null
br i1 %59, label %60, label %95
60: ; preds = %55
%61 = load i32*, i32** %7
%62 = load i32, i32* @SEEK_END
%63 = call i32 @fseek(i32* %61, i32 0, i32 %62)
%64 = load i32*, i32** %7
%65 = call i32 @ftell(i32* %64)
store i32 %65, i32* %14
%66 = load i32*, i32** %7
%67 = call i32 @rewind(i32* %66)
%68 = load i32*, i32** %7
%69 = load i32, i32* %10
%70 = load i32, i32* @SEEK_SET
%71 = call i32 @fseek(i32* %68, i32 %69, i32 %70)
store i32 0, i32* %11
br label %72
72: ; preds = %89, %60
%73 = load i32, i32* %11
%74 = load i32, i32* %14
%75 = add i32 %74, 1
%76 = icmp ult i32 %73, %75
br i1 %76, label %77, label %92
77: ; preds = %72
%78 = load i32*, i32** %7
%79 = call i32 @fread(i8* %16, i32 1, i32 1, i32* %78)
%80 = load i8, i8* %16
store i8 %80, i8* %17
%81 = load i8, i8* %17
%82 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8 zeroext %81)
%83 = load i32*, i32** %7
%84 = call i32 @fread(i8* %16, i32 1, i32 1, i32* %83)
%85 = load i32*, i32** %7
%86 = call i32 @fread(i8* %16, i32 1, i32 1, i32* %85)
%87 = load i32*, i32** %7
%88 = call i32 @fread(i8* %16, i32 1, i32 1, i32* %87)
br label %89
89: ; preds = %77
%90 = load i32, i32* %11
%91 = add nsw i32 %90, 4
store i32 %91, i32* %11
br label %72
92: ; preds = %72
%93 = load i32*, i32** %7
%94 = call i32 @fclose(i32* %93)
store i32 0, i32* %3
br label %99
95: ; preds = %55
%96 = load i32, i32* @stderr
%97 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%98 = call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %97)
store i32 1, i32* %3
br label %99
99: ; preds = %95, %92, %44
%100 = load i32, i32* %3
ret i32 %100
}

LLVM IR (-O2):
@.str = [6 x i8] c"hf:o:\00"
@EOF = global i32 0
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [10 x i8] c"Options:\0A\00"
@.str.2 = [15 x i8] c" -f inputFile\0A\00"
@.str.3 = [12 x i8] c" -o offset\0A\00"
@.str.4 = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.5 = [4 x i8] c"%x\0A\00"
@.str.6 = [24 x i8] c"Could not open file %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [256 x i8]
%4 = alloca i8
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
store i8 0, i8* %5
%6 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %32, label %9
9: ; preds = %2, %21
%10 = phi i32 [ %24, %21 ], [ %6, %2 ]
%11 = phi i32 [ %23, %21 ], [ 0, %2 ]
%12 = phi i32 [ %22, %21 ], [ 0, %2 ]
switch i32 %10, label %21 [
i32 104, label %13
i32 111, label %14
i32 102, label %17
]
13: ; preds = %9
br label %21
14: ; preds = %9
%15 = load i32, i32* @optarg
%16 = call i32 @strtoul(i32 %15, i32* null, i32 0)
br label %17
17: ; preds = %9, %14
%18 = phi i32 [ %12, %9 ], [ %16, %14 ]
%19 = load i32, i32* @optarg
%20 = call i32 @strcpy(i8* %5, i32 %19)
br label %21
21: ; preds = %9, %17, %13
%22 = phi i32 [ %12, %9 ], [ %18, %17 ], [ %12, %13 ]
%23 = phi i32 [ %11, %9 ], [ %11, %17 ], [ 1, %13 ]
%24 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%25 = load i32, i32* @EOF
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %9
27: ; preds = %21
%28 = load i8, i8* %5
%29 = icmp eq i8 %28, 0
%30 = icmp ne i32 %23, 0
%31 = select i1 %29, i1 true, i1 %30
br i1 %31, label %32, label %42
32: ; preds = %2, %27
%33 = phi i1 [ %30, %27 ], [ false, %2 ]
%34 = load i32, i32* @stderr
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%36 = load i32, i32* @stderr
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%38 = load i32, i32* @stderr
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%40 = xor i1 %33, true
%41 = zext i1 %40 to i32
br label %69
42: ; preds = %27
%43 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%44 = icmp eq i32* %43, null
br i1 %44, label %66, label %45
45: ; preds = %42
%46 = load i32, i32* @SEEK_END
%47 = call i32 @fseek(i32* %43, i32 0, i32 %46)
%48 = call i32 @ftell(i32* %43)
%49 = call i32 @rewind(i32* %43)
%50 = load i32, i32* @SEEK_SET
%51 = call i32 @fseek(i32* %43, i32 %22, i32 %50)
%52 = add i32 %48, 1
%53 = icmp eq i32 %52, 0
br i1 %53, label %64, label %54
54: ; preds = %45, %54
%55 = phi i32 [ %62, %54 ], [ 0, %45 ]
%56 = call i32 @fread(i8* %4, i32 1, i32 1, i32* %43)
%57 = load i8, i8* %4
%58 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8 zeroext %57)
%59 = call i32 @fread(i8* %4, i32 1, i32 1, i32* %43)
%60 = call i32 @fread(i8* %4, i32 1, i32 1, i32* %43)
%61 = call i32 @fread(i8* %4, i32 1, i32 1, i32* %43)
%62 = add nuw nsw i32 %55, 4
%63 = icmp ult i32 %62, %52
br i1 %63, label %54, label %64
64: ; preds = %54, %45
%65 = call i32 @fclose(i32* %43)
br label %69
66: ; preds = %42
%67 = load i32, i32* @stderr
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %5)
br label %69
69: ; preds = %66, %64, %32
%70 = phi i32 [ %41, %32 ], [ 0, %64 ], [ 1, %66 ]
ret i32 %70
}