#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ SEEK_END;
int fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
size_t fread(unsigned char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int fseek(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/);
size_t ftell(int /*<<< orphan*/ *);
unsigned char *malloc(size_t);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *file;
  int ret;
  unsigned char *buf;
  size_t count, i, j;
  if (argc != 2) {
    printf("Usage:\n%s FILENAME\n", argv[0]);
    return EXIT_FAILURE;
  }
  file = fopen(argv[1], "r");
  if (!file) {
    perror("fopen");
    return EXIT_FAILURE;
  }
  ret = fseek(file, 0, SEEK_END);
  if (ret < 0) {
    perror("fseek");
    return EXIT_FAILURE;
  }
  count = ftell(file);
  if (!count) {
    fprintf(stderr, "File %s has length 0\n", argv[1]);
    return EXIT_FAILURE;
  }
  rewind(file);
  buf = malloc(count);
  if (!buf) {
    perror("calloc");
    return EXIT_FAILURE;
  }
  count = fread(buf, 1, count, file);
  printf("/*\n");
  printf(" *  Non-zero %u byte strings of a disk image\n", 8);
  printf(" *\n");
  printf(" *  Generated with tools/file2include\n");
  printf(" *\n");
  printf(" *  SPDX-License-Identifier:	GPL-2.0+\n");
  printf(" */\n\n");
  printf("#define EFI_ST_DISK_IMG { 0x%08zx, { \\\n", count);
  for (i = 0; i < count; i += 8) {
    int c = 0;
    for (j = i; j < i + 8 && j < count; ++j) {
      if (buf[j])
        c = 1;
    }
    if (!c)
      continue;
    printf("\t{0x%08zx, \"", i);
    for (j = i; j < i + 8 && j < count; ++j)
      printf("\\x%02x", buf[j]);
    printf("\"}, /* ");
    for (j = i; j < i + 8 && j < count; ++j) {
      if (buf[j] >= 0x20 && buf[j] <= 0x7e)
        printf("%c", buf[j]);
      else
        printf(".");
    }
    printf(" */ \\\n");
  }
  printf("\t{0, NULL} } }\n");
  free(buf);
  ret = fclose(file);
  if (ret) {
    perror("fclose");
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11f6 <main+0x46>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15d3 <main+0x423>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe0f(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1236 <main+0x86>
lea    0xdf6(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2da4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15d3 <main+0x423>
mov    -0x18(%rbp),%rdi
mov    0x2da7(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1274 <main+0xc4>
lea    0xdbe(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2d66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15d3 <main+0x423>
mov    -0x18(%rbp),%rdi
call   1090 <ftell@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12ba <main+0x10a>
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd7e(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2d20(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15d3 <main+0x423>
mov    -0x18(%rbp),%rdi
call   1070 <rewind@plt>
mov    -0x30(%rbp),%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12f8 <main+0x148>
lea    0xd56(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2ce2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15d3 <main+0x423>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x30(%rbp)
lea    0xd26(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd1c(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd37(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd2d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd1b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd38(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xd45(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    157d <main+0x3cd>
movl   $0x0,-0x44(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rcx
mov    -0x38(%rbp),%rdx
add    $0x8,%rdx
xor    %eax,%eax
cmp    %rdx,%rcx
mov    %al,-0x45(%rbp)
jae    13d8 <main+0x228>
mov    -0x40(%rbp),%rax
cmp    -0x30(%rbp),%rax
setb   %al
mov    %al,-0x45(%rbp)
mov    -0x45(%rbp),%al
test   $0x1,%al
jne    13e8 <main+0x238>
jmp    1417 <main+0x267>
mov    -0x28(%rbp),%rax
mov    -0x40(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1401 <main+0x251>
movl   $0x1,-0x44(%rbp)
jmp    1406 <main+0x256>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    13b0 <main+0x200>
cmpl   $0x0,-0x44(%rbp)
jne    1426 <main+0x276>
jmp    156c <main+0x3bc>
mov    -0x38(%rbp),%rsi
lea    0xcc0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rcx
mov    -0x38(%rbp),%rdx
add    $0x8,%rdx
xor    %eax,%eax
cmp    %rdx,%rcx
mov    %al,-0x46(%rbp)
jae    1468 <main+0x2b8>
mov    -0x40(%rbp),%rax
cmp    -0x30(%rbp),%rax
setb   %al
mov    %al,-0x46(%rbp)
mov    -0x46(%rbp),%al
test   $0x1,%al
jne    1478 <main+0x2c8>
jmp    14a3 <main+0x2f3>
mov    -0x28(%rbp),%rax
mov    -0x40(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xc73(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1440 <main+0x290>
lea    0xc5b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rcx
mov    -0x38(%rbp),%rdx
add    $0x8,%rdx
xor    %eax,%eax
cmp    %rdx,%rcx
mov    %al,-0x47(%rbp)
jae    14e1 <main+0x331>
mov    -0x40(%rbp),%rax
cmp    -0x30(%rbp),%rax
setb   %al
mov    %al,-0x47(%rbp)
mov    -0x47(%rbp),%al
test   $0x1,%al
jne    14f1 <main+0x341>
jmp    155e <main+0x3ae>
mov    -0x28(%rbp),%rax
mov    -0x40(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jl     153a <main+0x38a>
mov    -0x28(%rbp),%rax
mov    -0x40(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x7e,%eax
jg     153a <main+0x38a>
mov    -0x28(%rbp),%rax
mov    -0x40(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xbdf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1548 <main+0x398>
lea    0xbcf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    154d <main+0x39d>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    14b9 <main+0x309>
lea    0xbad(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x38(%rbp)
jmp    1393 <main+0x1e3>
lea    0xb95(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     15c7 <main+0x417>
lea    0xb78(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2a13(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15d3 <main+0x423>
mov    0x29fa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%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
cmp    $0x2,%edi
jne    14c1 <main+0x2f1>
mov    0x8(%rbx),%rdi
lea    0xe1f(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     151a <main+0x34a>
mov    %rax,%rbp
mov    0x2ddb(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   10d0 <fseek@plt>
test   %eax,%eax
js     1523 <main+0x353>
mov    %rbp,%rdi
call   10b0 <ftell@plt>
test   %rax,%rax
je     14ff <main+0x32f>
mov    %rax,%r14
mov    %rbp,%rdi
call   1090 <rewind@plt>
mov    %r14,%rdi
call   10c0 <malloc@plt>
test   %rax,%rax
je     152c <main+0x35c>
mov    %rax,%r15
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r14,%rdx
mov    %rbp,0x10(%rsp)
mov    %rbp,%rcx
call   1060 <fread@plt>
mov    %rax,%r12
lea    0xe45(%rip),%rdi
call   1050 <puts@plt>
lea    0xdc0(%rip),%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xe4f(%rip),%rbp
mov    %rbp,%rdi
call   1050 <puts@plt>
lea    0xe1a(%rip),%rdi
call   1050 <puts@plt>
mov    %rbp,%rdi
call   1050 <puts@plt>
lea    0xe2f(%rip),%rdi
call   1050 <puts@plt>
lea    0xe49(%rip),%rdi
call   1050 <puts@plt>
lea    0xda0(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
test   %r12,%r12
je     14d4 <main+0x304>
mov    $0x1,%r14d
xor    %r13d,%r13d
jmp    1317 <main+0x147>
lea    0xdb7(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x8(%rsp),%r14
lea    0xe19(%rip),%rdi
call   1050 <puts@plt>
add    $0x8,%r14
cmp    %r12,%r13
jae    14d4 <main+0x304>
mov    %r13,%rbx
add    $0x8,%r13
cmp    $0xfffffffffffffff8,%rbx
je     130a <main+0x13a>
xor    %eax,%eax
cmpb   $0x0,(%r15,%rbx,1)
setne  %al
mov    %rbx,%rcx
or     $0x1,%rcx
cmp    %r13,%rcx
jae    1420 <main+0x250>
cmp    %r12,%rcx
jae    1420 <main+0x250>
cmpb   $0x0,(%r15,%rcx,1)
mov    $0x1,%ecx
cmovne %ecx,%eax
mov    %rbx,%rcx
or     $0x2,%rcx
cmp    %r13,%rcx
jae    1420 <main+0x250>
cmp    %r12,%rcx
jae    1420 <main+0x250>
cmpb   $0x0,(%r15,%rcx,1)
mov    $0x1,%ecx
cmovne %ecx,%eax
mov    %rbx,%rcx
or     $0x3,%rcx
cmp    %r13,%rcx
jae    1420 <main+0x250>
cmp    %r12,%rcx
jae    1420 <main+0x250>
cmpb   $0x0,(%r15,%rcx,1)
mov    $0x1,%ecx
cmovne %ecx,%eax
mov    %rbx,%rcx
or     $0x4,%rcx
cmp    %r13,%rcx
jae    1420 <main+0x250>
cmp    %r12,%rcx
jae    1420 <main+0x250>
cmpb   $0x0,(%r15,%rcx,1)
mov    $0x1,%ecx
cmovne %ecx,%eax
mov    %rbx,%rcx
or     $0x5,%rcx
cmp    %r13,%rcx
jae    1420 <main+0x250>
cmp    %r12,%rcx
jae    1420 <main+0x250>
cmpb   $0x0,(%r15,%rcx,1)
mov    $0x1,%ecx
cmovne %ecx,%eax
mov    %rbx,%rcx
or     $0x6,%rcx
cmp    %r13,%rcx
jae    1420 <main+0x250>
cmp    %r12,%rcx
jae    1420 <main+0x250>
cmpb   $0x0,(%r15,%rcx,1)
mov    $0x1,%ecx
cmovne %ecx,%eax
mov    %rbx,%rcx
or     $0x7,%rcx
cmp    %r13,%rcx
jae    1420 <main+0x250>
cmp    %r12,%rcx
jae    1420 <main+0x250>
cmpb   $0x0,(%r15,%rcx,1)
mov    $0x1,%ecx
cmovne %ecx,%eax
nopl   0x0(%rax,%rax,1)
test   %eax,%eax
je     130a <main+0x13a>
lea    0xc66(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,0x8(%rsp)
cmp    $0xfffffffffffffff8,%rbx
lea    0xc59(%rip),%rbx
je     12eb <main+0x11b>
nop
movzbl -0x1(%r15,%r14,1),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
cmp    %r13,%r14
jae    1471 <main+0x2a1>
lea    0x1(%r14),%rax
cmp    %r12,%r14
mov    %rax,%r14
jb     1450 <main+0x280>
lea    0xc31(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x8(%rsp),%r14
mov    %r14,%rbp
mov    $0x2e,%ebx
nopl   0x0(%rax)
movzbl -0x1(%r15,%rbp,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %ebx,%eax
movzbl %al,%edi
call   1040 <putchar@plt>
cmp    %r13,%rbp
jae    12fe <main+0x12e>
lea    0x1(%rbp),%rax
cmp    %r12,%rbp
mov    %rax,%rbp
jb     1490 <main+0x2c0>
jmp    12fe <main+0x12e>
mov    (%rbx),%rsi
lea    0xb35(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1541 <main+0x371>
lea    0xc34(%rip),%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rdi
call   1070 <fclose@plt>
test   %eax,%eax
jne    1535 <main+0x365>
mov    0x2acb(%rip),%rax
jmp    1548 <main+0x378>
mov    0x2ad2(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xb0f(%rip),%rsi
call   10a0 <fprintf@plt>
jmp    1541 <main+0x371>
lea    0xaf5(%rip),%rdi
jmp    153c <main+0x36c>
lea    0xaf2(%rip),%rdi
jmp    153c <main+0x36c>
lea    0xb05(%rip),%rdi
jmp    153c <main+0x36c>
lea    0xb75(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2a88(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Usage:\0A%s FILENAME\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"fopen\00"
@SEEK_END = global i32 0
@.str.3 = [6 x i8] c"fseek\00"
@stderr = global i32 0
@.str.4 = [22 x i8] c"File %s has length 0\0A\00"
@.str.5 = [7 x i8] c"calloc\00"
@.str.6 = [4 x i8] c"/*\0A\00"
@.str.7 = [46 x i8] c" * Non-zero %u byte strings of a disk image\0A\00"
@.str.8 = [4 x i8] c" *\0A\00"
@.str.9 = [39 x i8] c" * Generated with tools/file2include\0A\00"
@.str.10 = [39 x i8] c" * SPDX-License-Identifier:\09GPL-2.0+\0A\00"
@.str.11 = [6 x i8] c" */\0A\0A\00"
@.str.12 = [40 x i8] c"#define EFI_ST_DISK_IMG { 0x%08zx, { \\\0A\00"
@.str.13 = [13 x i8] c"\09{0x%08zx, \22\00"
@.str.14 = [7 x i8] c"\\x%02x\00"
@.str.15 = [8 x i8] c"\22}, /* \00"
@.str.16 = [3 x i8] c"%c\00"
@.str.17 = [2 x i8] c".\00"
@.str.18 = [7 x i8] c" */ \\\0A\00"
@.str.19 = [16 x i8] c"\09{0, NULL} } }\0A\00"
@.str.20 = [7 x i8] c"fclose\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %21
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i32, i32* @EXIT_FAILURE
store i32 %20, i32* %3
br label %192
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %25, i32** %6
%26 = load i32*, i32** %6
%27 = icmp ne i32* %26, null
br i1 %27, label %31, label %28
28: ; preds = %21
%29 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%30 = load i32, i32* @EXIT_FAILURE
store i32 %30, i32* %3
br label %192
31: ; preds = %21
%32 = load i32*, i32** %6
%33 = load i32, i32* @SEEK_END
%34 = call i32 @fseek(i32* %32, i32 0, i32 %33)
store i32 %34, i32* %7
%35 = load i32, i32* %7
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %31
%38 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%39 = load i32, i32* @EXIT_FAILURE
store i32 %39, i32* %3
br label %192
40: ; preds = %31
%41 = load i32*, i32** %6
%42 = call i64 @ftell(i32* %41)
store i64 %42, i64* %9
%43 = load i64, i64* %9
%44 = icmp ne i64 %43, 0
br i1 %44, label %52, label %45
45: ; preds = %40
%46 = load i32, i32* @stderr
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %49)
%51 = load i32, i32* @EXIT_FAILURE
store i32 %51, i32* %3
br label %192
52: ; preds = %40
%53 = load i32*, i32** %6
%54 = call i32 @rewind(i32* %53)
%55 = load i64, i64* %9
%56 = call i8* @malloc(i64 %55)
store i8* %56, i8** %8
%57 = load i8*, i8** %8
%58 = icmp ne i8* %57, null
br i1 %58, label %62, label %59
59: ; preds = %52
%60 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%61 = load i32, i32* @EXIT_FAILURE
store i32 %61, i32* %3
br label %192
62: ; preds = %52
%63 = load i8*, i8** %8
%64 = load i64, i64* %9
%65 = load i32*, i32** %6
%66 = call i64 @fread(i8* %63, i32 1, i64 %64, i32* %65)
store i64 %66, i64* %9
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), i32 8)
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.9, i64 0, i64 0))
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0))
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
%74 = load i64, i64* %9
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.12, i64 0, i64 0), i64 %74)
store i64 0, i64* %10
br label %76
76: ; preds = %176, %62
%77 = load i64, i64* %10
%78 = load i64, i64* %9
%79 = icmp ult i64 %77, %78
br i1 %79, label %80, label %179
80: ; preds = %76
store i32 0, i32* %12
%81 = load i64, i64* %10
store i64 %81, i64* %11
br label %82
82: ; preds = %101, %80
%83 = load i64, i64* %11
%84 = load i64, i64* %10
%85 = add i64 %84, 8
%86 = icmp ult i64 %83, %85
br i1 %86, label %87, label %91
87: ; preds = %82
%88 = load i64, i64* %11
%89 = load i64, i64* %9
%90 = icmp ult i64 %88, %89
br label %91
91: ; preds = %87, %82
%92 = phi i1 [ false, %82 ], [ %90, %87 ]
br i1 %92, label %93, label %104
93: ; preds = %91
%94 = load i8*, i8** %8
%95 = load i64, i64* %11
%96 = getelementptr inbounds i8, i8* %94, i64 %95
%97 = load i8, i8* %96
%98 = icmp ne i8 %97, 0
br i1 %98, label %99, label %100
99: ; preds = %93
store i32 1, i32* %12
br label %100
100: ; preds = %99, %93
br label %101
101: ; preds = %100
%102 = load i64, i64* %11
%103 = add i64 %102, 1
store i64 %103, i64* %11
br label %82
104: ; preds = %91
%105 = load i32, i32* %12
%106 = icmp ne i32 %105, 0
br i1 %106, label %108, label %107
107: ; preds = %104
br label %176
108: ; preds = %104
%109 = load i64, i64* %10
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i64 %109)
%111 = load i64, i64* %10
store i64 %111, i64* %11
br label %112
112: ; preds = %130, %108
%113 = load i64, i64* %11
%114 = load i64, i64* %10
%115 = add i64 %114, 8
%116 = icmp ult i64 %113, %115
br i1 %116, label %117, label %121
117: ; preds = %112
%118 = load i64, i64* %11
%119 = load i64, i64* %9
%120 = icmp ult i64 %118, %119
br label %121
121: ; preds = %117, %112
%122 = phi i1 [ false, %112 ], [ %120, %117 ]
br i1 %122, label %123, label %133
123: ; preds = %121
%124 = load i8*, i8** %8
%125 = load i64, i64* %11
%126 = getelementptr inbounds i8, i8* %124, i64 %125
%127 = load i8, i8* %126
%128 = zext i8 %127 to i32
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0), i32 %128)
br label %130
130: ; preds = %123
%131 = load i64, i64* %11
%132 = add i64 %131, 1
store i64 %132, i64* %11
br label %112
133: ; preds = %121
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.15, i64 0, i64 0))
%135 = load i64, i64* %10
store i64 %135, i64* %11
br label %136
136: ; preds = %171, %133
%137 = load i64, i64* %11
%138 = load i64, i64* %10
%139 = add i64 %138, 8
%140 = icmp ult i64 %137, %139
br i1 %140, label %141, label %145
141: ; preds = %136
%142 = load i64, i64* %11
%143 = load i64, i64* %9
%144 = icmp ult i64 %142, %143
br label %145
145: ; preds = %141, %136
%146 = phi i1 [ false, %136 ], [ %144, %141 ]
br i1 %146, label %147, label %174
147: ; preds = %145
%148 = load i8*, i8** %8
%149 = load i64, i64* %11
%150 = getelementptr inbounds i8, i8* %148, i64 %149
%151 = load i8, i8* %150
%152 = zext i8 %151 to i32
%153 = icmp sge i32 %152, 32
br i1 %153, label %154, label %168
154: ; preds = %147
%155 = load i8*, i8** %8
%156 = load i64, i64* %11
%157 = getelementptr inbounds i8, i8* %155, i64 %156
%158 = load i8, i8* %157
%159 = zext i8 %158 to i32
%160 = icmp sle i32 %159, 126
br i1 %160, label %161, label %168
161: ; preds = %154
%162 = load i8*, i8** %8
%163 = load i64, i64* %11
%164 = getelementptr inbounds i8, i8* %162, i64 %163
%165 = load i8, i8* %164
%166 = zext i8 %165 to i32
%167 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i32 %166)
br label %170
168: ; preds = %154, %147
%169 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.17, i64 0, i64 0))
br label %170
170: ; preds = %168, %161
br label %171
171: ; preds = %170
%172 = load i64, i64* %11
%173 = add i64 %172, 1
store i64 %173, i64* %11
br label %136
174: ; preds = %145
%175 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.18, i64 0, i64 0))
br label %176
176: ; preds = %174, %107
%177 = load i64, i64* %10
%178 = add i64 %177, 8
store i64 %178, i64* %10
br label %76
179: ; preds = %76
%180 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.19, i64 0, i64 0))
%181 = load i8*, i8** %8
%182 = call i32 @free(i8* %181)
%183 = load i32*, i32** %6
%184 = call i32 @fclose(i32* %183)
store i32 %184, i32* %7
%185 = load i32, i32* %7
%186 = icmp ne i32 %185, 0
br i1 %186, label %187, label %190
187: ; preds = %179
%188 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.20, i64 0, i64 0))
%189 = load i32, i32* @EXIT_FAILURE
store i32 %189, i32* %3
br label %192
190: ; preds = %179
%191 = load i32, i32* @EXIT_SUCCESS
store i32 %191, i32* %3
br label %192
192: ; preds = %190, %187, %59, %45, %37, %28, %15
%193 = load i32, i32* %3
ret i32 %193
}

LLVM IR (-O2):
@.str = [20 x i8] c"Usage:\0A%s FILENAME\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"fopen\00"
@SEEK_END = global i32 0
@.str.3 = [6 x i8] c"fseek\00"
@stderr = global i32 0
@.str.4 = [22 x i8] c"File %s has length 0\0A\00"
@.str.5 = [7 x i8] c"calloc\00"
@.str.7 = [46 x i8] c" * Non-zero %u byte strings of a disk image\0A\00"
@.str.12 = [40 x i8] c"#define EFI_ST_DISK_IMG { 0x%08zx, { \\\0A\00"
@.str.13 = [13 x i8] c"\09{0x%08zx, \22\00"
@.str.14 = [7 x i8] c"\\x%02x\00"
@.str.15 = [8 x i8] c"\22}, /* \00"
@.str.20 = [7 x i8] c"fclose\00"
@EXIT_SUCCESS = global i32 0
@str = [3 x i8] c"/*\00"
@str.22 = [38 x i8] c" * Generated with tools/file2include\00"
@str.23 = [3 x i8] c" *\00"
@str.24 = [38 x i8] c" * SPDX-License-Identifier:\09GPL-2.0+\00"
@str.25 = [5 x i8] c" */\0A\00"
@str.26 = [15 x i8] c"\09{0, NULL} } }\00"
@str.27 = [6 x i8] c" */ \\\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %159
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %159
14: ; preds = %7
%15 = load i32, i32* @SEEK_END
%16 = tail call i32 @fseek(i32* %10, i32 0, i32 %15)
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %159
20: ; preds = %14
%21 = tail call i64 @ftell(i32* %10)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %8
%26 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %25)
br label %159
27: ; preds = %20
%28 = tail call i32 @rewind(i32* %10)
%29 = tail call i8* @malloc(i64 %21)
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %159
33: ; preds = %27
%34 = tail call i64 @fread(i8* %29, i32 1, i64 %21, i32* %10)
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), i32 8)
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.23, i64 0, i64 0))
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.22, i64 0, i64 0))
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.23, i64 0, i64 0))
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.24, i64 0, i64 0))
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.25, i64 0, i64 0))
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.12, i64 0, i64 0), i64 %34)
%43 = icmp eq i64 %34, 0
br i1 %43, label %152, label %44
44: ; preds = %33, %150
%45 = phi i64 [ %46, %150 ], [ 0, %33 ]
%46 = add i64 %45, 8
%47 = icmp eq i64 %45, -8
br i1 %47, label %150, label %48
48: ; preds = %44
%49 = getelementptr inbounds i8, i8* %29, i64 %45
%50 = load i8, i8* %49
%51 = icmp ne i8 %50, 0
%52 = zext i1 %51 to i32
%53 = or i64 %45, 1
%54 = icmp ult i64 %53, %46
%55 = icmp ult i64 %53, %34
%56 = and i1 %54, %55
br i1 %56, label %57, label %116
57: ; preds = %48
%58 = getelementptr inbounds i8, i8* %29, i64 %53
%59 = load i8, i8* %58
%60 = icmp eq i8 %59, 0
%61 = select i1 %60, i32 %52, i32 1
%62 = or i64 %45, 2
%63 = icmp ult i64 %62, %46
%64 = icmp ult i64 %62, %34
%65 = and i1 %63, %64
br i1 %65, label %66, label %116
66: ; preds = %57
%67 = getelementptr inbounds i8, i8* %29, i64 %62
%68 = load i8, i8* %67
%69 = icmp eq i8 %68, 0
%70 = select i1 %69, i32 %61, i32 1
%71 = or i64 %45, 3
%72 = icmp ult i64 %71, %46
%73 = icmp ult i64 %71, %34
%74 = and i1 %72, %73
br i1 %74, label %75, label %116
75: ; preds = %66
%76 = getelementptr inbounds i8, i8* %29, i64 %71
%77 = load i8, i8* %76
%78 = icmp eq i8 %77, 0
%79 = select i1 %78, i32 %70, i32 1
%80 = or i64 %45, 4
%81 = icmp ult i64 %80, %46
%82 = icmp ult i64 %80, %34
%83 = and i1 %81, %82
br i1 %83, label %84, label %116
84: ; preds = %75
%85 = getelementptr inbounds i8, i8* %29, i64 %80
%86 = load i8, i8* %85
%87 = icmp eq i8 %86, 0
%88 = select i1 %87, i32 %79, i32 1
%89 = or i64 %45, 5
%90 = icmp ult i64 %89, %46
%91 = icmp ult i64 %89, %34
%92 = and i1 %90, %91
br i1 %92, label %93, label %116
93: ; preds = %84
%94 = getelementptr inbounds i8, i8* %29, i64 %89
%95 = load i8, i8* %94
%96 = icmp eq i8 %95, 0
%97 = select i1 %96, i32 %88, i32 1
%98 = or i64 %45, 6
%99 = icmp ult i64 %98, %46
%100 = icmp ult i64 %98, %34
%101 = and i1 %99, %100
br i1 %101, label %102, label %116
102: ; preds = %93
%103 = getelementptr inbounds i8, i8* %29, i64 %98
%104 = load i8, i8* %103
%105 = icmp eq i8 %104, 0
%106 = select i1 %105, i32 %97, i32 1
%107 = or i64 %45, 7
%108 = icmp ult i64 %107, %46
%109 = icmp ult i64 %107, %34
%110 = and i1 %108, %109
br i1 %110, label %111, label %116
111: ; preds = %102
%112 = getelementptr inbounds i8, i8* %29, i64 %107
%113 = load i8, i8* %112
%114 = icmp eq i8 %113, 0
%115 = select i1 %114, i32 %106, i32 1
br label %116
116: ; preds = %111, %102, %93, %84, %75, %66, %57, %48
%117 = phi i32 [ %52, %48 ], [ %61, %57 ], [ %70, %66 ], [ %79, %75 ], [ %88, %84 ], [ %97, %93 ], [ %106, %102 ], [ %115, %111 ]
%118 = icmp eq i32 %117, 0
br i1 %118, label %150, label %119
119: ; preds = %116
%120 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i64 %45)
br i1 %47, label %121, label %123
121: ; preds = %119
%122 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.15, i64 0, i64 0))
br label %148
123: ; preds = %119, %123
%124 = phi i64 [ %129, %123 ], [ %45, %119 ]
%125 = getelementptr inbounds i8, i8* %29, i64 %124
%126 = load i8, i8* %125
%127 = zext i8 %126 to i32
%128 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0), i32 %127)
%129 = add nuw i64 %124, 1
%130 = icmp ult i64 %129, %46
%131 = icmp ult i64 %129, %34
%132 = and i1 %130, %131
br i1 %132, label %123, label %133
133: ; preds = %123
%134 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.15, i64 0, i64 0))
br label %135
135: ; preds = %133, %135
%136 = phi i64 [ %144, %135 ], [ %45, %133 ]
%137 = getelementptr inbounds i8, i8* %29, i64 %136
%138 = load i8, i8* %137
%139 = add i8 %138, -32
%140 = icmp ult i8 %139, 95
%141 = select i1 %140, i8 %138, i8 46
%142 = zext i8 %141 to i32
%143 = tail call i32 @putchar(i32 %142)
%144 = add nuw i64 %136, 1
%145 = icmp ult i64 %144, %46
%146 = icmp ult i64 %144, %34
%147 = and i1 %145, %146
br i1 %147, label %135, label %148
148: ; preds = %135, %121
%149 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.27, i64 0, i64 0))
br label %150
150: ; preds = %44, %116, %148
%151 = icmp ult i64 %46, %34
br i1 %151, label %44, label %152
152: ; preds = %150, %33
%153 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.26, i64 0, i64 0))
%154 = tail call i32 @free(i8* %29)
%155 = tail call i32 @fclose(i32* %10)
%156 = icmp eq i32 %155, 0
br i1 %156, label %159, label %157
157: ; preds = %152
%158 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.20, i64 0, i64 0))
br label %159
159: ; preds = %152, %157, %31, %23, %18, %12, %4
%160 = phi i32* [ @EXIT_FAILURE, %4 ], [ @EXIT_FAILURE, %18 ], [ @EXIT_FAILURE, %157 ], [ @EXIT_FAILURE, %31 ], [ @EXIT_FAILURE, %23 ], [ @EXIT_FAILURE, %12 ], [ @EXIT_SUCCESS, %152 ]
%161 = load i32, i32* %160
ret i32 %161
}