#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*/ outfn;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ fputc(char, int /*<<< orphan*/ *);
size_t fread(char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, char const *);
int writeoutput(const char *fn, FILE *ppm, int X, int Y, int bpp) {
  FILE *outf[] = {NULL, NULL, NULL};
  int i, x, y = 0;
  char outfn[256];
  static const char *exts[3] = {"red", "grn", "blu"};
  char *image_line = NULL;
  int ok = 0;
  for (i = 0; i < 3; ++i) {
    snprintf(outfn, sizeof(outfn), "%s.%s.pgm", fn, exts[i]);
    outf[i] = fopen(outfn, "wb");
    if (!outf[i])
      goto cleanup;
    fprintf(outf[i], "P5\n");
    fprintf(outf[i], "%d %d\n", X, Y);
    fprintf(outf[i], "%d\n", bpp);
  }
  image_line = (char *)malloc((size_t)X * 3 * sizeof(char));
  if (!image_line)
    goto cleanup;
  while (fread(image_line, sizeof(char), (size_t)X * 3, ppm) == (size_t)X * 3) {
    for (x = 0; x < X; ++x)
      for (i = 0; i < 3; ++i)
        if (fputc(image_line[3 * x + i], outf[i]) == EOF)
          goto cleanup;
    ++y;
  }
  if (y == Y)
    ok = 1;
cleanup:
  free(image_line);
  for (i = 0; i < 3; ++i)
    if (outf[i])
      fclose(outf[i]);
  return ok;
}


x86 assembly (clang, -O0):
<writeoutput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1070 <memset@plt>
movl   $0x0,-0x4c(%rbp)
movq   $0x0,-0x158(%rbp)
movl   $0x0,-0x15c(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x3,-0x44(%rbp)
jge    12a5 <writeoutput+0x115>
lea    -0x150(%rbp),%rdi
mov    -0x8(%rbp),%rcx
movslq -0x44(%rbp),%rdx
lea    0x2e70(%rip),%rax
mov    (%rax,%rdx,8),%r8
mov    $0x100,%esi
lea    0xdfc(%rip),%rdx
call   1060 <snprintf@plt>
lea    -0x150(%rbp),%rdi
lea    0xdf3(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rcx
movslq -0x44(%rbp),%rax
mov    %rcx,-0x40(%rbp,%rax,8)
movslq -0x44(%rbp),%rax
cmpq   $0x0,-0x40(%rbp,%rax,8)
jne    1249 <writeoutput+0xb9>
jmp    13b0 <writeoutput+0x220>
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
lea    0xdc0(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xda7(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
mov    -0x1c(%rbp),%edx
lea    0xd90(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11e0 <writeoutput+0x50>
movslq -0x14(%rbp),%rax
imul   $0x3,%rax,%rdi
shl    $0x0,%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x158(%rbp)
cmpq   $0x0,-0x158(%rbp)
jne    12d0 <writeoutput+0x140>
jmp    13b0 <writeoutput+0x220>
jmp    12d5 <writeoutput+0x145>
mov    -0x158(%rbp),%rdi
movslq -0x14(%rbp),%rax
imul   $0x3,%rax,%rdx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
movslq -0x14(%rbp),%rcx
imul   $0x3,%rcx,%rcx
cmp    %rcx,%rax
jne    1395 <writeoutput+0x205>
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1387 <writeoutput+0x1f7>
movl   $0x0,-0x44(%rbp)
cmpl   $0x3,-0x44(%rbp)
jge    1374 <writeoutput+0x1e4>
mov    -0x158(%rbp),%rax
imul   $0x3,-0x48(%rbp),%ecx
add    -0x44(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
movslq -0x44(%rbp),%rcx
mov    -0x40(%rbp,%rcx,8),%rsi
movsbl %al,%edi
call   1080 <fputc@plt>
mov    0x2c95(%rip),%rcx
cmp    (%rcx),%rax
jne    1361 <writeoutput+0x1d1>
jmp    13b0 <writeoutput+0x220>
jmp    1366 <writeoutput+0x1d6>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    131d <writeoutput+0x18d>
jmp    1379 <writeoutput+0x1e9>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    130a <writeoutput+0x17a>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    12d5 <writeoutput+0x145>
mov    -0x4c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    13ab <writeoutput+0x21b>
movl   $0x1,-0x15c(%rbp)
jmp    13b0 <writeoutput+0x220>
mov    -0x158(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x3,-0x44(%rbp)
jge    13fe <writeoutput+0x26e>
movslq -0x44(%rbp),%rax
cmpq   $0x0,-0x40(%rbp,%rax,8)
je     13eb <writeoutput+0x25b>
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
call   1050 <fclose@plt>
jmp    13f0 <writeoutput+0x260>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    13c3 <writeoutput+0x233>
mov    -0x15c(%rbp),%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeoutput>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x138,%rsp
mov    %r8d,0x8(%rsp)
mov    %ecx,0x4(%rsp)
mov    %edx,%r13d
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xe52(%rip),%rdx
lea    0xe3f(%rip),%r8
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x100,%esi
mov    %r15,%rcx
call   1060 <snprintf@plt>
lea    0xe39(%rip),%rsi
mov    %rbp,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     145d <writeoutput+0x2cd>
mov    %rax,%r12
mov    %rbx,0x18(%rsp)
lea    0xe1c(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10b0 <fwrite@plt>
lea    0xe07(%rip),%rsi
xor    %r14d,%r14d
mov    %r12,%rdi
mov    %r13d,%edx
mov    0x4(%rsp),%ecx
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0xdef(%rip),%rsi
mov    %r12,%rdi
mov    0x8(%rsp),%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0xdc6(%rip),%rdx
lea    0xdb7(%rip),%r8
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x100,%esi
mov    %r15,%rcx
call   1060 <snprintf@plt>
lea    0xdad(%rip),%rsi
mov    %rbp,%rdi
call   10a0 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1469 <writeoutput+0x2d9>
lea    0xd95(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
lea    0xd80(%rip),%rsi
mov    %rbx,%rdi
mov    %r13d,(%rsp)
mov    %r13d,%edx
mov    0x4(%rsp),%r13d
mov    %r13d,%ecx
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0xd63(%rip),%rsi
mov    %rbx,0x10(%rsp)
mov    %rbx,%rdi
mov    0x8(%rsp),%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0xd35(%rip),%rdx
lea    0xd2a(%rip),%r8
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x100,%esi
mov    %r15,%rcx
call   1060 <snprintf@plt>
lea    0xd1c(%rip),%rsi
mov    %rbp,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1471 <writeoutput+0x2e1>
mov    %rax,%r15
lea    0xd04(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10b0 <fwrite@plt>
lea    0xcef(%rip),%rsi
mov    %r15,%rdi
mov    (%rsp),%ebp
mov    %ebp,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0xcd9(%rip),%rsi
mov    %r15,%rdi
mov    0x8(%rsp),%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
movslq %ebp,%rax
lea    (%rax,%rax,2),%rbp
mov    %rbp,%rdi
call   1090 <malloc@plt>
test   %rax,%rax
je     1474 <writeoutput+0x2e4>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1,%esi
mov    %rbp,%rdx
mov    0x18(%rsp),%rcx
call   1040 <fread@plt>
mov    %rbp,0x20(%rsp)
cmp    %rbp,%rax
mov    $0x0,%ebp
mov    0x10(%rsp),%r13
jne    1443 <writeoutput+0x2b3>
mov    (%rsp),%eax
lea    (%rax,%rax,2),%rax
mov    %rax,0x8(%rsp)
xor    %ebp,%ebp
mov    %rbp,0x28(%rsp)
cmpl   $0x0,(%rsp)
jle    1418 <writeoutput+0x288>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movsbl (%rbx,%rbp,1),%edi
mov    %r12,%rsi
call   1070 <fputc@plt>
xor    %r14d,%r14d
mov    0x2c12(%rip),%rcx
cmp    (%rcx),%rax
je     144e <writeoutput+0x2be>
movsbl 0x1(%rbx,%rbp,1),%edi
mov    %r13,%rsi
call   1070 <fputc@plt>
mov    0x2bf9(%rip),%rcx
cmp    (%rcx),%rax
je     144e <writeoutput+0x2be>
movsbl 0x2(%rbx,%rbp,1),%edi
mov    %r15,%rsi
call   1070 <fputc@plt>
mov    0x2be0(%rip),%rcx
cmp    (%rcx),%rax
je     144e <writeoutput+0x2be>
add    $0x3,%rbp
cmp    %rbp,0x8(%rsp)
jne    13c0 <writeoutput+0x230>
mov    0x28(%rsp),%rbp
add    $0x1,%ebp
mov    %rbx,%rdi
mov    $0x1,%esi
mov    0x20(%rsp),%r14
mov    %r14,%rdx
mov    0x18(%rsp),%rcx
call   1040 <fread@plt>
cmp    %r14,%rax
je     13ab <writeoutput+0x21b>
xor    %r14d,%r14d
cmp    0x4(%rsp),%ebp
sete   %r14b
mov    %rbx,%rdi
call   1030 <free@plt>
test   %r12,%r12
jne    1480 <writeoutput+0x2f0>
jmp    1488 <writeoutput+0x2f8>
xor    %r14d,%r14d
xor    %edi,%edi
call   1030 <free@plt>
jmp    14a2 <writeoutput+0x312>
xor    %r15d,%r15d
mov    %rbx,%r13
jmp    1479 <writeoutput+0x2e9>
xor    %r15d,%r15d
mov    0x10(%rsp),%r13
xor    %edi,%edi
call   1030 <free@plt>
mov    %r12,%rdi
call   1050 <fclose@plt>
test   %r13,%r13
je     1495 <writeoutput+0x305>
mov    %r13,%rdi
call   1050 <fclose@plt>
test   %r15,%r15
je     14a2 <writeoutput+0x312>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    %r14d,%eax
add    $0x138,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@writeoutput.exts = internal global [3 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0)]
@.str = [4 x i8] c"red\00"
@.str.1 = [4 x i8] c"grn\00"
@.str.2 = [4 x i8] c"blu\00"
@.str.3 = [10 x i8] c"%s.%s.pgm\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [4 x i8] c"P5\0A\00"
@.str.6 = [7 x i8] c"%d %d\0A\00"
@.str.7 = [4 x i8] c"%d\0A\00"
@EOF = global i64 0
define i32 @writeoutput(i8* %0, i32* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [3 x i32*]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca [256 x i8]
%16 = alloca i8*
%17 = alloca i32
store i8* %0, i8** %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%18 = bitcast [3 x i32*]* %11 to i8*
store i32 0, i32* %14
store i8* null, i8** %16
store i32 0, i32* %17
store i32 0, i32* %12
br label %19
19: ; preds = %60, %5
%20 = load i32, i32* %12
%21 = icmp slt i32 %20, 3
br i1 %21, label %22, label %63
22: ; preds = %19
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%24 = load i8*, i8** %6
%25 = load i32, i32* %12
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [3 x i8*], [3 x i8*]* @writeoutput.exts, i64 0, i64 %26
%28 = load i8*, i8** %27
%29 = call i32 @snprintf(i8* %23, i32 256, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %24, i8* %28)
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%32 = load i32, i32* %12
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [3 x i32*], [3 x i32*]* %11, i64 0, i64 %33
store i32* %31, i32** %34
%35 = load i32, i32* %12
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [3 x i32*], [3 x i32*]* %11, i64 0, i64 %36
%38 = load i32*, i32** %37
%39 = icmp ne i32* %38, null
br i1 %39, label %41, label %40
40: ; preds = %22
br label %128
41: ; preds = %22
%42 = load i32, i32* %12
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [3 x i32*], [3 x i32*]* %11, i64 0, i64 %43
%45 = load i32*, i32** %44
%46 = call i32 (i32*, i8*, ...) @fprintf(i32* %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%47 = load i32, i32* %12
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [3 x i32*], [3 x i32*]* %11, i64 0, i64 %48
%50 = load i32*, i32** %49
%51 = load i32, i32* %8
%52 = load i32, i32* %9
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %50, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %51, i32 %52)
%54 = load i32, i32* %12
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [3 x i32*], [3 x i32*]* %11, i64 0, i64 %55
%57 = load i32*, i32** %56
%58 = load i32, i32* %10
%59 = call i32 (i32*, i8*, ...) @fprintf(i32* %57, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %58)
br label %60
60: ; preds = %41
%61 = load i32, i32* %12
%62 = add nsw i32 %61, 1
store i32 %62, i32* %12
br label %19
63: ; preds = %19
%64 = load i32, i32* %8
%65 = sext i32 %64 to i64
%66 = mul i64 %65, 3
%67 = mul i64 %66, 1
%68 = call i64 @malloc(i64 %67)
%69 = inttoptr i64 %68 to i8*
store i8* %69, i8** %16
%70 = load i8*, i8** %16
%71 = icmp ne i8* %70, null
br i1 %71, label %73, label %72
72: ; preds = %63
br label %128
73: ; preds = %63
br label %74
74: ; preds = %119, %73
%75 = load i8*, i8** %16
%76 = load i32, i32* %8
%77 = sext i32 %76 to i64
%78 = mul i64 %77, 3
%79 = load i32*, i32** %7
%80 = call i64 @fread(i8* %75, i32 1, i64 %78, i32* %79)
%81 = load i32, i32* %8
%82 = sext i32 %81 to i64
%83 = mul i64 %82, 3
%84 = icmp eq i64 %80, %83
br i1 %84, label %85, label %122
85: ; preds = %74
store i32 0, i32* %13
br label %86
86: ; preds = %116, %85
%87 = load i32, i32* %13
%88 = load i32, i32* %8
%89 = icmp slt i32 %87, %88
br i1 %89, label %90, label %119
90: ; preds = %86
store i32 0, i32* %12
br label %91
91: ; preds = %112, %90
%92 = load i32, i32* %12
%93 = icmp slt i32 %92, 3
br i1 %93, label %94, label %115
94: ; preds = %91
%95 = load i8*, i8** %16
%96 = load i32, i32* %13
%97 = mul nsw i32 3, %96
%98 = load i32, i32* %12
%99 = add nsw i32 %97, %98
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i8, i8* %95, i64 %100
%102 = load i8, i8* %101
%103 = load i32, i32* %12
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds [3 x i32*], [3 x i32*]* %11, i64 0, i64 %104
%106 = load i32*, i32** %105
%107 = call i64 @fputc(i8 signext %102, i32* %106)
%108 = load i64, i64* @EOF
%109 = icmp eq i64 %107, %108
br i1 %109, label %110, label %111
110: ; preds = %94
br label %128
111: ; preds = %94
br label %112
112: ; preds = %111
%113 = load i32, i32* %12
%114 = add nsw i32 %113, 1
store i32 %114, i32* %12
br label %91
115: ; preds = %91
br label %116
116: ; preds = %115
%117 = load i32, i32* %13
%118 = add nsw i32 %117, 1
store i32 %118, i32* %13
br label %86
119: ; preds = %86
%120 = load i32, i32* %14
%121 = add nsw i32 %120, 1
store i32 %121, i32* %14
br label %74
122: ; preds = %74
%123 = load i32, i32* %14
%124 = load i32, i32* %9
%125 = icmp eq i32 %123, %124
br i1 %125, label %126, label %127
126: ; preds = %122
store i32 1, i32* %17
br label %127
127: ; preds = %126, %122
br label %128
128: ; preds = %127, %110, %72, %40
%129 = load i8*, i8** %16
%130 = call i32 @free(i8* %129)
store i32 0, i32* %12
br label %131
131: ; preds = %147, %128
%132 = load i32, i32* %12
%133 = icmp slt i32 %132, 3
br i1 %133, label %134, label %150
134: ; preds = %131
%135 = load i32, i32* %12
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds [3 x i32*], [3 x i32*]* %11, i64 0, i64 %136
%138 = load i32*, i32** %137
%139 = icmp ne i32* %138, null
br i1 %139, label %140, label %146
140: ; preds = %134
%141 = load i32, i32* %12
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds [3 x i32*], [3 x i32*]* %11, i64 0, i64 %142
%144 = load i32*, i32** %143
%145 = call i32 @fclose(i32* %144)
br label %146
146: ; preds = %140, %134
br label %147
147: ; preds = %146
%148 = load i32, i32* %12
%149 = add nsw i32 %148, 1
store i32 %149, i32* %12
br label %131
150: ; preds = %131
%151 = load i32, i32* %17
ret i32 %151
}

LLVM IR (-O2):
@.str = [4 x i8] c"red\00"
@.str.1 = [4 x i8] c"grn\00"
@.str.2 = [4 x i8] c"blu\00"
@.str.3 = [10 x i8] c"%s.%s.pgm\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [4 x i8] c"P5\0A\00"
@.str.6 = [7 x i8] c"%d %d\0A\00"
@.str.7 = [4 x i8] c"%d\0A\00"
@EOF = global i64 0
define i32 @writeoutput(i8* %0, i32* nocapture %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca [256 x i8]
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%8 = call i32 @snprintf(i8* %7, i32 256, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%9 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %5
%12 = call i32 @free(i8* null)
br label %97
13: ; preds = %5
%14 = call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 3, i64 1, i32* %9)
%15 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %2, i32 %3)
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %4)
%17 = call i32 @snprintf(i8* %7, i32 256, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %77, label %20
20: ; preds = %13
%21 = call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 3, i64 1, i32* %18)
%22 = call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %2, i32 %3)
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %4)
%24 = call i32 @snprintf(i8* %7, i32 256, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%26 = icmp eq i32* %25, null
br i1 %26, label %77, label %27
27: ; preds = %20
%28 = call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 3, i64 1, i32* %25)
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %2, i32 %3)
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %4)
%31 = sext i32 %2 to i64
%32 = mul nsw i64 %31, 3
%33 = call i64 @malloc(i64 %32)
%34 = inttoptr i64 %33 to i8*
%35 = icmp eq i64 %33, 0
br i1 %35, label %77, label %36
36: ; preds = %27
%37 = call i64 @fread(i8* %34, i32 1, i64 %32, i32* %1)
%38 = icmp eq i64 %37, %32
br i1 %38, label %39, label %73
39: ; preds = %36
%40 = icmp sgt i32 %2, 0
%41 = zext i32 %2 to i64
br label %42
42: ; preds = %39, %69
%43 = phi i32 [ 0, %39 ], [ %70, %69 ]
br i1 %40, label %44, label %69
44: ; preds = %42, %66
%45 = phi i64 [ %67, %66 ], [ 0, %42 ]
%46 = mul nuw nsw i64 %45, 3
%47 = getelementptr inbounds i8, i8* %34, i64 %46
%48 = load i8, i8* %47
%49 = call i64 @fputc(i8 signext %48, i32* %9)
%50 = load i64, i64* @EOF
%51 = icmp eq i64 %49, %50
br i1 %51, label %80, label %52
52: ; preds = %44
%53 = add nuw nsw i64 %46, 1
%54 = getelementptr inbounds i8, i8* %34, i64 %53
%55 = load i8, i8* %54
%56 = call i64 @fputc(i8 signext %55, i32* %18)
%57 = load i64, i64* @EOF
%58 = icmp eq i64 %56, %57
br i1 %58, label %80, label %59
59: ; preds = %52
%60 = add nuw nsw i64 %46, 2
%61 = getelementptr inbounds i8, i8* %34, i64 %60
%62 = load i8, i8* %61
%63 = call i64 @fputc(i8 signext %62, i32* %25)
%64 = load i64, i64* @EOF
%65 = icmp eq i64 %63, %64
br i1 %65, label %80, label %66
66: ; preds = %59
%67 = add nuw nsw i64 %45, 1
%68 = icmp eq i64 %67, %41
br i1 %68, label %69, label %44
69: ; preds = %66, %42
%70 = add nuw nsw i32 %43, 1
%71 = call i64 @fread(i8* %34, i32 1, i64 %32, i32* %1)
%72 = icmp eq i64 %71, %32
br i1 %72, label %42, label %73
73: ; preds = %69, %36
%74 = phi i32 [ 0, %36 ], [ %70, %69 ]
%75 = icmp eq i32 %74, %3
%76 = zext i1 %75 to i32
br label %80
77: ; preds = %13, %20, %27
%78 = phi i32* [ null, %13 ], [ null, %20 ], [ %25, %27 ]
%79 = call i32 @free(i8* null)
br label %83
80: ; preds = %44, %52, %59, %73
%81 = phi i32 [ %76, %73 ], [ 0, %59 ], [ 0, %52 ], [ 0, %44 ]
%82 = call i32 @free(i8* %34)
br i1 %10, label %87, label %83
83: ; preds = %77, %80
%84 = phi i32 [ 0, %77 ], [ %81, %80 ]
%85 = phi i32* [ %78, %77 ], [ %25, %80 ]
%86 = call i32 @fclose(i32* %9)
br label %87
87: ; preds = %80, %83
%88 = phi i32 [ %81, %80 ], [ %84, %83 ]
%89 = phi i32* [ %25, %80 ], [ %85, %83 ]
%90 = icmp eq i32* %18, null
br i1 %90, label %93, label %91
91: ; preds = %87
%92 = call i32 @fclose(i32* %18)
br label %93
93: ; preds = %91, %87
%94 = icmp eq i32* %89, null
br i1 %94, label %97, label %95
95: ; preds = %93
%96 = call i32 @fclose(i32* %89)
br label %97
97: ; preds = %11, %95, %93
%98 = phi i32 [ 0, %11 ], [ %88, %95 ], [ %88, %93 ]
ret i32 %98
}