#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 /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(unsigned char *, int, size_t, int /*<<< orphan*/ *);
scalar_t__ memcmp(unsigned char *, char *, int);
int /*<<< orphan*/ printf(char *, char *, unsigned int, size_t);
int /*<<< orphan*/ sprintf(char *, char *, char *, int /*<<< orphan*/);
void write(unsigned char *_src, int _size, char *_prefix) {
  FILE *fh;
  unsigned int offset;
  size_t size, fsize, remain;
  char name[0x20];
  int bgmno = 0, tonno = 0;
  unsigned char found = 0;
  offset = 0;
  remain = _size;
  do {
    if (memcmp(&_src[offset], "BGM", 3) == 0 ||
        memcmp(&_src[offset], "bgm", 3) == 0) {
      found = 1;
    }
    if (memcmp(&_src[offset], "ONS", 3) == 0 ||
        memcmp(&_src[offset], "ons", 3) == 0) {
      found = 2;
    }
    if (found == 0) {
      break;
    }
    size = 512;
    remain -= 512;
    while (remain > 0) {
      if (memcmp(&_src[offset + size], "BGM", 3) == 0 ||
          memcmp(&_src[offset + size], "bgm", 3) == 0 ||
          memcmp(&_src[offset + size], "ONS", 3) == 0 ||
          memcmp(&_src[offset + size], "ons", 3) == 0) {
        break;
      }
      remain -= 512;
      size += 512;
      continue;
    }
    if (found == 1) {
      sprintf(name, "%s%02X.BGM", _prefix, bgmno++);
    } else {
      sprintf(name, "%s%02X.TON", _prefix, tonno++);
    }
    fsize = _src[offset + 4] + ((size_t)_src[offset + 5] << 8);
    printf("%s ofs:0x%04x size:0x%04x\n", name, offset, fsize);
    fh = fopen(name, "wb");
    fseek(fh, SEEK_SET, 0);
    fwrite(_src + offset + 0x10, 1, size - 0x10, fh);
    fclose(fh);
    offset += size;
    found = 0;
  } while (offset < _size);
}


x86 assembly (clang, -O0):
<write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x64(%rbp)
movl   $0x0,-0x68(%rbp)
movb   $0x0,-0x69(%rbp)
movl   $0x0,-0x24(%rbp)
movslq -0xc(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    %rax,%rdi
lea    0xe5e(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     11ee <write+0x7e>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    %rax,%rdi
lea    0xe26(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    11f2 <write+0x82>
movb   $0x1,-0x69(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    %rax,%rdi
lea    0xe01(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     123c <write+0xcc>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    %rax,%rdi
lea    0xde0(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    1240 <write+0xd0>
movb   $0x2,-0x69(%rbp)
movzbl -0x69(%rbp),%eax
cmp    $0x0,%eax
jne    1252 <write+0xe2>
jmp    1441 <write+0x2d1>
movq   $0x200,-0x30(%rbp)
mov    -0x40(%rbp),%rax
sub    $0x200,%rax
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jbe    133d <write+0x1cd>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    -0x30(%rbp),%rax
add    %rax,%rdi
lea    0xd8b(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     1317 <write+0x1a7>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    -0x30(%rbp),%rax
add    %rax,%rdi
lea    0xd4f(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     1317 <write+0x1a7>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    -0x30(%rbp),%rax
add    %rax,%rdi
lea    0xd2a(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     1317 <write+0x1a7>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    -0x30(%rbp),%rax
add    %rax,%rdi
lea    0xd05(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    131c <write+0x1ac>
jmp    133d <write+0x1cd>
mov    -0x40(%rbp),%rax
sub    $0x200,%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
add    $0x200,%rax
mov    %rax,-0x30(%rbp)
jmp    1268 <write+0xf8>
movzbl -0x69(%rbp),%eax
cmp    $0x1,%eax
jne    136e <write+0x1fe>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x64(%rbp),%ecx
mov    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
lea    0xca8(%rip),%rsi
call   1080 <sprintf@plt>
jmp    138d <write+0x21d>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x68(%rbp),%ecx
mov    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
lea    0xc8f(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x4,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
mov    -0x8(%rbp),%rcx
mov    -0x24(%rbp),%edx
add    $0x5,%edx
mov    %edx,%edx
movzbl (%rcx,%rdx,1),%ecx
shl    $0x8,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
lea    -0x60(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x38(%rbp),%rcx
lea    0xc58(%rip),%rdi
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
lea    0xc63(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2bf2(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1060 <fseek@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    %rax,%rdi
add    $0x10,%rdi
mov    -0x30(%rbp),%rdx
sub    $0x10,%rdx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   1090 <fwrite@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x30(%rbp),%rcx
mov    -0x24(%rbp),%eax
add    %rcx,%rax
mov    %eax,-0x24(%rbp)
movb   $0x0,-0x69(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jb     11a4 <write+0x34>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rdx,0x20(%rsp)
mov    %rdi,0x28(%rsp)
mov    %esi,0xc(%rsp)
movslq %esi,%r12
xor    %ebx,%ebx
xor    %eax,%eax
mov    %rax,0x18(%rsp)
xor    %eax,%eax
mov    %rax,0x10(%rsp)
jmp    1259 <write+0xe9>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x10(%rsp),%rcx
lea    0x1(%rcx),%ebp
mov    %r14,%rdi
lea    0xe55(%rip),%rsi
mov    0x20(%rsp),%rdx
call   1080 <sprintf@plt>
mov    %ebp,%eax
mov    %rax,0x10(%rsp)
mov    %r13,%rax
or     $0x4,%rax
mov    0x28(%rsp),%rdx
movzbl (%rdx,%rax,1),%eax
mov    %r13,%rcx
or     $0x5,%rcx
movzbl (%rdx,%rcx,1),%ecx
shl    $0x8,%rcx
or     %rax,%rcx
lea    0xe26(%rip),%rdi
mov    %r14,%rsi
mov    %r13d,%edx
call   1040 <printf@plt>
mov    %r14,%rdi
lea    0xe2c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbp
mov    0x2dc0(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
xor    %edx,%edx
call   1060 <fseek@plt>
add    $0x10,%r15
lea    -0x10(%rbx),%rdx
mov    %r15,%rdi
mov    $0x1,%esi
mov    %rbp,%rcx
call   1090 <fwrite@plt>
mov    %rbp,%rdi
call   1030 <fclose@plt>
add    %r13d,%ebx
cmp    0xc(%rsp),%ebx
jae    13b1 <write+0x241>
mov    %ebx,%r13d
mov    0x28(%rsp),%rax
lea    (%rax,%r13,1),%r15
mov    %r15,%rdi
lea    0xda4(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     12a0 <write+0x130>
mov    %r15,%rdi
lea    0xd78(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     12a0 <write+0x130>
xor    %ebx,%ebx
jmp    12a2 <write+0x132>
nopl   0x0(%rax,%rax,1)
mov    $0x1,%bl
mov    %r15,%rdi
lea    0xd58(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     12f0 <write+0x180>
mov    %r15,%rdi
lea    0xd43(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
setne  %bpl
sete   %al
or     %bl,%al
cmp    $0x1,%al
je     12f2 <write+0x182>
jmp    13b1 <write+0x241>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %ebp,%ebp
mov    $0x200,%ebx
add    $0xfffffffffffffe00,%r12
je     1378 <write+0x208>
lea    (%r15,%rbx,1),%r14
mov    %r14,%rdi
lea    0xd05(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     137b <write+0x20b>
mov    %r14,%rdi
lea    0xcd9(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     137b <write+0x20b>
mov    %r14,%rdi
lea    0xcc4(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     137b <write+0x20b>
mov    %r14,%rdi
lea    0xcaf(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     137b <write+0x20b>
add    $0x200,%rbx
add    $0xfffffffffffffe00,%r12
jne    1300 <write+0x190>
xor    %r12d,%r12d
lea    0x30(%rsp),%r14
test   %bpl,%bpl
je     11b0 <write+0x40>
mov    0x18(%rsp),%rcx
lea    0x1(%rcx),%ebp
mov    %r14,%rdi
lea    0xc71(%rip),%rsi
mov    0x20(%rsp),%rdx
call   1080 <sprintf@plt>
mov    %ebp,%eax
mov    %rax,0x18(%rsp)
jmp    11d3 <write+0x63>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"BGM\00"
@.str.1 = [4 x i8] c"bgm\00"
@.str.2 = [4 x i8] c"ONS\00"
@.str.3 = [4 x i8] c"ons\00"
@.str.4 = [11 x i8] c"%s%02X.BGM\00"
@.str.5 = [11 x i8] c"%s%02X.TON\00"
@.str.6 = [27 x i8] c"%s ofs:0x%04x size:0x%04x\0A\00"
@.str.7 = [3 x i8] c"wb\00"
@SEEK_SET = global i32 0
define void @write(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca [32 x i8]
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i32 0, i32* %13
store i32 0, i32* %14
store i8 0, i8* %15
store i32 0, i32* %8
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
store i64 %17, i64* %11
br label %18
18: ; preds = %159, %3
%19 = load i8*, i8** %4
%20 = load i32, i32* %8
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = call i64 @memcmp(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%24 = icmp eq i64 %23, 0
br i1 %24, label %32, label %25
25: ; preds = %18
%26 = load i8*, i8** %4
%27 = load i32, i32* %8
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = call i64 @memcmp(i8* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %25, %18
store i8 1, i8* %15
br label %33
33: ; preds = %32, %25
%34 = load i8*, i8** %4
%35 = load i32, i32* %8
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = call i64 @memcmp(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%39 = icmp eq i64 %38, 0
br i1 %39, label %47, label %40
40: ; preds = %33
%41 = load i8*, i8** %4
%42 = load i32, i32* %8
%43 = zext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = call i64 @memcmp(i8* %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %40, %33
store i8 2, i8* %15
br label %48
48: ; preds = %47, %40
%49 = load i8, i8* %15
%50 = zext i8 %49 to i32
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %48
br label %163
53: ; preds = %48
store i64 512, i64* %9
%54 = load i64, i64* %11
%55 = sub i64 %54, 512
store i64 %55, i64* %11
br label %56
56: ; preds = %96, %53
%57 = load i64, i64* %11
%58 = icmp ugt i64 %57, 0
br i1 %58, label %59, label %101
59: ; preds = %56
%60 = load i8*, i8** %4
%61 = load i32, i32* %8
%62 = zext i32 %61 to i64
%63 = load i64, i64* %9
%64 = add i64 %62, %63
%65 = getelementptr inbounds i8, i8* %60, i64 %64
%66 = call i64 @memcmp(i8* %65, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%67 = icmp eq i64 %66, 0
br i1 %67, label %95, label %68
68: ; preds = %59
%69 = load i8*, i8** %4
%70 = load i32, i32* %8
%71 = zext i32 %70 to i64
%72 = load i64, i64* %9
%73 = add i64 %71, %72
%74 = getelementptr inbounds i8, i8* %69, i64 %73
%75 = call i64 @memcmp(i8* %74, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%76 = icmp eq i64 %75, 0
br i1 %76, label %95, label %77
77: ; preds = %68
%78 = load i8*, i8** %4
%79 = load i32, i32* %8
%80 = zext i32 %79 to i64
%81 = load i64, i64* %9
%82 = add i64 %80, %81
%83 = getelementptr inbounds i8, i8* %78, i64 %82
%84 = call i64 @memcmp(i8* %83, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%85 = icmp eq i64 %84, 0
br i1 %85, label %95, label %86
86: ; preds = %77
%87 = load i8*, i8** %4
%88 = load i32, i32* %8
%89 = zext i32 %88 to i64
%90 = load i64, i64* %9
%91 = add i64 %89, %90
%92 = getelementptr inbounds i8, i8* %87, i64 %91
%93 = call i64 @memcmp(i8* %92, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%94 = icmp eq i64 %93, 0
br i1 %94, label %95, label %96
95: ; preds = %86, %77, %68, %59
br label %101
96: ; preds = %86
%97 = load i64, i64* %11
%98 = sub i64 %97, 512
store i64 %98, i64* %11
%99 = load i64, i64* %9
%100 = add i64 %99, 512
store i64 %100, i64* %9
br label %56
101: ; preds = %95, %56
%102 = load i8, i8* %15
%103 = zext i8 %102 to i32
%104 = icmp eq i32 %103, 1
br i1 %104, label %105, label %111
105: ; preds = %101
%106 = getelementptr inbounds [32 x i8], [32 x i8]* %12, i64 0, i64 0
%107 = load i8*, i8** %6
%108 = load i32, i32* %13
%109 = add nsw i32 %108, 1
store i32 %109, i32* %13
%110 = call i32 @sprintf(i8* %106, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %107, i32 %108)
br label %117
111: ; preds = %101
%112 = getelementptr inbounds [32 x i8], [32 x i8]* %12, i64 0, i64 0
%113 = load i8*, i8** %6
%114 = load i32, i32* %14
%115 = add nsw i32 %114, 1
store i32 %115, i32* %14
%116 = call i32 @sprintf(i8* %112, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %113, i32 %114)
br label %117
117: ; preds = %111, %105
%118 = load i8*, i8** %4
%119 = load i32, i32* %8
%120 = add i32 %119, 4
%121 = zext i32 %120 to i64
%122 = getelementptr inbounds i8, i8* %118, i64 %121
%123 = load i8, i8* %122
%124 = zext i8 %123 to i64
%125 = load i8*, i8** %4
%126 = load i32, i32* %8
%127 = add i32 %126, 5
%128 = zext i32 %127 to i64
%129 = getelementptr inbounds i8, i8* %125, i64 %128
%130 = load i8, i8* %129
%131 = zext i8 %130 to i64
%132 = shl i64 %131, 8
%133 = add i64 %124, %132
store i64 %133, i64* %10
%134 = getelementptr inbounds [32 x i8], [32 x i8]* %12, i64 0, i64 0
%135 = load i32, i32* %8
%136 = load i64, i64* %10
%137 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %134, i32 %135, i64 %136)
%138 = getelementptr inbounds [32 x i8], [32 x i8]* %12, i64 0, i64 0
%139 = call i32* @fopen(i8* %138, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
store i32* %139, i32** %7
%140 = load i32*, i32** %7
%141 = load i32, i32* @SEEK_SET
%142 = call i32 @fseek(i32* %140, i32 %141, i32 0)
%143 = load i8*, i8** %4
%144 = load i32, i32* %8
%145 = zext i32 %144 to i64
%146 = getelementptr inbounds i8, i8* %143, i64 %145
%147 = getelementptr inbounds i8, i8* %146, i64 16
%148 = load i64, i64* %9
%149 = sub i64 %148, 16
%150 = load i32*, i32** %7
%151 = call i32 @fwrite(i8* %147, i32 1, i64 %149, i32* %150)
%152 = load i32*, i32** %7
%153 = call i32 @fclose(i32* %152)
%154 = load i64, i64* %9
%155 = load i32, i32* %8
%156 = zext i32 %155 to i64
%157 = add i64 %156, %154
%158 = trunc i64 %157 to i32
store i32 %158, i32* %8
store i8 0, i8* %15
br label %159
159: ; preds = %117
%160 = load i32, i32* %8
%161 = load i32, i32* %5
%162 = icmp ult i32 %160, %161
br i1 %162, label %18, label %163
163: ; preds = %159, %52
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"BGM\00"
@.str.1 = [4 x i8] c"bgm\00"
@.str.2 = [4 x i8] c"ONS\00"
@.str.3 = [4 x i8] c"ons\00"
@.str.4 = [11 x i8] c"%s%02X.BGM\00"
@.str.5 = [11 x i8] c"%s%02X.TON\00"
@.str.6 = [27 x i8] c"%s ofs:0x%04x size:0x%04x\0A\00"
@.str.7 = [3 x i8] c"wb\00"
@SEEK_SET = global i32 0
define void @write(i8* %0, i32 %1, i8* %2) {
%4 = alloca [32 x i8]
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%6 = sext i32 %1 to i64
br label %7
7: ; preds = %62, %3
%8 = phi i32 [ 0, %3 ], [ %86, %62 ]
%9 = phi i64 [ %6, %3 ], [ %55, %62 ]
%10 = phi i32 [ 0, %3 ], [ %63, %62 ]
%11 = phi i32 [ 0, %3 ], [ %64, %62 ]
%12 = zext i32 %8 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = call i64 @memcmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %7
%17 = call i64 @memcmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %16, %7
br label %20
20: ; preds = %19, %16
%21 = phi i1 [ true, %19 ], [ false, %16 ]
%22 = call i64 @memcmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%23 = icmp eq i64 %22, 0
br i1 %23, label %29, label %24
24: ; preds = %20
%25 = call i64 @memcmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%26 = icmp eq i64 %25, 0
%27 = or i1 %26, %21
%28 = xor i1 %26, true
br i1 %27, label %29, label %88
29: ; preds = %24, %20
%30 = phi i1 [ %28, %24 ], [ false, %20 ]
%31 = add i64 %9, -512
%32 = icmp eq i64 %31, 0
br i1 %32, label %53, label %33
33: ; preds = %29, %49
%34 = phi i64 [ %51, %49 ], [ %31, %29 ]
%35 = phi i64 [ %50, %49 ], [ 512, %29 ]
%36 = add i64 %35, %12
%37 = getelementptr inbounds i8, i8* %0, i64 %36
%38 = call i64 @memcmp(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%39 = icmp eq i64 %38, 0
br i1 %39, label %53, label %40
40: ; preds = %33
%41 = call i64 @memcmp(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%42 = icmp eq i64 %41, 0
br i1 %42, label %53, label %43
43: ; preds = %40
%44 = call i64 @memcmp(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%45 = icmp eq i64 %44, 0
br i1 %45, label %53, label %46
46: ; preds = %43
%47 = call i64 @memcmp(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%48 = icmp eq i64 %47, 0
br i1 %48, label %53, label %49
49: ; preds = %46
%50 = add i64 %35, 512
%51 = add i64 %34, -512
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %33
53: ; preds = %49, %46, %43, %40, %33, %29
%54 = phi i64 [ 512, %29 ], [ %35, %33 ], [ %35, %40 ], [ %35, %43 ], [ %35, %46 ], [ %50, %49 ]
%55 = phi i64 [ 0, %29 ], [ %34, %33 ], [ %34, %40 ], [ %34, %43 ], [ %34, %46 ], [ 0, %49 ]
br i1 %30, label %56, label %59
56: ; preds = %53
%57 = add nsw i32 %10, 1
%58 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %2, i32 %10)
br label %62
59: ; preds = %53
%60 = add nsw i32 %11, 1
%61 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %2, i32 %11)
br label %62
62: ; preds = %59, %56
%63 = phi i32 [ %57, %56 ], [ %10, %59 ]
%64 = phi i32 [ %11, %56 ], [ %60, %59 ]
%65 = or i32 %8, 4
%66 = zext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %0, i64 %66
%68 = load i8, i8* %67
%69 = zext i8 %68 to i64
%70 = or i32 %8, 5
%71 = zext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %0, i64 %71
%73 = load i8, i8* %72
%74 = zext i8 %73 to i64
%75 = shl nuw nsw i64 %74, 8
%76 = or i64 %75, %69
%77 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %5, i32 %8, i64 %76)
%78 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%79 = load i32, i32* @SEEK_SET
%80 = call i32 @fseek(i32* %78, i32 %79, i32 0)
%81 = getelementptr inbounds i8, i8* %13, i64 16
%82 = add i64 %54, -16
%83 = call i32 @fwrite(i8* %81, i32 1, i64 %82, i32* %78)
%84 = call i32 @fclose(i32* %78)
%85 = trunc i64 %54 to i32
%86 = add i32 %8, %85
%87 = icmp ult i32 %86, %1
br i1 %87, label %7, label %88
88: ; preds = %24, %62
ret void
}