#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*/ fread(unsigned char **, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(unsigned char **, int, int, int /*<<< orphan*/ *);
int main() {
  unsigned char image[256][256];
  unsigned char image_w[256][256];
  FILE *fp;
  fp = fopen("girl.dat", "rb");
  fread(image, sizeof(unsigned char), 256 * 256, fp);
  fclose(fp);
  for (int i = 0; i < 256; i++) {
    for (int j = 0; j < 256; j++) {
      image_w[i][j] = image[256 - i - 1][256 - j - 1];
    }
  }
  fp = fopen("girl1.dat", "wb");
  fwrite(image_w, sizeof(unsigned char), 256 * 256, fp);
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20020,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20018(%rbp)
lea    -0x10010(%rbp),%rdi
mov    -0x20018(%rbp),%rcx
mov    $0x1,%esi
mov    $0x10000,%edx
call   1030 <fread@plt>
mov    -0x20018(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x2001c(%rbp)
cmpl   $0x100,-0x2001c(%rbp)
jge    1248 <main+0x108>
movl   $0x0,-0x20020(%rbp)
cmpl   $0x100,-0x20020(%rbp)
jge    122f <main+0xef>
mov    $0x100,%eax
sub    -0x2001c(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    -0x10010(%rbp),%rax
shl    $0x8,%rcx
add    %rcx,%rax
mov    $0x100,%ecx
sub    -0x20020(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
movslq -0x2001c(%rbp),%rcx
lea    -0x20010(%rbp),%rax
shl    $0x8,%rcx
add    %rcx,%rax
movslq -0x20020(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20020(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20020(%rbp)
jmp    11b9 <main+0x79>
jmp    1234 <main+0xf4>
mov    -0x2001c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2001c(%rbp)
jmp    119f <main+0x5f>
lea    0xdbd(%rip),%rdi
lea    0xdc0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20018(%rbp)
lea    -0x20010(%rbp),%rdi
mov    -0x20018(%rbp),%rcx
mov    $0x1,%esi
mov    $0x10000,%edx
call   1060 <fwrite@plt>
mov    -0x20018(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x20020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20000,%rsp
lea    0xeb1(%rip),%rdi
lea    0xeb3(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
lea    0x10000(%rsp),%rdi
mov    $0x1,%esi
mov    $0x10000,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0x1fff0(%rsp),%rax
lea    0x10(%rsp),%rcx
xor    %edx,%edx
pxor   %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rax,%rsi
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
nop
movdqa -0x10(%rsi),%xmm1
movdqa (%rsi),%xmm2
movdqa %xmm2,%xmm3
punpcklbw %xmm0,%xmm3
pshufd $0x4e,%xmm3,%xmm3
pshuflw $0x1b,%xmm3,%xmm3
pshufhw $0x1b,%xmm3,%xmm3
punpckhbw %xmm0,%xmm2
pshufd $0x4e,%xmm2,%xmm2
pshuflw $0x1b,%xmm2,%xmm2
pshufhw $0x1b,%xmm2,%xmm2
packuswb %xmm3,%xmm2
movdqa %xmm1,%xmm3
punpcklbw %xmm0,%xmm3
pshufd $0x4e,%xmm3,%xmm3
pshuflw $0x1b,%xmm3,%xmm3
pshufhw $0x1b,%xmm3,%xmm3
punpckhbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm3,%xmm1
movdqa %xmm2,-0x10(%rcx,%rdi,1)
movdqa %xmm1,(%rcx,%rdi,1)
add    $0x20,%rdi
add    $0xffffffffffffffe0,%rsi
cmp    $0x100,%rdi
jne    11b0 <main+0x70>
add    $0x1,%rdx
add    $0xffffffffffffff00,%rax
add    $0x100,%rcx
cmp    $0x100,%rdx
jne    11a0 <main+0x60>
lea    0xdb2(%rip),%rdi
lea    0xdb5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x10000,%edx
mov    %rax,%rcx
call   1060 <fwrite@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x20000,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"girl.dat\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [10 x i8] c"girl1.dat\00"
@.str.3 = [3 x i8] c"wb\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x [256 x i8]]
%3 = alloca [256 x [256 x i8]]
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %4
%8 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %2, i64 0, i64 0
%9 = bitcast [256 x i8]* %8 to i8**
%10 = load i32*, i32** %4
%11 = call i32 @fread(i8** %9, i32 1, i32 65536, i32* %10)
%12 = load i32*, i32** %4
%13 = call i32 @fclose(i32* %12)
store i32 0, i32* %5
br label %14
14: ; preds = %43, %0
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 256
br i1 %16, label %17, label %46
17: ; preds = %14
store i32 0, i32* %6
br label %18
18: ; preds = %39, %17
%19 = load i32, i32* %6
%20 = icmp slt i32 %19, 256
br i1 %20, label %21, label %42
21: ; preds = %18
%22 = load i32, i32* %5
%23 = sub nsw i32 256, %22
%24 = sub nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %2, i64 0, i64 %25
%27 = load i32, i32* %6
%28 = sub nsw i32 256, %27
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %26, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %3, i64 0, i64 %34
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %35, i64 0, i64 %37
store i8 %32, i8* %38
br label %39
39: ; preds = %21
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
br label %18
42: ; preds = %18
br label %43
43: ; preds = %42
%44 = load i32, i32* %5
%45 = add nsw i32 %44, 1
store i32 %45, i32* %5
br label %14
46: ; preds = %14
%47 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 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* %47, i32** %4
%48 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %3, i64 0, i64 0
%49 = bitcast [256 x i8]* %48 to i8**
%50 = load i32*, i32** %4
%51 = call i32 @fwrite(i8** %49, i32 1, i32 65536, i32* %50)
%52 = load i32*, i32** %4
%53 = call i32 @fclose(i32* %52)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"girl.dat\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [10 x i8] c"girl1.dat\00"
@.str.3 = [3 x i8] c"wb\00"
define i32 @main() {
%1 = alloca [256 x [256 x i8]]
%2 = alloca [256 x [256 x i8]]
%3 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %1, i64 0, i64 0, i64 0
%4 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %2, i64 0, i64 0, i64 0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = bitcast [256 x [256 x i8]]* %1 to i8**
%7 = call i32 @fread(i8** %6, i32 1, i32 65536, i32* %5)
%8 = tail call i32 @fclose(i32* %5)
br label %9
9: ; preds = %0, %35
%10 = phi i64 [ 0, %0 ], [ %36, %35 ]
%11 = sub nuw nsw i64 255, %10
br label %12
12: ; preds = %12, %9
%13 = phi i64 [ 0, %9 ], [ %28, %12 ]
%14 = sub nuw nsw i64 255, %13
%15 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %1, i64 0, i64 %11, i64 %14
%16 = getelementptr inbounds i8, i8* %15, i64 -15
%17 = bitcast i8* %16 to <16 x i8>*
%18 = load <16 x i8>, <16 x i8>* %17
%19 = shufflevector <16 x i8> %18, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%20 = getelementptr inbounds i8, i8* %15, i64 -31
%21 = bitcast i8* %20 to <16 x i8>*
%22 = load <16 x i8>, <16 x i8>* %21
%23 = shufflevector <16 x i8> %22, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%24 = getelementptr inbounds [256 x [256 x i8]], [256 x [256 x i8]]* %2, i64 0, i64 %10, i64 %13
%25 = bitcast i8* %24 to <16 x i8>*
store <16 x i8> %19, <16 x i8>* %25
%26 = getelementptr inbounds i8, i8* %24, i64 16
%27 = bitcast i8* %26 to <16 x i8>*
store <16 x i8> %23, <16 x i8>* %27
%28 = add nuw i64 %13, 32
%29 = icmp eq i64 %28, 256
br i1 %29, label %35, label %12
30: ; preds = %35
%31 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%32 = bitcast [256 x [256 x i8]]* %2 to i8**
%33 = call i32 @fwrite(i8** %32, i32 1, i32 65536, i32* %31)
%34 = tail call i32 @fclose(i32* %31)
ret i32 0
35: ; preds = %12
%36 = add nuw nsw i64 %10, 1
%37 = icmp eq i64 %36, 256
br i1 %37, label %30, label %9
}