#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 /*<<< orphan*/ SEEK_SET;
int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, unsigned char, unsigned char,
                          unsigned char, unsigned char);
int main(int argc, char *argv[]) {
  if (argc < 3)
    return -1;
  FILE *f = fopen(argv[1], "rb");
  if (!f)
    return -1;
  unsigned char x[4];
  int i = 0;
  int n = atoi(argv[2]);
  int base = 0;
  int file_pos = 0;
  if (argc >= 5) {
    file_pos = atoi(argv[3]);
    base = atoi(argv[4]);
  }
  fseek(f, file_pos, SEEK_SET);
  while (!feof(f) && (n == 0 || (i < n))) {
    fread(x, 1, 4, f);
    printf("@%x %02X%02X%02X%02X\n", (base + i) * 0x4, x[3], x[2], x[1], x[0]);
    i++;
  }
  for (; i < n;) {
    printf("@%x %02X%02X%02X%02X\n", (base + i) * 0x4, 0, 0, 0, 0);
    i++;
  }
  fclose(f);
  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   $0x3,-0x8(%rbp)
jge    119c <main+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    131b <main+0x1ab>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe55(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11cb <main+0x5b>
movl   $0xffffffff,-0x4(%rbp)
jmp    131b <main+0x1ab>
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x5,-0x8(%rbp)
jl     121a <main+0xaa>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    0x2db8(%rip),%rax
mov    (%rax),%edx
call   1070 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1060 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x2d(%rbp)
jne    1269 <main+0xf9>
mov    $0x1,%al
cmpl   $0x0,-0x24(%rbp)
mov    %al,-0x2e(%rbp)
je     1263 <main+0xf3>
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
setl   %al
mov    %al,-0x2e(%rbp)
mov    -0x2e(%rbp),%al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
test   $0x1,%al
jne    1279 <main+0x109>
jmp    12cb <main+0x15b>
lea    -0x1c(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
mov    -0x28(%rbp),%esi
add    -0x20(%rbp),%esi
shl    $0x2,%esi
mov    -0x19(%rbp),%dl
mov    -0x1a(%rbp),%cl
mov    -0x1b(%rbp),%al
lea    0xd5a(%rip),%rdi
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl %al,%r8d
movzbl -0x1c(%rbp),%r9d
call   1050 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    122f <main+0xbf>
jmp    12d0 <main+0x160>
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    130b <main+0x19b>
mov    -0x28(%rbp),%esi
add    -0x20(%rbp),%esi
shl    $0x2,%esi
lea    0xd17(%rip),%rdi
xor    %r9d,%r9d
mov    %r9d,%edx
mov    %r9d,%ecx
mov    %r9d,%r8d
call   1050 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12d0 <main+0x160>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xffffffff,%ebx
cmp    $0x3,%edi
jl     12b6 <main+0x146>
mov    %rsi,%r15
mov    %edi,%r12d
mov    0x8(%rsi),%rdi
lea    0xe66(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12b6 <main+0x146>
mov    %rax,%r14
mov    0x10(%r15),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebp
xor    %r13d,%r13d
mov    $0x0,%ebx
mov    $0x0,%esi
cmp    $0x5,%r12d
jb     11e1 <main+0x71>
mov    0x18(%r15),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebx
mov    0x20(%r15),%rdi
call   1090 <atoi@plt>
mov    %ebx,%esi
mov    %eax,%ebx
mov    0x2df8(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
call   1070 <fseek@plt>
mov    %r14,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    1275 <main+0x105>
lea    0x0(,%rbx,4),%r15d
xor    %r13d,%r13d
lea    0xdf3(%rip),%r12
jmp    126c <main+0xfc>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0x4(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
movzbl 0x7(%rsp),%edx
movzbl 0x6(%rsp),%ecx
movzbl 0x5(%rsp),%r8d
movzbl 0x4(%rsp),%r9d
mov    %r12,%rdi
mov    %r15d,%esi
call   1050 <printf@plt>
add    $0x1,%r13d
mov    %r14,%rdi
call   1060 <feof@plt>
add    $0x4,%r15d
test   %eax,%eax
jne    1275 <main+0x105>
test   %ebp,%ebp
je     1220 <main+0xb0>
cmp    %ebp,%r13d
jl     1220 <main+0xb0>
cmp    %ebp,%r13d
jge    12ac <main+0x13c>
sub    %r13d,%ebp
add    %r13d,%ebx
shl    $0x2,%ebx
lea    0xd79(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebx,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1050 <printf@plt>
add    $0x4,%ebx
add    $0xffffffff,%ebp
jne    1290 <main+0x120>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@SEEK_SET = global i32 0
@.str.1 = [22 x i8] c"@%x %02X%02X%02X%02X\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [4 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 -1, i32* %3
br label %94
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %19, i32** %6
%20 = load i32*, i32** %6
%21 = icmp ne i32* %20, null
br i1 %21, label %23, label %22
22: ; preds = %15
store i32 -1, i32* %3
br label %94
23: ; preds = %15
store i32 0, i32* %8
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
%28 = load i32, i32* %4
%29 = icmp sge i32 %28, 5
br i1 %29, label %30, label %39
30: ; preds = %23
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 3
%33 = load i8*, i8** %32
%34 = call i32 @atoi(i8* %33)
store i32 %34, i32* %11
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 4
%37 = load i8*, i8** %36
%38 = call i32 @atoi(i8* %37)
store i32 %38, i32* %10
br label %39
39: ; preds = %30, %23
%40 = load i32*, i32** %6
%41 = load i32, i32* %11
%42 = load i32, i32* @SEEK_SET
%43 = call i32 @fseek(i32* %40, i32 %41, i32 %42)
br label %44
44: ; preds = %59, %39
%45 = load i32*, i32** %6
%46 = call i32 @feof(i32* %45)
%47 = icmp ne i32 %46, 0
br i1 %47, label %57, label %48
48: ; preds = %44
%49 = load i32, i32* %9
%50 = icmp eq i32 %49, 0
br i1 %50, label %55, label %51
51: ; preds = %48
%52 = load i32, i32* %8
%53 = load i32, i32* %9
%54 = icmp slt i32 %52, %53
br label %55
55: ; preds = %51, %48
%56 = phi i1 [ true, %48 ], [ %54, %51 ]
br label %57
57: ; preds = %55, %44
%58 = phi i1 [ false, %44 ], [ %56, %55 ]
br i1 %58, label %59, label %78
59: ; preds = %57
%60 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%61 = load i32*, i32** %6
%62 = call i32 @fread(i8* %60, i32 1, i32 4, i32* %61)
%63 = load i32, i32* %10
%64 = load i32, i32* %8
%65 = add nsw i32 %63, %64
%66 = mul nsw i32 %65, 4
%67 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 3
%68 = load i8, i8* %67
%69 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 2
%70 = load i8, i8* %69
%71 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 1
%72 = load i8, i8* %71
%73 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%74 = load i8, i8* %73
%75 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %66, i8 zeroext %68, i8 zeroext %70, i8 zeroext %72, i8 zeroext %74)
%76 = load i32, i32* %8
%77 = add nsw i32 %76, 1
store i32 %77, i32* %8
br label %44
78: ; preds = %57
br label %79
79: ; preds = %83, %78
%80 = load i32, i32* %8
%81 = load i32, i32* %9
%82 = icmp slt i32 %80, %81
br i1 %82, label %83, label %91
83: ; preds = %79
%84 = load i32, i32* %10
%85 = load i32, i32* %8
%86 = add nsw i32 %84, %85
%87 = mul nsw i32 %86, 4
%88 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %87, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0)
%89 = load i32, i32* %8
%90 = add nsw i32 %89, 1
store i32 %90, i32* %8
br label %79
91: ; preds = %79
%92 = load i32*, i32** %6
%93 = call i32 @fclose(i32* %92)
store i32 0, i32* %3
br label %94
94: ; preds = %91, %22, %14
%95 = load i32, i32* %3
ret i32 %95
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@SEEK_SET = global i32 0
@.str.1 = [22 x i8] c"@%x %02X%02X%02X%02X\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4 x i8]
%4 = icmp slt i32 %0, 3
br i1 %4, label %63, label %5
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32* @fopen(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %63, label %10
10: ; preds = %5
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = icmp ugt i32 %0, 4
br i1 %15, label %16, label %23
16: ; preds = %10
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
%20 = getelementptr inbounds i8*, i8** %1, i64 4
%21 = load i8*, i8** %20
%22 = tail call i32 @atoi(i8* %21)
br label %23
23: ; preds = %16, %10
%24 = phi i32 [ %22, %16 ], [ 0, %10 ]
%25 = phi i32 [ %19, %16 ], [ 0, %10 ]
%26 = load i32, i32* @SEEK_SET
%27 = tail call i32 @fseek(i32* %8, i32 %25, i32 %26)
%28 = tail call i32 @feof(i32* %8)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %51
30: ; preds = %23
%31 = icmp eq i32 %14, 0
%32 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 3
%33 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
%34 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
br label %35
35: ; preds = %30, %39
%36 = phi i32 [ 0, %30 ], [ %48, %39 ]
%37 = icmp slt i32 %36, %14
%38 = select i1 %31, i1 true, i1 %37
br i1 %38, label %39, label %51
39: ; preds = %35
%40 = call i32 @fread(i8* %11, i32 1, i32 4, i32* %8)
%41 = add nsw i32 %36, %24
%42 = shl nsw i32 %41, 2
%43 = load i8, i8* %32
%44 = load i8, i8* %33
%45 = load i8, i8* %34
%46 = load i8, i8* %11
%47 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %42, i8 zeroext %43, i8 zeroext %44, i8 zeroext %45, i8 zeroext %46)
%48 = add nuw nsw i32 %36, 1
%49 = tail call i32 @feof(i32* %8)
%50 = icmp eq i32 %49, 0
br i1 %50, label %35, label %51
51: ; preds = %35, %39, %23
%52 = phi i32 [ 0, %23 ], [ %48, %39 ], [ %36, %35 ]
%53 = icmp slt i32 %52, %14
br i1 %53, label %54, label %61
54: ; preds = %51, %54
%55 = phi i32 [ %59, %54 ], [ %52, %51 ]
%56 = add nsw i32 %55, %24
%57 = shl nsw i32 %56, 2
%58 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %57, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0)
%59 = add i32 %55, 1
%60 = icmp eq i32 %59, %14
br i1 %60, label %61, label %54
61: ; preds = %54, %51
%62 = tail call i32 @fclose(i32* %8)
br label %63
63: ; preds = %61, %5, %2
%64 = phi i32 [ -1, %2 ], [ 0, %61 ], [ -1, %5 ]
ret i32 %64
}