#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int);
int /*<<< orphan*/ fread(unsigned char **, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(unsigned char **, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ system(char *);
int main() {
  unsigned char image[256][256];
  unsigned char image_w[256][256];
  int histgram[256];
  FILE *fp;
  fp = fopen("girldark.dat", "rb");
  fread(image, sizeof(unsigned char), 256 * 256, fp);
  fclose(fp);
  int lMin = 255;
  int lMax = 0;
  for (int i = 0; i < 256; i++) {
    for (int j = 0; j < 256; j++) {
      histgram[image[i][j]]++;
      if (image[i][j] > lMax) {
        lMax = image[i][j];
      }
      if (image[i][j] < lMin) {
        lMin = image[i][j];
      }
    }
  }
  int newhist[256];
  for (int i = 0; i < 256; i++) {
    for (int j = 0; j < 256; j++) {
      int d =
          (float)(255 - 0) / (float)(lMax - lMin) * (int)(image[i][j] - lMin);
      if (d > 255) {
        image_w[i][j] = 255;
        newhist[255]++;
      } else if (d < 0) {
        image_w[i][j] = 0;
        newhist[0]++;
      } else {
        image_w[i][j] = (unsigned char)d;
        newhist[d]++;
      }
    }
  }
  fp = fopen("plot_ex2-2.dat", "wb");
  for (int i = 0; i < 256; i++) {
    fprintf(fp, "%3d %3d\n", i, newhist[i]);
  }
  fclose(fp);
  fp = fopen("girldark_ex2-2.dat", "wb");
  fwrite(image_w, sizeof(unsigned char), 256 * 256, fp);
  fclose(fp);
  system("zsh ex2-2.sh");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20840,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8b(%rip),%rdi
lea    0xe91(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20418(%rbp)
lea    -0x10010(%rbp),%rdi
mov    -0x20418(%rbp),%rcx
mov    $0x1,%esi
mov    $0x10000,%edx
call   1030 <fread@plt>
mov    -0x20418(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0xff,-0x2041c(%rbp)
movl   $0x0,-0x20420(%rbp)
movl   $0x0,-0x20424(%rbp)
cmpl   $0x100,-0x20424(%rbp)
jge    1304 <main+0x1a4>
movl   $0x0,-0x20428(%rbp)
cmpl   $0x100,-0x20428(%rbp)
jge    12eb <main+0x18b>
movslq -0x20424(%rbp),%rcx
lea    -0x10010(%rbp),%rax
shl    $0x8,%rcx
add    %rcx,%rax
movslq -0x20428(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x20410(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x20410(%rbp,%rax,4)
movslq -0x20424(%rbp),%rcx
lea    -0x10010(%rbp),%rax
shl    $0x8,%rcx
add    %rcx,%rax
movslq -0x20428(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    -0x20420(%rbp),%eax
jle    1280 <main+0x120>
movslq -0x20424(%rbp),%rcx
lea    -0x10010(%rbp),%rax
shl    $0x8,%rcx
add    %rcx,%rax
movslq -0x20428(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x20420(%rbp)
movslq -0x20424(%rbp),%rcx
lea    -0x10010(%rbp),%rax
shl    $0x8,%rcx
add    %rcx,%rax
movslq -0x20428(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    -0x2041c(%rbp),%eax
jge    12d2 <main+0x172>
movslq -0x20424(%rbp),%rcx
lea    -0x10010(%rbp),%rax
shl    $0x8,%rcx
add    %rcx,%rax
movslq -0x20428(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x2041c(%rbp)
jmp    12d7 <main+0x177>
mov    -0x20428(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20428(%rbp)
jmp    11ed <main+0x8d>
jmp    12f0 <main+0x190>
mov    -0x20424(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20424(%rbp)
jmp    11d3 <main+0x73>
movl   $0x0,-0x20834(%rbp)
cmpl   $0x100,-0x20834(%rbp)
jge    1487 <main+0x327>
movl   $0x0,-0x20838(%rbp)
cmpl   $0x100,-0x20838(%rbp)
jge    146e <main+0x30e>
mov    -0x20420(%rbp),%eax
sub    -0x2041c(%rbp),%eax
cvtsi2ss %eax,%xmm1
movss  0xcb0(%rip),%xmm0
divss  %xmm1,%xmm0
movslq -0x20834(%rbp),%rcx
lea    -0x10010(%rbp),%rax
shl    $0x8,%rcx
add    %rcx,%rax
movslq -0x20838(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
sub    -0x2041c(%rbp),%eax
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x2083c(%rbp)
cmpl   $0xff,-0x2083c(%rbp)
jle    13d0 <main+0x270>
movslq -0x20834(%rbp),%rcx
lea    -0x20010(%rbp),%rax
shl    $0x8,%rcx
add    %rcx,%rax
movslq -0x20838(%rbp),%rcx
movb   $0xff,(%rax,%rcx,1)
mov    -0x20434(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20434(%rbp)
jmp    1455 <main+0x2f5>
cmpl   $0x0,-0x2083c(%rbp)
jge    1411 <main+0x2b1>
movslq -0x20834(%rbp),%rcx
lea    -0x20010(%rbp),%rax
shl    $0x8,%rcx
add    %rcx,%rax
movslq -0x20838(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20830(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20830(%rbp)
jmp    1450 <main+0x2f0>
mov    -0x2083c(%rbp),%eax
mov    %al,%dl
movslq -0x20834(%rbp),%rcx
lea    -0x20010(%rbp),%rax
shl    $0x8,%rcx
add    %rcx,%rax
movslq -0x20838(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
movslq -0x2083c(%rbp),%rax
mov    -0x20830(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x20830(%rbp,%rax,4)
jmp    1455 <main+0x2f5>
jmp    145a <main+0x2fa>
mov    -0x20838(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20838(%rbp)
jmp    1328 <main+0x1c8>
jmp    1473 <main+0x313>
mov    -0x20834(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20834(%rbp)
jmp    130e <main+0x1ae>
lea    0xb86(%rip),%rdi
lea    0xb8e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20418(%rbp)
movl   $0x0,-0x20840(%rbp)
cmpl   $0x100,-0x20840(%rbp)
jge    14f6 <main+0x396>
mov    -0x20418(%rbp),%rdi
mov    -0x20840(%rbp),%edx
movslq -0x20840(%rbp),%rax
mov    -0x20830(%rbp,%rax,4),%ecx
lea    0xb49(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x20840(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20840(%rbp)
jmp    14ab <main+0x34b>
mov    -0x20418(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xb26(%rip),%rdi
lea    0xb13(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20418(%rbp)
lea    -0x20010(%rbp),%rdi
mov    -0x20418(%rbp),%rcx
mov    $0x1,%esi
mov    $0x10000,%edx
call   1080 <fwrite@plt>
mov    -0x20418(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xaf6(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0x20840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20800,%rsp
lea    0xe91(%rip),%rdi
lea    0xe97(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
lea    0x10800(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x10000,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
lea    0x10801(%rsp),%rcx
mov    $0xff,%eax
xor    %r8d,%r8d
xor    %esi,%esi
nopl   0x0(%rax)
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl -0x1(%rcx,%rdi,1),%edx
addl   $0x1,0x400(%rsp,%rdx,4)
01
cmp    %edx,%esi
cmovb  %edx,%esi
cmp    %edx,%eax
cmovg  %edx,%eax
movzbl (%rcx,%rdi,1),%edx
addl   $0x1,0x400(%rsp,%rdx,4)
01
cmp    %edx,%esi
cmovb  %edx,%esi
cmp    %edx,%eax
cmovg  %edx,%eax
add    $0x2,%rdi
cmp    $0x100,%rdi
jne    11d0 <main+0x70>
add    $0x1,%r8
add    $0x100,%rcx
cmp    $0x100,%r8
jne    11c0 <main+0x60>
sub    %eax,%esi
cvtsi2ss %esi,%xmm1
movss  0xdd4(%rip),%xmm0
divss  %xmm1,%xmm0
lea    0x800(%rsp),%rcx
xor    %edx,%edx
jmp    125b <main+0xfb>
nopl   0x0(%rax)
add    $0x1,%rdx
add    $0x100,%rbx
add    $0x100,%rcx
cmp    $0x100,%rdx
je     12b0 <main+0x150>
xor    %esi,%esi
jmp    1279 <main+0x119>
nop
movb   $0xff,(%rcx,%rsi,1)
addl   $0x1,0x3fc(%rsp)
01
add    $0x1,%rsi
cmp    $0x100,%rsi
je     1240 <main+0xe0>
movzbl (%rbx,%rsi,1),%edi
sub    %eax,%edi
xorps  %xmm1,%xmm1
cvtsi2ss %edi,%xmm1
mulss  %xmm0,%xmm1
cvttss2si %xmm1,%edi
cmp    $0x100,%edi
jge    1260 <main+0x100>
test   %edi,%edi
js     12a6 <main+0x146>
mov    %dil,(%rcx,%rsi,1)
mov    %edi,%edi
addl   $0x1,(%rsp,%rdi,4)
jmp    126c <main+0x10c>
movb   $0x0,(%rcx,%rsi,1)
addl   $0x1,(%rsp)
jmp    126c <main+0x10c>
lea    0xd5d(%rip),%rdi
lea    0xd65(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
xor    %ebx,%ebx
lea    0xd57(%rip),%r15
nop
mov    (%rsp,%rbx,4),%ecx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1060 <fprintf@plt>
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    12d0 <main+0x170>
mov    %r14,%rdi
call   1040 <fclose@plt>
lea    0xd33(%rip),%rdi
lea    0xd20(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0x800(%rsp),%rdi
mov    $0x1,%esi
mov    $0x10000,%edx
mov    %rax,%rcx
call   1080 <fwrite@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xd0e(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0x20800,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"girldark.dat\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [15 x i8] c"plot_ex2-2.dat\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [9 x i8] c"%3d %3d\0A\00"
@.str.5 = [19 x i8] c"girldark_ex2-2.dat\00"
@.str.6 = [13 x i8] c"zsh ex2-2.sh\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x [256 x i8]]
%3 = alloca [256 x [256 x i8]]
%4 = alloca [256 x i32]
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [256 x i32]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %1
%15 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %15, i32** %5
%16 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %2, i64 0, i64 0
%17 = bitcast [256 x i8]* %16 to i8**
%18 = load i32*, i32** %5
%19 = call i32 @fread(i8** %17, i32 1, i32 65536, i32* %18)
%20 = load i32*, i32** %5
%21 = call i32 @fclose(i32* %20)
store i32 255, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
br label %22
22: ; preds = %85, %0
%23 = load i32, i32* %8
%24 = icmp slt i32 %23, 256
br i1 %24, label %25, label %88
25: ; preds = %22
store i32 0, i32* %9
br label %26
26: ; preds = %81, %25
%27 = load i32, i32* %9
%28 = icmp slt i32 %27, 256
br i1 %28, label %29, label %84
29: ; preds = %26
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %2, i64 0, i64 %31
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %32, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = zext i8 %36 to i64
%38 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = add nsw i32 %39, 1
store i32 %40, i32* %38
%41 = load i32, i32* %8
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %2, i64 0, i64 %42
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %43, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = load i32, i32* %7
%50 = icmp sgt i32 %48, %49
br i1 %50, label %51, label %60
51: ; preds = %29
%52 = load i32, i32* %8
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %2, i64 0, i64 %53
%55 = load i32, i32* %9
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [256 x i8], [256 x i8]* %54, i64 0, i64 %56
%58 = load i8, i8* %57
%59 = zext i8 %58 to i32
store i32 %59, i32* %7
br label %60
60: ; preds = %51, %29
%61 = load i32, i32* %8
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %2, i64 0, i64 %62
%64 = load i32, i32* %9
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [256 x i8], [256 x i8]* %63, i64 0, i64 %65
%67 = load i8, i8* %66
%68 = zext i8 %67 to i32
%69 = load i32, i32* %6
%70 = icmp slt i32 %68, %69
br i1 %70, label %71, label %80
71: ; preds = %60
%72 = load i32, i32* %8
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %2, i64 0, i64 %73
%75 = load i32, i32* %9
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [256 x i8], [256 x i8]* %74, i64 0, i64 %76
%78 = load i8, i8* %77
%79 = zext i8 %78 to i32
store i32 %79, i32* %6
br label %80
80: ; preds = %71, %60
br label %81
81: ; preds = %80
%82 = load i32, i32* %9
%83 = add nsw i32 %82, 1
store i32 %83, i32* %9
br label %26
84: ; preds = %26
br label %85
85: ; preds = %84
%86 = load i32, i32* %8
%87 = add nsw i32 %86, 1
store i32 %87, i32* %8
br label %22
88: ; preds = %22
store i32 0, i32* %11
br label %89
89: ; preds = %160, %88
%90 = load i32, i32* %11
%91 = icmp slt i32 %90, 256
br i1 %91, label %92, label %163
92: ; preds = %89
store i32 0, i32* %12
br label %93
93: ; preds = %156, %92
%94 = load i32, i32* %12
%95 = icmp slt i32 %94, 256
br i1 %95, label %96, label %159
96: ; preds = %93
%97 = load i32, i32* %7
%98 = load i32, i32* %6
%99 = sub nsw i32 %97, %98
%100 = sitofp i32 %99 to float
%101 = fdiv float 2.550000e+02, %100
%102 = load i32, i32* %11
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %2, i64 0, i64 %103
%105 = load i32, i32* %12
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [256 x i8], [256 x i8]* %104, i64 0, i64 %106
%108 = load i8, i8* %107
%109 = zext i8 %108 to i32
%110 = load i32, i32* %6
%111 = sub nsw i32 %109, %110
%112 = sitofp i32 %111 to float
%113 = fmul float %101, %112
%114 = fptosi float %113 to i32
store i32 %114, i32* %13
%115 = load i32, i32* %13
%116 = icmp sgt i32 %115, 255
br i1 %116, label %117, label %127
117: ; preds = %96
%118 = load i32, i32* %11
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %3, i64 0, i64 %119
%121 = load i32, i32* %12
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds [256 x i8], [256 x i8]* %120, i64 0, i64 %122
store i8 -1, i8* %123
%124 = getelementptr inbounds [256 x i32], [256 x i32]* %10, i64 0, i64 255
%125 = load i32, i32* %124
%126 = add nsw i32 %125, 1
store i32 %126, i32* %124
br label %155
127: ; preds = %96
%128 = load i32, i32* %13
%129 = icmp slt i32 %128, 0
br i1 %129, label %130, label %140
130: ; preds = %127
%131 = load i32, i32* %11
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %3, i64 0, i64 %132
%134 = load i32, i32* %12
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds [256 x i8], [256 x i8]* %133, i64 0, i64 %135
store i8 0, i8* %136
%137 = getelementptr inbounds [256 x i32], [256 x i32]* %10, i64 0, i64 0
%138 = load i32, i32* %137
%139 = add nsw i32 %138, 1
store i32 %139, i32* %137
br label %154
140: ; preds = %127
%141 = load i32, i32* %13
%142 = trunc i32 %141 to i8
%143 = load i32, i32* %11
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %3, i64 0, i64 %144
%146 = load i32, i32* %12
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds [256 x i8], [256 x i8]* %145, i64 0, i64 %147
store i8 %142, i8* %148
%149 = load i32, i32* %13
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds [256 x i32], [256 x i32]* %10, i64 0, i64 %150
%152 = load i32, i32* %151
%153 = add nsw i32 %152, 1
store i32 %153, i32* %151
br label %154
154: ; preds = %140, %130
br label %155
155: ; preds = %154, %117
br label %156
156: ; preds = %155
%157 = load i32, i32* %12
%158 = add nsw i32 %157, 1
store i32 %158, i32* %12
br label %93
159: ; preds = %93
br label %160
160: ; preds = %159
%161 = load i32, i32* %11
%162 = add nsw i32 %161, 1
store i32 %162, i32* %11
br label %89
163: ; preds = %89
%164 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %164, i32** %5
store i32 0, i32* %14
br label %165
165: ; preds = %176, %163
%166 = load i32, i32* %14
%167 = icmp slt i32 %166, 256
br i1 %167, label %168, label %179
168: ; preds = %165
%169 = load i32*, i32** %5
%170 = load i32, i32* %14
%171 = load i32, i32* %14
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds [256 x i32], [256 x i32]* %10, i64 0, i64 %172
%174 = load i32, i32* %173
%175 = call i32 @fprintf(i32* %169, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %170, i32 %174)
br label %176
176: ; preds = %168
%177 = load i32, i32* %14
%178 = add nsw i32 %177, 1
store i32 %178, i32* %14
br label %165
179: ; preds = %165
%180 = load i32*, i32** %5
%181 = call i32 @fclose(i32* %180)
%182 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %182, i32** %5
%183 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %3, i64 0, i64 0
%184 = bitcast [256 x i8]* %183 to i8**
%185 = load i32*, i32** %5
%186 = call i32 @fwrite(i8** %184, i32 1, i32 65536, i32* %185)
%187 = load i32*, i32** %5
%188 = call i32 @fclose(i32* %187)
%189 = call i32 @system(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"girldark.dat\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [15 x i8] c"plot_ex2-2.dat\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [9 x i8] c"%3d %3d\0A\00"
@.str.5 = [19 x i8] c"girldark_ex2-2.dat\00"
@.str.6 = [13 x i8] c"zsh ex2-2.sh\00"
define i32 @main() {
%1 = alloca [256 x [256 x i8]]
%2 = alloca [256 x [256 x i8]]
%3 = alloca [256 x i32]
%4 = alloca [256 x i32]
%5 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %1, i64 0, i64 0, i64 0
%6 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %2, i64 0, i64 0, i64 0
%7 = bitcast [256 x i32]* %3 to i8*
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%9 = bitcast [256 x [256 x i8]]* %1 to i8**
%10 = call i32 @fread(i8** %9, i32 1, i32 65536, i32* %8)
%11 = tail call i32 @fclose(i32* %8)
br label %12
12: ; preds = %0, %23
%13 = phi i64 [ 0, %0 ], [ %24, %23 ]
%14 = phi i32 [ 0, %0 ], [ %50, %23 ]
%15 = phi i32 [ 255, %0 ], [ %52, %23 ]
br label %26
16: ; preds = %23
%17 = bitcast [256 x i32]* %4 to i8*
%18 = sub nsw i32 %50, %52
%19 = sitofp i32 %18 to float
%20 = fdiv float 2.550000e+02, %19
%21 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 0
%22 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 255
br label %55
23: ; preds = %26
%24 = add nuw nsw i64 %13, 1
%25 = icmp eq i64 %24, 256
br i1 %25, label %16, label %12
26: ; preds = %26, %12
%27 = phi i64 [ 0, %12 ], [ %53, %26 ]
%28 = phi i32 [ %14, %12 ], [ %50, %26 ]
%29 = phi i32 [ %15, %12 ], [ %52, %26 ]
%30 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %1, i64 0, i64 %13, i64 %27
%31 = load i8, i8* %30
%32 = zext i8 %31 to i64
%33 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = add nsw i32 %34, 1
store i32 %35, i32* %33
%36 = zext i8 %31 to i32
%37 = icmp ult i32 %28, %36
%38 = select i1 %37, i32 %36, i32 %28
%39 = icmp sgt i32 %29, %36
%40 = select i1 %39, i32 %36, i32 %29
%41 = or i64 %27, 1
%42 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %1, i64 0, i64 %13, i64 %41
%43 = load i8, i8* %42
%44 = zext i8 %43 to i64
%45 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = add nsw i32 %46, 1
store i32 %47, i32* %45
%48 = zext i8 %43 to i32
%49 = icmp ult i32 %38, %48
%50 = select i1 %49, i32 %48, i32 %38
%51 = icmp sgt i32 %40, %48
%52 = select i1 %51, i32 %48, i32 %40
%53 = add nuw nsw i64 %27, 2
%54 = icmp eq i64 %53, 256
br i1 %54, label %23, label %26
55: ; preds = %16, %59
%56 = phi i64 [ 0, %16 ], [ %60, %59 ]
br label %62
57: ; preds = %59
%58 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %99
59: ; preds = %89
%60 = add nuw nsw i64 %56, 1
%61 = icmp eq i64 %60, 256
br i1 %61, label %57, label %55
62: ; preds = %55, %89
%63 = phi i64 [ 0, %55 ], [ %90, %89 ]
%64 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %1, i64 0, i64 %56, i64 %63
%65 = load i8, i8* %64
%66 = zext i8 %65 to i32
%67 = sub nsw i32 %66, %52
%68 = sitofp i32 %67 to float
%69 = fmul float %20, %68
%70 = fptosi float %69 to i32
%71 = icmp sgt i32 %70, 255
br i1 %71, label %72, label %76
72: ; preds = %62
%73 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %2, i64 0, i64 %56, i64 %63
store i8 -1, i8* %73
%74 = load i32, i32* %22
%75 = add nsw i32 %74, 1
store i32 %75, i32* %22
br label %89
76: ; preds = %62
%77 = icmp slt i32 %70, 0
br i1 %77, label %78, label %82
78: ; preds = %76
%79 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %2, i64 0, i64 %56, i64 %63
store i8 0, i8* %79
%80 = load i32, i32* %21
%81 = add nsw i32 %80, 1
store i32 %81, i32* %21
br label %89
82: ; preds = %76
%83 = trunc i32 %70 to i8
%84 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %2, i64 0, i64 %56, i64 %63
store i8 %83, i8* %84
%85 = zext i32 %70 to i64
%86 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %85
%87 = load i32, i32* %86
%88 = add nsw i32 %87, 1
store i32 %88, i32* %86
br label %89
89: ; preds = %78, %82, %72
%90 = add nuw nsw i64 %63, 1
%91 = icmp eq i64 %90, 256
br i1 %91, label %59, label %62
92: ; preds = %99
%93 = tail call i32 @fclose(i32* %58)
%94 = tail call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%95 = bitcast [256 x [256 x i8]]* %2 to i8**
%96 = call i32 @fwrite(i8** %95, i32 1, i32 65536, i32* %94)
%97 = tail call i32 @fclose(i32* %94)
%98 = tail call i32 @system(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
99: ; preds = %57, %99
%100 = phi i64 [ 0, %57 ], [ %105, %99 ]
%101 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %100
%102 = load i32, i32* %101
%103 = trunc i64 %100 to i32
%104 = tail call i32 @fprintf(i32* %58, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %103, i32 %102)
%105 = add nuw nsw i64 %100, 1
%106 = icmp eq i64 %105, 256
br i1 %106, label %92, label %99
}