#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 */
struct stat {
  int st_size;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int fstat(int, struct stat *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int, void *, int);
int main(int argc, char **argv) {
  unsigned char block[256];
  unsigned int csum;
  int fd_i, bc;
  FILE *fd_o;
  struct stat fileinfo;
  unsigned int i, j;
  if (argc != 4) {
    printf("usage: %s width binfile hexfile\n", argv[0]);
    return -1;
  }
  bc = atoi(argv[1]);
  if ((bc < 1) || (bc > 255)) {
    printf("byte count per line must be 1-255");
    return -1;
  }
  if ((fd_i = open(argv[2], O_RDONLY)) == -1 || fstat(fd_i, &fileinfo) == -1) {
    printf("Couldn't open file\n");
    return -1;
  }
  printf("size: %u bytes\n", fileinfo.st_size);
  if ((fd_o = fopen(argv[3], "w")) == NULL) {
    printf("invalid outfile\n");
    return -1;
  }
  for (i = 0; i < fileinfo.st_size; i += bc) {
    read(fd_i, (void *)block, bc);
    csum = bc + ((i / bc) >> 8) + ((i / bc) & 0xff);
    for (j = 0; j < bc; j++)
      csum += block[j];
    csum &= 0xff;
    csum = (~csum + 1) & 0xff;
    fprintf(fd_o, ":%.2X%.4X00", bc, i / bc);
    for (j = 0; j < bc; j++)
      fprintf(fd_o, "%.2X", block[bc - 1 - j]);
    fprintf(fd_o, "%.2X\n", csum);
  }
  fprintf(fd_o, ":00000001FF\n");
  fclose(fd_o);
  close(fd_i);
  return 0;
}


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)
cmpl   $0x4,-0x8(%rbp)
je     11d4 <main+0x44>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14bc <main+0x32c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x11c(%rbp)
cmpl   $0x1,-0x11c(%rbp)
jl     1204 <main+0x74>
cmpl   $0xff,-0x11c(%rbp)
jle    121e <main+0x8e>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14bc <main+0x32c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2dbb(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x118(%rbp)
cmp    $0xffffffff,%eax
je     125e <main+0xce>
mov    -0x118(%rbp),%edi
lea    -0x130(%rbp),%rsi
call   10b0 <fstat@plt>
cmp    $0xffffffff,%eax
jne    1278 <main+0xe8>
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14bc <main+0x32c>
mov    -0x130(%rbp),%esi
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xdcc(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x128(%rbp)
cmp    $0x0,%rax
jne    12cb <main+0x13b>
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14bc <main+0x32c>
movl   $0x0,-0x134(%rbp)
mov    -0x134(%rbp),%eax
cmp    -0x130(%rbp),%eax
jae    1489 <main+0x2f9>
mov    -0x118(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    -0x11c(%rbp),%edx
call   1060 <read@plt>
mov    -0x11c(%rbp),%eax
mov    %eax,-0x140(%rbp)
mov    -0x134(%rbp),%eax
xor    %edx,%edx
divl   -0x11c(%rbp)
mov    %eax,%ecx
mov    -0x140(%rbp),%eax
shr    $0x8,%ecx
add    %ecx,%eax
mov    %eax,-0x13c(%rbp)
mov    -0x134(%rbp),%eax
xor    %edx,%edx
divl   -0x11c(%rbp)
mov    %eax,%ecx
mov    -0x13c(%rbp),%eax
and    $0xff,%ecx
add    %ecx,%eax
mov    %eax,-0x114(%rbp)
movl   $0x0,-0x138(%rbp)
mov    -0x138(%rbp),%eax
cmp    -0x11c(%rbp),%eax
jae    139a <main+0x20a>
mov    -0x138(%rbp),%eax
movzbl -0x110(%rbp,%rax,1),%eax
ff
add    -0x114(%rbp),%eax
mov    %eax,-0x114(%rbp)
mov    -0x138(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x138(%rbp)
jmp    135a <main+0x1ca>
mov    -0x114(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x114(%rbp)
mov    -0x114(%rbp),%eax
xor    $0xffffffff,%eax
add    $0x1,%eax
and    $0xff,%eax
mov    %eax,-0x114(%rbp)
mov    -0x128(%rbp),%rdi
mov    -0x11c(%rbp),%eax
mov    %eax,-0x144(%rbp)
mov    -0x134(%rbp),%eax
xor    %edx,%edx
divl   -0x11c(%rbp)
mov    -0x144(%rbp),%edx
mov    %eax,%ecx
lea    0xc88(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x138(%rbp)
mov    -0x138(%rbp),%eax
cmp    -0x11c(%rbp),%eax
jae    1457 <main+0x2c7>
mov    -0x128(%rbp),%rdi
mov    -0x11c(%rbp),%eax
sub    $0x1,%eax
sub    -0x138(%rbp),%eax
mov    %eax,%eax
movzbl -0x110(%rbp,%rax,1),%edx
ff
lea    0xc4a(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x138(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x138(%rbp)
jmp    1403 <main+0x273>
mov    -0x128(%rbp),%rdi
mov    -0x114(%rbp),%edx
lea    0xc20(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x11c(%rbp),%eax
add    -0x134(%rbp),%eax
mov    %eax,-0x134(%rbp)
jmp    12d5 <main+0x145>
mov    -0x128(%rbp),%rdi
lea    0xbfa(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x128(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x118(%rbp),%edi
call   1050 <close@plt>
movl   $0x0,-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    $0x148,%rsp
mov    %rsi,%rbp
cmp    $0x4,%edi
jne    11f6 <main+0x46>
mov    0x8(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %eax,%r15d
lea    -0x100(%r15),%eax
cmp    $0xffffff00,%eax
ja     120d <main+0x5d>
lea    0xe37(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    14b8 <main+0x308>
mov    0x0(%rbp),%rsi
lea    0xdff(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    14b8 <main+0x308>
mov    0x10(%rbp),%rdi
mov    0x2dd0(%rip),%rax
mov    (%rax),%esi
call   1090 <open@plt>
cmp    $0xffffffff,%eax
je     1476 <main+0x2c6>
mov    %eax,%r14d
lea    0x8(%rsp),%rsi
mov    %eax,%edi
call   10d0 <fstat@plt>
cmp    $0xffffffff,%eax
je     1476 <main+0x2c6>
mov    0x8(%rsp),%ebx
lea    0xdf8(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rbp),%rdi
lea    0xdf4(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     14ac <main+0x2fc>
mov    %rax,%rbp
mov    %ebx,0x14(%rsp)
test   %ebx,%ebx
je     147f <main+0x2cf>
mov    %r15d,%ebx
mov    %ebx,%eax
and    $0xfffffff8,%eax
mov    %rax,0x30(%rsp)
add    $0xfffffffffffffff8,%rax
mov    %rax,0x28(%rsp)
mov    %rax,%rcx
shr    $0x3,%rcx
add    $0x1,%rcx
mov    %rcx,%rax
mov    %rcx,0x20(%rsp)
and    $0xfffffffffffffffe,%rcx
mov    %rcx,0x18(%rsp)
lea    0xdac(%rip),%r12
xor    %r13d,%r13d
mov    %r14d,0x10(%rsp)
mov    %r15,0x38(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14d,%edi
lea    0x40(%rsp),%rsi
mov    %r15d,%edx
call   1070 <read@plt>
mov    %r13d,%eax
xor    %edx,%edx
div    %r15d
mov    %eax,%edx
shr    $0x8,%edx
add    %r15d,%edx
movzbl %al,%ecx
add    %edx,%ecx
cmp    $0x8,%r15d
jae    1310 <main+0x160>
xor    %edx,%edx
jmp    13e0 <main+0x230>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movd   %ecx,%xmm0
cmpq   $0x0,0x28(%rsp)
je     145c <main+0x2ac>
pxor   %xmm1,%xmm1
mov    0x18(%rsp),%rdx
xor    %ecx,%ecx
pxor   %xmm4,%xmm4
nop
movdqa 0x40(%rsp,%rcx,1),%xmm2
movd   0x44(%rsp,%rcx,1),%xmm3
punpcklbw %xmm4,%xmm2
punpcklwd %xmm4,%xmm2
paddd  %xmm0,%xmm2
punpcklbw %xmm4,%xmm3
punpcklwd %xmm4,%xmm3
paddd  %xmm1,%xmm3
movq   0x48(%rsp,%rcx,1),%xmm0
movd   0x4c(%rsp,%rcx,1),%xmm1
punpcklbw %xmm4,%xmm0
punpcklwd %xmm4,%xmm0
paddd  %xmm2,%xmm0
punpcklbw %xmm4,%xmm1
punpcklwd %xmm4,%xmm1
paddd  %xmm3,%xmm1
add    $0x10,%rcx
add    $0xfffffffffffffffe,%rdx
jne    1330 <main+0x180>
testb  $0x1,0x20(%rsp)
je     13ad <main+0x1fd>
movq   0x40(%rsp,%rcx,1),%xmm2
movd   0x44(%rsp,%rcx,1),%xmm3
punpcklbw %xmm4,%xmm2
punpcklwd %xmm4,%xmm2
paddd  %xmm2,%xmm0
punpcklbw %xmm4,%xmm3
punpcklwd %xmm4,%xmm3
paddd  %xmm3,%xmm1
paddd  %xmm1,%xmm0
pshufd $0xee,%xmm0,%xmm1
paddd  %xmm0,%xmm1
pshufd $0x55,%xmm1,%xmm0
paddd  %xmm1,%xmm0
movd   %xmm0,%ecx
mov    0x30(%rsp),%rsi
mov    %rsi,%rdx
cmp    %rbx,%rsi
je     13f0 <main+0x240>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl 0x40(%rsp,%rdx,1),%esi
add    %esi,%ecx
add    $0x1,%rdx
cmp    %rdx,%rbx
jne    13e0 <main+0x230>
neg    %ecx
movzbl %cl,%r14d
mov    %rbp,%rdi
lea    0xc55(%rip),%rsi
mov    %r15d,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %rbx,%r15
nop
add    $0xffffffffffffffff,%r15
mov    %r15d,%eax
movzbl 0x40(%rsp,%rax,1),%edx
mov    %rbp,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
test   %r15,%r15
jne    1410 <main+0x260>
mov    %rbp,%rdi
lea    0xc2e(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x38(%rsp),%r15
add    %r15d,%r13d
cmp    0x14(%rsp),%r13d
mov    0x10(%rsp),%r14d
jb     12d0 <main+0x120>
jmp    147f <main+0x2cf>
pxor   %xmm1,%xmm1
xor    %ecx,%ecx
pxor   %xmm4,%xmm4
testb  $0x1,0x20(%rsp)
jne    1389 <main+0x1d9>
jmp    13ad <main+0x1fd>
lea    0xc0c(%rip),%rdi
jmp    14b3 <main+0x303>
lea    0xbe6(%rip),%rdi
mov    $0xc,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   10c0 <fwrite@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    %r14d,%edi
call   1060 <close@plt>
xor    %eax,%eax
jmp    14bd <main+0x30d>
lea    0xbc6(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x148,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [33 x i8] c"usage: %s width binfile hexfile\0A\00"
@.str.1 = [34 x i8] c"byte count per line must be 1-255\00"
@O_RDONLY = global i32 0
@.str.2 = [20 x i8] c"Couldn't open file\0A\00"
@.str.3 = [16 x i8] c"size: %u bytes\0A\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [17 x i8] c"invalid outfile\0A\00"
@.str.6 = [12 x i8] c":%.2X%.4X00\00"
@.str.7 = [5 x i8] c"%.2X\00"
@.str.8 = [6 x i8] c"%.2X\0A\00"
@.str.9 = [13 x i8] c":00000001FF\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca %struct.stat
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 4
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %19)
store i32 -1, i32* %3
br label %140
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %9
%26 = load i32, i32* %9
%27 = icmp slt i32 %26, 1
br i1 %27, label %31, label %28
28: ; preds = %21
%29 = load i32, i32* %9
%30 = icmp sgt i32 %29, 255
br i1 %30, label %31, label %33
31: ; preds = %28, %21
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %140
33: ; preds = %28
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = load i32, i32* @O_RDONLY
%38 = call i32 @open(i8* %36, i32 %37)
store i32 %38, i32* %8
%39 = icmp eq i32 %38, -1
br i1 %39, label %44, label %40
40: ; preds = %33
%41 = load i32, i32* %8
%42 = call i32 @fstat(i32 %41, %struct.stat* %11)
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %46
44: ; preds = %40, %33
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %140
46: ; preds = %40
%47 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%48 = load i32, i32* %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %48)
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 3
%52 = load i8*, i8** %51
%53 = call i32* @fopen(i8* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %53, i32** %10
%54 = icmp eq i32* %53, null
br i1 %54, label %55, label %57
55: ; preds = %46
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %140
57: ; preds = %46
store i32 0, i32* %12
br label %58
58: ; preds = %129, %57
%59 = load i32, i32* %12
%60 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%61 = load i32, i32* %60
%62 = icmp ult i32 %59, %61
br i1 %62, label %63, label %133
63: ; preds = %58
%64 = load i32, i32* %8
%65 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%66 = load i32, i32* %9
%67 = call i32 @read(i32 %64, i8* %65, i32 %66)
%68 = load i32, i32* %9
%69 = load i32, i32* %12
%70 = load i32, i32* %9
%71 = udiv i32 %69, %70
%72 = lshr i32 %71, 8
%73 = add i32 %68, %72
%74 = load i32, i32* %12
%75 = load i32, i32* %9
%76 = udiv i32 %74, %75
%77 = and i32 %76, 255
%78 = add i32 %73, %77
store i32 %78, i32* %7
store i32 0, i32* %13
br label %79
79: ; preds = %91, %63
%80 = load i32, i32* %13
%81 = load i32, i32* %9
%82 = icmp ult i32 %80, %81
br i1 %82, label %83, label %94
83: ; preds = %79
%84 = load i32, i32* %13
%85 = zext i32 %84 to i64
%86 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %85
%87 = load i8, i8* %86
%88 = zext i8 %87 to i32
%89 = load i32, i32* %7
%90 = add i32 %89, %88
store i32 %90, i32* %7
br label %91
91: ; preds = %83
%92 = load i32, i32* %13
%93 = add i32 %92, 1
store i32 %93, i32* %13
br label %79
94: ; preds = %79
%95 = load i32, i32* %7
%96 = and i32 %95, 255
store i32 %96, i32* %7
%97 = load i32, i32* %7
%98 = xor i32 %97, -1
%99 = add i32 %98, 1
%100 = and i32 %99, 255
store i32 %100, i32* %7
%101 = load i32*, i32** %10
%102 = load i32, i32* %9
%103 = load i32, i32* %12
%104 = load i32, i32* %9
%105 = udiv i32 %103, %104
%106 = call i32 (i32*, i8*, ...) @fprintf(i32* %101, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %102, i32 %105)
store i32 0, i32* %13
br label %107
107: ; preds = %122, %94
%108 = load i32, i32* %13
%109 = load i32, i32* %9
%110 = icmp ult i32 %108, %109
br i1 %110, label %111, label %125
111: ; preds = %107
%112 = load i32*, i32** %10
%113 = load i32, i32* %9
%114 = sub nsw i32 %113, 1
%115 = load i32, i32* %13
%116 = sub i32 %114, %115
%117 = zext i32 %116 to i64
%118 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %117
%119 = load i8, i8* %118
%120 = zext i8 %119 to i32
%121 = call i32 (i32*, i8*, ...) @fprintf(i32* %112, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %120)
br label %122
122: ; preds = %111
%123 = load i32, i32* %13
%124 = add i32 %123, 1
store i32 %124, i32* %13
br label %107
125: ; preds = %107
%126 = load i32*, i32** %10
%127 = load i32, i32* %7
%128 = call i32 (i32*, i8*, ...) @fprintf(i32* %126, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 %127)
br label %129
129: ; preds = %125
%130 = load i32, i32* %9
%131 = load i32, i32* %12
%132 = add i32 %131, %130
store i32 %132, i32* %12
br label %58
133: ; preds = %58
%134 = load i32*, i32** %10
%135 = call i32 (i32*, i8*, ...) @fprintf(i32* %134, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
%136 = load i32*, i32** %10
%137 = call i32 @fclose(i32* %136)
%138 = load i32, i32* %8
%139 = call i32 @close(i32 %138)
store i32 0, i32* %3
br label %140
140: ; preds = %133, %55, %44, %31, %16
%141 = load i32, i32* %3
ret i32 %141
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [33 x i8] c"usage: %s width binfile hexfile\0A\00"
@.str.1 = [34 x i8] c"byte count per line must be 1-255\00"
@O_RDONLY = global i32 0
@.str.3 = [16 x i8] c"size: %u bytes\0A\00"
@.str.4 = [2 x i8] c"w\00"
@.str.6 = [12 x i8] c":%.2X%.4X00\00"
@.str.7 = [5 x i8] c"%.2X\00"
@.str.8 = [6 x i8] c"%.2X\0A\00"
@.str.9 = [13 x i8] c":00000001FF\0A\00"
@str = [16 x i8] c"invalid outfile\00"
@str.10 = [19 x i8] c"Couldn't open file\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca %struct.stat
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = bitcast %struct.stat* %4 to i8*
%7 = icmp eq i32 %0, 4
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %154
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = add i32 %14, -256
%16 = icmp ult i32 %15, -255
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %154
19: ; preds = %11
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = load i32, i32* @O_RDONLY
%23 = tail call i32 @open(i8* %21, i32 %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %28, label %25
25: ; preds = %19
%26 = call i32 @fstat(i32 %23, %struct.stat* %4)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %30
28: ; preds = %25, %19
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.10, i64 0, i64 0))
br label %154
30: ; preds = %25
%31 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%32 = load i32, i32* %31
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds i8*, i8** %1, i64 3
%35 = load i8*, i8** %34
%36 = tail call i32* @fopen(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%37 = icmp eq i32* %36, null
br i1 %37, label %54, label %38
38: ; preds = %30
%39 = icmp eq i32 %32, 0
br i1 %39, label %150, label %40
40: ; preds = %38
%41 = zext i32 %14 to i64
%42 = zext i32 %14 to i64
%43 = and i64 %41, 4294967288
%44 = add nsw i64 %43, -8
%45 = lshr exact i64 %44, 3
%46 = add nuw nsw i64 %45, 1
%47 = icmp ult i32 %14, 8
%48 = and i64 %41, 4294967288
%49 = and i64 %46, 1
%50 = icmp eq i64 %44, 0
%51 = and i64 %46, 4611686018427387902
%52 = icmp eq i64 %49, 0
%53 = icmp eq i64 %48, %41
br label %56
54: ; preds = %30
%55 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %154
56: ; preds = %40, %146
%57 = phi i32 [ 0, %40 ], [ %148, %146 ]
%58 = call i32 @read(i32 %23, i8* %5, i32 %14)
%59 = udiv i32 %57, %14
%60 = lshr i32 %59, 8
%61 = add i32 %60, %14
%62 = and i32 %59, 255
%63 = add i32 %61, %62
br i1 %47, label %117, label %64
64: ; preds = %56
%65 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %63, i64 0
br i1 %50, label %95, label %66
66: ; preds = %64, %66
%67 = phi i64 [ %92, %66 ], [ 0, %64 ]
%68 = phi <4 x i32> [ %90, %66 ], [ %65, %64 ]
%69 = phi <4 x i32> [ %91, %66 ], [ zeroinitializer, %64 ]
%70 = phi i64 [ %93, %66 ], [ 0, %64 ]
%71 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %67
%72 = bitcast i8* %71 to <4 x i8>*
%73 = load <4 x i8>, <4 x i8>* %72
%74 = getelementptr inbounds i8, i8* %71, i64 4
%75 = bitcast i8* %74 to <4 x i8>*
%76 = load <4 x i8>, <4 x i8>* %75
%77 = zext <4 x i8> %73 to <4 x i32>
%78 = zext <4 x i8> %76 to <4 x i32>
%79 = add <4 x i32> %68, %77
%80 = add <4 x i32> %69, %78
%81 = or i64 %67, 8
%82 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %81
%83 = bitcast i8* %82 to <4 x i8>*
%84 = load <4 x i8>, <4 x i8>* %83
%85 = getelementptr inbounds i8, i8* %82, i64 4
%86 = bitcast i8* %85 to <4 x i8>*
%87 = load <4 x i8>, <4 x i8>* %86
%88 = zext <4 x i8> %84 to <4 x i32>
%89 = zext <4 x i8> %87 to <4 x i32>
%90 = add <4 x i32> %79, %88
%91 = add <4 x i32> %80, %89
%92 = add nuw i64 %67, 16
%93 = add i64 %70, 2
%94 = icmp eq i64 %93, %51
br i1 %94, label %95, label %66
95: ; preds = %66, %64
%96 = phi <4 x i32> [ undef, %64 ], [ %90, %66 ]
%97 = phi <4 x i32> [ undef, %64 ], [ %91, %66 ]
%98 = phi i64 [ 0, %64 ], [ %92, %66 ]
%99 = phi <4 x i32> [ %65, %64 ], [ %90, %66 ]
%100 = phi <4 x i32> [ zeroinitializer, %64 ], [ %91, %66 ]
br i1 %52, label %112, label %101
101: ; preds = %95
%102 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %98
%103 = bitcast i8* %102 to <4 x i8>*
%104 = load <4 x i8>, <4 x i8>* %103
%105 = getelementptr inbounds i8, i8* %102, i64 4
%106 = bitcast i8* %105 to <4 x i8>*
%107 = load <4 x i8>, <4 x i8>* %106
%108 = zext <4 x i8> %104 to <4 x i32>
%109 = zext <4 x i8> %107 to <4 x i32>
%110 = add <4 x i32> %99, %108
%111 = add <4 x i32> %100, %109
br label %112
112: ; preds = %95, %101
%113 = phi <4 x i32> [ %96, %95 ], [ %110, %101 ]
%114 = phi <4 x i32> [ %97, %95 ], [ %111, %101 ]
%115 = add <4 x i32> %114, %113
%116 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %115)
br i1 %53, label %129, label %117
117: ; preds = %56, %112
%118 = phi i64 [ 0, %56 ], [ %48, %112 ]
%119 = phi i32 [ %63, %56 ], [ %116, %112 ]
br label %120
120: ; preds = %117, %120
%121 = phi i64 [ %127, %120 ], [ %118, %117 ]
%122 = phi i32 [ %126, %120 ], [ %119, %117 ]
%123 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %121
%124 = load i8, i8* %123
%125 = zext i8 %124 to i32
%126 = add i32 %122, %125
%127 = add nuw nsw i64 %121, 1
%128 = icmp eq i64 %127, %41
br i1 %128, label %129, label %120
129: ; preds = %120, %112
%130 = phi i32 [ %116, %112 ], [ %126, %120 ]
%131 = sub i32 0, %130
%132 = and i32 %131, 255
%133 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %14, i32 %59)
br label %134
134: ; preds = %129, %134
%135 = phi i64 [ 0, %129 ], [ %144, %134 ]
%136 = trunc i64 %135 to i32
%137 = xor i32 %136, -1
%138 = add i32 %14, %137
%139 = zext i32 %138 to i64
%140 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %139
%141 = load i8, i8* %140
%142 = zext i8 %141 to i32
%143 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %142)
%144 = add nuw nsw i64 %135, 1
%145 = icmp eq i64 %144, %42
br i1 %145, label %146, label %134
146: ; preds = %134
%147 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 %132)
%148 = add i32 %57, %14
%149 = icmp ult i32 %148, %32
br i1 %149, label %56, label %150
150: ; preds = %146, %38
%151 = tail call i64 @fwrite(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i64 12, i64 1, i32* %36)
%152 = tail call i32 @fclose(i32* %36)
%153 = tail call i32 @close(i32 %23)
br label %154
154: ; preds = %150, %54, %28, %17, %8
%155 = phi i32 [ -1, %8 ], [ -1, %17 ], [ -1, %28 ], [ -1, %54 ], [ 0, %150 ]
ret i32 %155
}