#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 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*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  unsigned char x[4];
  int i, n;
  FILE *f;
  if (argc < 3)
    return 1;
  if (!(f = fopen(argv[1], "rb")))
    return 1;
  n = atoi(argv[2]) / 4;
  printf("DEPTH = %d;\n", n);
  printf("WIDTH = 32;\n");
  printf("ADDRESS_RADIX = HEX;\n");
  printf("DATA_RADIX = HEX;\n");
  printf("CONTENT\n");
  printf("BEGIN\n");
  for (i = 0; !feof(f); ++i) {
    fread(x, 1, 4, f);
    printf("%x : %02X%02X%02X%02X;\n", i, x[0], x[1], x[2], x[3]);
  }
  for (; i < n; ++i) {
    printf("%x : %02X%02X%02X%02X;\n", i, 0, 0, 0, 0);
  }
  printf("END;\n");
  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    118c <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    12f0 <main+0x190>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe65(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11ba <main+0x5a>
movl   $0x1,-0x4(%rbp)
jmp    12f0 <main+0x190>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <atoi@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    124e <main+0xee>
jmp    1296 <main+0x136>
lea    -0x14(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
mov    -0x18(%rbp),%esi
movzbl -0x14(%rbp),%edx
movzbl -0x13(%rbp),%ecx
movzbl -0x12(%rbp),%r8d
movzbl -0x11(%rbp),%r9d
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1230 <main+0xd0>
jmp    129b <main+0x13b>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12d2 <main+0x172>
mov    -0x18(%rbp),%esi
lea    0xda5(%rip),%rdi
xor    %r9d,%r9d
mov    %r9d,%edx
mov    %r9d,%ecx
mov    %r9d,%r8d
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    129b <main+0x13b>
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%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   %r12
push   %rbx
sub    $0x10,%rsp
mov    $0x1,%ebp
cmp    $0x3,%edi
jl     12c4 <main+0x154>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xe68(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12c4 <main+0x154>
mov    %rax,%rbx
mov    0x10(%r14),%rdi
call   1090 <atoi@plt>
lea    0x3(%rax),%r14d
test   %eax,%eax
cmovns %eax,%r14d
sar    $0x2,%r14d
lea    0xe3c(%rip),%rdi
xor    %ebp,%ebp
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe4e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe57(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe59(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    1276 <main+0x106>
lea    0xc(%rsp),%r15
lea    0xde9(%rip),%r12
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
movzbl 0xc(%rsp),%edx
movzbl 0xd(%rsp),%ecx
movzbl 0xe(%rsp),%r8d
movzbl 0xf(%rsp),%r9d
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%ebp
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     1230 <main+0xc0>
cmp    %r14d,%ebp
jge    12ae <main+0x13e>
lea    0xd8e(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %ebp,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%r14d
jne    1290 <main+0x120>
lea    0xdb4(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [13 x i8] c"DEPTH = %d;\0A\00"
@.str.2 = [13 x i8] c"WIDTH = 32;\0A\00"
@.str.3 = [22 x i8] c"ADDRESS_RADIX = HEX;\0A\00"
@.str.4 = [19 x i8] c"DATA_RADIX = HEX;\0A\00"
@.str.5 = [9 x i8] c"CONTENT\0A\00"
@.str.6 = [7 x i8] c"BEGIN\0A\00"
@.str.7 = [24 x i8] c"%x : %02X%02X%02X%02X;\0A\00"
@.str.8 = [6 x i8] c"END;\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 1, i32* %3
br label %74
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %9
%18 = icmp ne i32* %17, null
br i1 %18, label %20, label %19
19: ; preds = %13
store i32 1, i32* %3
br label %74
20: ; preds = %13
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
%25 = sdiv i32 %24, 4
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %7
br label %33
33: ; preds = %56, %20
%34 = load i32*, i32** %9
%35 = call i32 @feof(i32* %34)
%36 = icmp ne i32 %35, 0
%37 = xor i1 %36, true
br i1 %37, label %38, label %59
38: ; preds = %33
%39 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%40 = load i32*, i32** %9
%41 = call i32 @fread(i8* %39, i32 1, i32 4, i32* %40)
%42 = load i32, i32* %7
%43 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 1
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 2
%50 = load i8, i8* %49
%51 = zext i8 %50 to i32
%52 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 3
%53 = load i8, i8* %52
%54 = zext i8 %53 to i32
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 %42, i32 %45, i32 %48, i32 %51, i32 %54)
br label %56
56: ; preds = %38
%57 = load i32, i32* %7
%58 = add nsw i32 %57, 1
store i32 %58, i32* %7
br label %33
59: ; preds = %33
br label %60
60: ; preds = %67, %59
%61 = load i32, i32* %7
%62 = load i32, i32* %8
%63 = icmp slt i32 %61, %62
br i1 %63, label %64, label %70
64: ; preds = %60
%65 = load i32, i32* %7
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 %65, i32 0, i32 0, i32 0, i32 0)
br label %67
67: ; preds = %64
%68 = load i32, i32* %7
%69 = add nsw i32 %68, 1
store i32 %69, i32* %7
br label %60
70: ; preds = %60
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%72 = load i32*, i32** %9
%73 = call i32 @fclose(i32* %72)
store i32 0, i32* %3
br label %74
74: ; preds = %70, %19, %12
%75 = load i32, i32* %3
ret i32 %75
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [13 x i8] c"DEPTH = %d;\0A\00"
@.str.7 = [24 x i8] c"%x : %02X%02X%02X%02X;\0A\00"
@str = [12 x i8] c"WIDTH = 32;\00"
@str.9 = [21 x i8] c"ADDRESS_RADIX = HEX;\00"
@str.10 = [18 x i8] c"DATA_RADIX = HEX;\00"
@str.11 = [8 x i8] c"CONTENT\00"
@str.12 = [6 x i8] c"BEGIN\00"
@str.13 = [5 x i8] c"END;\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4 x i8]
%4 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 3
br i1 %5, label %54, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %54, label %11
11: ; preds = %6
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = sdiv i32 %14, 4
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.9, i64 0, i64 0))
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.11, i64 0, i64 0))
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.12, i64 0, i64 0))
%22 = tail call i32 @feof(i32* %9)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %11
%25 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
%26 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
%27 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 3
br label %31
28: ; preds = %31, %11
%29 = phi i32 [ 0, %11 ], [ %43, %31 ]
%30 = icmp slt i32 %29, %15
br i1 %30, label %46, label %51
31: ; preds = %24, %31
%32 = phi i32 [ 0, %24 ], [ %43, %31 ]
%33 = call i32 @fread(i8* %4, i32 1, i32 4, i32* %9)
%34 = load i8, i8* %4
%35 = zext i8 %34 to i32
%36 = load i8, i8* %25
%37 = zext i8 %36 to i32
%38 = load i8, i8* %26
%39 = zext i8 %38 to i32
%40 = load i8, i8* %27
%41 = zext i8 %40 to i32
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 %32, i32 %35, i32 %37, i32 %39, i32 %41)
%43 = add nuw nsw i32 %32, 1
%44 = tail call i32 @feof(i32* %9)
%45 = icmp eq i32 %44, 0
br i1 %45, label %31, label %28
46: ; preds = %28, %46
%47 = phi i32 [ %49, %46 ], [ %29, %28 ]
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 %47, i32 0, i32 0, i32 0, i32 0)
%49 = add i32 %47, 1
%50 = icmp eq i32 %49, %15
br i1 %50, label %51, label %46
51: ; preds = %46, %28
%52 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.13, i64 0, i64 0))
%53 = tail call i32 @fclose(i32* %9)
br label %54
54: ; preds = %6, %2, %51
%55 = phi i32 [ 0, %51 ], [ 1, %2 ], [ 1, %6 ]
ret i32 %55
}