#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_END;
int /*<<< orphan*/ SEEK_SET;
int ab_strcmp(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, size_t, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
size_t ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, size_t, int /*<<< orphan*/ *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main(int argc, char **argv) {
  printf("memory patcher v1.0 by 1eht~rampnup-mirpec\n");
  printf("filename: ");
  char s_filename[8] = {};
  scanf("%s", s_filename);
  printf("reading..");
  char *Result = 0;
  FILE *File = fopen(s_filename, "rb");
  size_t FileSize = 0;
  if (File) {
    fseek(File, 0, SEEK_END);
    FileSize = ftell(File);
    fseek(File, 0, SEEK_SET);
    Result = (char *)malloc(FileSize + 1);
    fread(Result, FileSize, 1, File);
    Result[FileSize] = 0;
    fclose(File);
  }
  printf("done.\n");
  int s_inst, s_index, s_value;
  printf("query(hex): ");
  scanf("%x", &s_inst);
  int IsElf = ab_strcmp(Result + 1, "ELF");
  if (!IsElf) {
    printf("Invalid ELF file.\n");
    return 0;
  }
  int i;
  for (i = 0; i < FileSize - 3; i++) {
    if (((unsigned int)*(Result + i + 0) & 0xff) == s_inst) {
      int start = i;
      printf("(%04d) ", start);
      for (; i < start + 8; i++) {
        printf("%02x ", *(Result + i) & 0xff);
      }
      printf("\n");
    }
  }
  printf("set index: ");
  scanf("%d", &s_index);
  printf("to ");
  scanf("%d", &s_value);
  *(Result + s_index) = s_value;
  File = fopen("p", "wb");
  fwrite(Result, sizeof(char), FileSize, File);
  fclose(File);
  return 0;
}


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)
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1060 <memset@plt>
lea    -0x18(%rbp),%rsi
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   10a0 <scanf@plt>
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movq   $0x0,-0x20(%rbp)
lea    -0x18(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12b2 <main+0x102>
mov    -0x28(%rbp),%rdi
mov    0x2d9c(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x28(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    0x2d6b(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x30(%rbp),%rdi
add    $0x1,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rcx
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd86(%rip),%rdi
lea    -0x34(%rbp),%rsi
mov    $0x0,%al
call   10a0 <scanf@plt>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
lea    0xd6f(%rip),%rsi
call   10d0 <ab_strcmp@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jne    131b <main+0x16b>
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1455 <main+0x2a5>
movl   $0x0,-0x44(%rbp)
movslq -0x44(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    $0x3,%rcx
cmp    %rcx,%rax
jae    13c8 <main+0x218>
mov    -0x20(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
and    $0xff,%eax
cmp    -0x34(%rbp),%eax
jne    13b5 <main+0x205>
mov    -0x44(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%esi
lea    0xd14(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x44(%rbp),%eax
mov    -0x48(%rbp),%ecx
add    $0x8,%ecx
cmp    %ecx,%eax
jge    13a7 <main+0x1f7>
mov    -0x20(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
and    $0xff,%esi
lea    0xceb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1368 <main+0x1b8>
lea    0xcc5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    13ba <main+0x20a>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1322 <main+0x172>
lea    0xcb4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xcb2(%rip),%rdi
lea    -0x38(%rbp),%rsi
mov    $0x0,%al
call   10a0 <scanf@plt>
lea    0xca3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xc92(%rip),%rdi
lea    -0x3c(%rbp),%rsi
mov    $0x0,%al
call   10a0 <scanf@plt>
mov    -0x3c(%rbp),%eax
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
lea    0xc77(%rip),%rdi
lea    0xc72(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   10c0 <fwrite@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-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
lea    0xe80(%rip),%rdi
call   1040 <puts@plt>
lea    0xe1f(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1070 <printf@plt>
movq   $0x0,0x10(%rsp)
lea    0xe10(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   10b0 <scanf@plt>
lea    0xdfd(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdf9(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     128f <main+0xcf>
mov    %rax,%rbx
mov    0x2db2(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    %rbx,%rdi
call   1080 <ftell@plt>
mov    %rax,%r14
mov    0x2d84(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
lea    0x1(%r14),%rdi
call   1090 <malloc@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fread@plt>
movb   $0x0,0x0(%r13,%r14,1)
mov    %rbx,%rdi
call   1060 <fclose@plt>
jmp    1292 <main+0xd2>
xor    %r13d,%r13d
lea    0xde7(%rip),%rdi
call   1040 <puts@plt>
lea    0xd76(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd75(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   10b0 <scanf@plt>
lea    0x1(%r13),%rdi
lea    0xd61(%rip),%rsi
call   10e0 <ab_strcmp@plt>
test   %eax,%eax
je     143e <main+0x27e>
mov    %r14,%rbp
add    $0xfffffffffffffffd,%rbp
je     13bc <main+0x1fc>
lea    0xd44(%rip),%r15
lea    0xd45(%rip),%r12
xor    %eax,%eax
xor    %ebx,%ebx
jmp    130f <main+0x14f>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
movslq %ebx,%rax
cmp    %rax,%rbp
jbe    13bc <main+0x1fc>
movzbl 0x0(%r13,%rax,1),%eax
cmp    %eax,0xc(%rsp)
jne    1300 <main+0x140>
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
movslq %ebx,%rbx
movzbl 0x0(%r13,%rbx,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movzbl 0x1(%r13,%rbx,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movzbl 0x2(%r13,%rbx,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movzbl 0x3(%r13,%rbx,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movzbl 0x4(%r13,%rbx,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movzbl 0x5(%r13,%rbx,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movzbl 0x6(%r13,%rbx,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movzbl 0x7(%r13,%rbx,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x8,%ebx
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1300 <main+0x140>
lea    0xc7a(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xc78(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   10b0 <scanf@plt>
lea    0xc65(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   10b0 <scanf@plt>
mov    0x4(%rsp),%al
movslq 0x8(%rsp),%rcx
mov    %al,0x0(%r13,%rcx,1)
lea    0xc3e(%rip),%rdi
lea    0xc39(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%rbx
mov    %r13,%rdi
mov    $0x1,%esi
mov    %r14,%rdx
mov    %rax,%rcx
call   10d0 <fwrite@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
jmp    144a <main+0x28a>
lea    0xc41(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [44 x i8] c"memory patcher v1.0 by 1eht~rampnup-mirpec\0A\00"
@.str.1 = [11 x i8] c"filename: \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [10 x i8] c"reading..\00"
@.str.4 = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.5 = [7 x i8] c"done.\0A\00"
@.str.6 = [13 x i8] c"query(hex): \00"
@.str.7 = [3 x i8] c"%x\00"
@.str.8 = [4 x i8] c"ELF\00"
@.str.9 = [19 x i8] c"Invalid ELF file.\0A\00"
@.str.10 = [8 x i8] c"(%04d) \00"
@.str.11 = [6 x i8] c"%02x \00"
@.str.12 = [2 x i8] c"\0A\00"
@.str.13 = [12 x i8] c"set index: \00"
@.str.14 = [3 x i8] c"%d\00"
@.str.15 = [4 x i8] c"to \00"
@.str.16 = [2 x i8] c"p\00"
@.str.17 = [3 x i8] c"wb\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [8 x i8]
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%18 = bitcast [8 x i8]* %6 to i8*
%19 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
store i8* null, i8** %7
%22 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %23, i32** %8
store i64 0, i64* %9
%24 = load i32*, i32** %8
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %48
26: ; preds = %2
%27 = load i32*, i32** %8
%28 = load i32, i32* @SEEK_END
%29 = call i32 @fseek(i32* %27, i32 0, i32 %28)
%30 = load i32*, i32** %8
%31 = call i64 @ftell(i32* %30)
store i64 %31, i64* %9
%32 = load i32*, i32** %8
%33 = load i32, i32* @SEEK_SET
%34 = call i32 @fseek(i32* %32, i32 0, i32 %33)
%35 = load i64, i64* %9
%36 = add i64 %35, 1
%37 = call i64 @malloc(i64 %36)
%38 = inttoptr i64 %37 to i8*
store i8* %38, i8** %7
%39 = load i8*, i8** %7
%40 = load i64, i64* %9
%41 = load i32*, i32** %8
%42 = call i32 @fread(i8* %39, i64 %40, i32 1, i32* %41)
%43 = load i8*, i8** %7
%44 = load i64, i64* %9
%45 = getelementptr inbounds i8, i8* %43, i64 %44
store i8 0, i8* %45
%46 = load i32*, i32** %8
%47 = call i32 @fclose(i32* %46)
br label %48
48: ; preds = %26, %2
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%51 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %10)
%52 = load i8*, i8** %7
%53 = getelementptr inbounds i8, i8* %52, i64 1
%54 = call i32 @ab_strcmp(i8* %53, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
store i32 %54, i32* %13
%55 = load i32, i32* %13
%56 = icmp ne i32 %55, 0
br i1 %56, label %59, label %57
57: ; preds = %48
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %3
br label %122
59: ; preds = %48
store i32 0, i32* %14
br label %60
60: ; preds = %101, %59
%61 = load i32, i32* %14
%62 = sext i32 %61 to i64
%63 = load i64, i64* %9
%64 = sub i64 %63, 3
%65 = icmp ult i64 %62, %64
br i1 %65, label %66, label %104
66: ; preds = %60
%67 = load i8*, i8** %7
%68 = load i32, i32* %14
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %67, i64 %69
%71 = getelementptr inbounds i8, i8* %70, i64 0
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = and i32 %73, 255
%75 = load i32, i32* %10
%76 = icmp eq i32 %74, %75
br i1 %76, label %77, label %100
77: ; preds = %66
%78 = load i32, i32* %14
store i32 %78, i32* %15
%79 = load i32, i32* %15
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i32 %79)
br label %81
81: ; preds = %95, %77
%82 = load i32, i32* %14
%83 = load i32, i32* %15
%84 = add nsw i32 %83, 8
%85 = icmp slt i32 %82, %84
br i1 %85, label %86, label %98
86: ; preds = %81
%87 = load i8*, i8** %7
%88 = load i32, i32* %14
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8, i8* %87, i64 %89
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = and i32 %92, 255
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %93)
br label %95
95: ; preds = %86
%96 = load i32, i32* %14
%97 = add nsw i32 %96, 1
store i32 %97, i32* %14
br label %81
98: ; preds = %81
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
br label %100
100: ; preds = %98, %66
br label %101
101: ; preds = %100
%102 = load i32, i32* %14
%103 = add nsw i32 %102, 1
store i32 %103, i32* %14
br label %60
104: ; preds = %60
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
%106 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0), i32* %11)
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0))
%108 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0), i32* %12)
%109 = load i32, i32* %12
%110 = trunc i32 %109 to i8
%111 = load i8*, i8** %7
%112 = load i32, i32* %11
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds i8, i8* %111, i64 %113
store i8 %110, i8* %114
%115 = call i32* @fopen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0))
store i32* %115, i32** %8
%116 = load i8*, i8** %7
%117 = load i64, i64* %9
%118 = load i32*, i32** %8
%119 = call i32 @fwrite(i8* %116, i32 1, i64 %117, i32* %118)
%120 = load i32*, i32** %8
%121 = call i32 @fclose(i32* %120)
store i32 0, i32* %3
br label %122
122: ; preds = %104, %57
%123 = load i32, i32* %3
ret i32 %123
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"filename: \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [10 x i8] c"reading..\00"
@.str.4 = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.6 = [13 x i8] c"query(hex): \00"
@.str.7 = [3 x i8] c"%x\00"
@.str.8 = [4 x i8] c"ELF\00"
@.str.10 = [8 x i8] c"(%04d) \00"
@.str.11 = [6 x i8] c"%02x \00"
@.str.13 = [12 x i8] c"set index: \00"
@.str.14 = [3 x i8] c"%d\00"
@.str.15 = [4 x i8] c"to \00"
@.str.16 = [2 x i8] c"p\00"
@.str.17 = [3 x i8] c"wb\00"
@str = [43 x i8] c"memory patcher v1.0 by 1eht~rampnup-mirpec\00"
@str.18 = [6 x i8] c"done.\00"
@str.19 = [18 x i8] c"Invalid ELF file.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%9 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i64* %3)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %26, label %14
14: ; preds = %2
%15 = load i32, i32* @SEEK_END
%16 = call i32 @fseek(i32* %12, i32 0, i32 %15)
%17 = call i64 @ftell(i32* %12)
%18 = load i32, i32* @SEEK_SET
%19 = call i32 @fseek(i32* %12, i32 0, i32 %18)
%20 = add i64 %17, 1
%21 = call i64 @malloc(i64 %20)
%22 = inttoptr i64 %21 to i8*
%23 = call i32 @fread(i8* %22, i64 %17, i32 1, i32* %12)
%24 = getelementptr inbounds i8, i8* %22, i64 %17
store i8 0, i8* %24
%25 = call i32 @fclose(i32* %12)
br label %26
26: ; preds = %14, %2
%27 = phi i64 [ %17, %14 ], [ 0, %2 ]
%28 = phi i8* [ %22, %14 ], [ null, %2 ]
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.18, i64 0, i64 0))
%30 = bitcast i32* %4 to i8*
%31 = bitcast i32* %5 to i8*
%32 = bitcast i32* %6 to i8*
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %4)
%35 = getelementptr inbounds i8, i8* %28, i64 1
%36 = call i32 @ab_strcmp(i8* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%37 = icmp eq i32 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %26
%39 = add i64 %27, -3
%40 = icmp eq i64 %39, 0
br i1 %40, label %100, label %43
41: ; preds = %26
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.19, i64 0, i64 0))
br label %113
43: ; preds = %38, %95
%44 = phi i64 [ %98, %95 ], [ 0, %38 ]
%45 = phi i32 [ %97, %95 ], [ 0, %38 ]
%46 = getelementptr inbounds i8, i8* %28, i64 %44
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = load i32, i32* %4
%50 = icmp eq i32 %49, %48
br i1 %50, label %51, label %95
51: ; preds = %43
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i32 %45)
%53 = sext i32 %45 to i64
%54 = getelementptr inbounds i8, i8* %28, i64 %53
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %56)
%58 = add nsw i64 %53, 1
%59 = getelementptr inbounds i8, i8* %28, i64 %58
%60 = load i8, i8* %59
%61 = zext i8 %60 to i32
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %61)
%63 = add nsw i64 %53, 2
%64 = getelementptr inbounds i8, i8* %28, i64 %63
%65 = load i8, i8* %64
%66 = zext i8 %65 to i32
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %66)
%68 = add nsw i64 %53, 3
%69 = getelementptr inbounds i8, i8* %28, i64 %68
%70 = load i8, i8* %69
%71 = zext i8 %70 to i32
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %71)
%73 = add nsw i64 %53, 4
%74 = getelementptr inbounds i8, i8* %28, i64 %73
%75 = load i8, i8* %74
%76 = zext i8 %75 to i32
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %76)
%78 = add nsw i64 %53, 5
%79 = getelementptr inbounds i8, i8* %28, i64 %78
%80 = load i8, i8* %79
%81 = zext i8 %80 to i32
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %81)
%83 = add nsw i64 %53, 6
%84 = getelementptr inbounds i8, i8* %28, i64 %83
%85 = load i8, i8* %84
%86 = zext i8 %85 to i32
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %86)
%88 = add nsw i64 %53, 7
%89 = getelementptr inbounds i8, i8* %28, i64 %88
%90 = load i8, i8* %89
%91 = zext i8 %90 to i32
%92 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %91)
%93 = add i32 %45, 8
%94 = call i32 @putchar(i32 10)
br label %95
95: ; preds = %43, %51
%96 = phi i32 [ %93, %51 ], [ %45, %43 ]
%97 = add nsw i32 %96, 1
%98 = sext i32 %97 to i64
%99 = icmp ugt i64 %39, %98
br i1 %99, label %43, label %100
100: ; preds = %95, %38
%101 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
%102 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0), i32* %5)
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0))
%104 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0), i32* %6)
%105 = load i32, i32* %6
%106 = trunc i32 %105 to i8
%107 = load i32, i32* %5
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i8, i8* %28, i64 %108
store i8 %106, i8* %109
%110 = call i32* @fopen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0))
%111 = call i32 @fwrite(i8* %28, i32 1, i64 %27, i32* %110)
%112 = call i32 @fclose(i32* %110)
br label %113
113: ; preds = %100, %41
ret i32 0
}