#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 */

/* Variables and functions */
int /*<<< orphan*/ MAP_PRIVATE;
int /*<<< orphan*/ MAP_SHARED;
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_RDWR;
int O_TRUNC;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ close(int);
int ftruncate(int, unsigned int);
unsigned int lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char const *, int);
void *mmap(int /*<<< orphan*/, unsigned int, int, int /*<<< orphan*/, int,
           int /*<<< orphan*/);
int open(char *, int, ...);
int /*<<< orphan*/ perror(char *);
int swoz(int);
int main(int argc, char **argv) {
  int x, y;
  int in = open(argv[1], O_RDONLY);
  int out = open(argv[2], O_RDWR | O_TRUNC | O_CREAT, 0660);
  unsigned size;
  const unsigned char *p;
  unsigned char *dest;
  if (in == -1) {
    perror(argv[1]);
    return 1;
  }
  if (out == -1) {
    perror(argv[2]);
    return 1;
  }
  size = lseek(in, 0, SEEK_END);
  p = mmap(0, size, PROT_READ, MAP_PRIVATE, in, 0);
  if (ftruncate(out, size) == -1) {
    perror("ftruncate");
    return 1;
  }
  dest = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, out, 0);
  for (y = 0; y < size / 512; y++) {
    for (x = 0; x < 512; x += 16)
      memcpy(&dest[y * 512 + (x)], &p[y * 512 + swoz(x)], 16);
  }
  close(in);
  close(out);
  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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e13(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1090 <open@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2e08(%rip),%rax
mov    (%rax),%esi
mov    0x2e27(%rip),%rax
or     (%rax),%esi
mov    0x2e26(%rip),%rax
or     (%rax),%esi
mov    $0x1b0,%edx
mov    $0x0,%al
call   1090 <open@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1206 <main+0x86>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1376 <main+0x1f6>
cmpl   $0xffffffff,-0x20(%rbp)
jne    1229 <main+0xa9>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10a0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1376 <main+0x1f6>
mov    -0x1c(%rbp),%edi
mov    0x2d8d(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <lseek@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
mov    0x2d9f(%rip),%rax
mov    (%rax),%edx
mov    0x2d4e(%rip),%rax
mov    (%rax),%ecx
mov    -0x1c(%rbp),%r8d
xor    %r9d,%r9d
mov    %r9d,%edi
call   1040 <mmap@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1050 <ftruncate@plt>
cmp    $0xffffffff,%eax
jne    1293 <main+0x113>
lea    0xd7e(%rip),%rdi
call   10a0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1376 <main+0x1f6>
mov    -0x24(%rbp),%esi
mov    0x2d4b(%rip),%rax
mov    (%rax),%edx
mov    0x2d02(%rip),%rax
or     (%rax),%edx
mov    0x2d29(%rip),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%r8d
xor    %r9d,%r9d
mov    %r9d,%edi
call   1040 <mmap@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x24(%rbp),%ecx
shr    $0x9,%ecx
cmp    %ecx,%eax
jae    135f <main+0x1df>
movl   $0x0,-0x14(%rbp)
cmpl   $0x200,-0x14(%rbp)
jge    134c <main+0x1cc>
mov    -0x38(%rbp),%rax
mov    -0x18(%rbp),%ecx
shl    $0x9,%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%eax
shl    $0x9,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <swoz@plt>
mov    -0x50(%rbp),%rsi
mov    -0x48(%rbp),%rdi
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
add    %ecx,%eax
cltq
add    %rax,%rsi
mov    $0x10,%edx
call   1080 <memcpy@plt>
mov    -0x14(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x14(%rbp)
jmp    12e3 <main+0x163>
jmp    1351 <main+0x1d1>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12cb <main+0x14b>
mov    -0x1c(%rbp),%edi
call   1070 <close@plt>
mov    -0x20(%rbp),%edi
call   1070 <close@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
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
mov    0x2e1c(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   1090 <open@plt>
mov    %eax,%r15d
mov    0x2e19(%rip),%rax
mov    0x2e3a(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x10(%rbp),%rdi
mov    0x2e33(%rip),%rax
or     (%rax),%esi
mov    $0x1b0,%edx
xor    %eax,%eax
call   1090 <open@plt>
cmp    $0xffffffff,%r15d
je     12fa <main+0x17a>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     1300 <main+0x180>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
xor    %esi,%esi
call   1060 <lseek@plt>
mov    %eax,%r13d
mov    0x2de3(%rip),%r14
mov    (%r14),%edx
mov    0x2d91(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %r13d,%esi
mov    %r15d,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,%rbp
mov    %ebx,%edi
mov    %r13d,%esi
call   1050 <ftruncate@plt>
cmp    $0xffffffff,%eax
je     1306 <main+0x186>
mov    %r15d,0xc(%rsp)
mov    0x2d65(%rip),%rax
mov    (%rax),%edx
or     (%r14),%edx
mov    0x2d89(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %r13d,%esi
mov    %ebx,0x8(%rsp)
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
cmp    $0x200,%r13d
jb     12d7 <main+0x157>
mov    %rax,%rbx
shr    $0x9,%r13d
xor    %r12d,%r12d
mov    %r13,0x10(%rsp)
nopl   (%rax)
mov    %r12d,%r13d
shl    $0x9,%r13d
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
lea    (%rbx,%r15,1),%r14
mov    %r15d,%edi
call   1030 <swoz@plt>
add    %r13d,%eax
movslq %eax,%rsi
add    %rbp,%rsi
mov    %r14,%rdi
mov    $0x10,%edx
call   1080 <memcpy@plt>
lea    0x10(%r15),%rax
cmp    $0x1f0,%r15
mov    %rax,%r15
jb     1290 <main+0x110>
add    $0x1,%r12
add    $0x200,%rbx
mov    0x10(%rsp),%r13
cmp    %r13,%r12
jne    1280 <main+0x100>
mov    0xc(%rsp),%edi
call   1070 <close@plt>
mov    0x8(%rsp),%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rbp),%rdi
jmp    130d <main+0x18d>
mov    0x10(%rbp),%rdi
jmp    130d <main+0x18d>
lea    0xcf3(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%eax
jmp    12eb <main+0x16b>

LLVM IR (-O0):
@O_RDONLY = global i32 0
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@SEEK_END = global i32 0
@PROT_READ = global i32 0
@MAP_PRIVATE = global i32 0
@.str = [10 x i8] c"ftruncate\00"
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = load i32, i32* @O_RDONLY
%17 = call i32 (i8*, i32, ...) @open(i8* %15, i32 %16)
store i32 %17, i32* %8
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = load i32, i32* @O_RDWR
%22 = load i32, i32* @O_TRUNC
%23 = or i32 %21, %22
%24 = load i32, i32* @O_CREAT
%25 = or i32 %23, %24
%26 = call i32 (i8*, i32, ...) @open(i8* %20, i32 %25, i32 432)
store i32 %26, i32* %9
%27 = load i32, i32* %8
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %34
29: ; preds = %2
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32 @perror(i8* %32)
store i32 1, i32* %3
br label %103
34: ; preds = %2
%35 = load i32, i32* %9
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32 @perror(i8* %40)
store i32 1, i32* %3
br label %103
42: ; preds = %34
%43 = load i32, i32* %8
%44 = load i32, i32* @SEEK_END
%45 = call i32 @lseek(i32 %43, i32 0, i32 %44)
store i32 %45, i32* %10
%46 = load i32, i32* %10
%47 = load i32, i32* @PROT_READ
%48 = load i32, i32* @MAP_PRIVATE
%49 = load i32, i32* %8
%50 = call i8* @mmap(i32 0, i32 %46, i32 %47, i32 %48, i32 %49, i32 0)
store i8* %50, i8** %11
%51 = load i32, i32* %9
%52 = load i32, i32* %10
%53 = call i32 @ftruncate(i32 %51, i32 %52)
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %57
55: ; preds = %42
%56 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %103
57: ; preds = %42
%58 = load i32, i32* %10
%59 = load i32, i32* @PROT_READ
%60 = load i32, i32* @PROT_WRITE
%61 = or i32 %59, %60
%62 = load i32, i32* @MAP_SHARED
%63 = load i32, i32* %9
%64 = call i8* @mmap(i32 0, i32 %58, i32 %61, i32 %62, i32 %63, i32 0)
store i8* %64, i8** %12
store i32 0, i32* %7
br label %65
65: ; preds = %95, %57
%66 = load i32, i32* %7
%67 = load i32, i32* %10
%68 = udiv i32 %67, 512
%69 = icmp ult i32 %66, %68
br i1 %69, label %70, label %98
70: ; preds = %65
store i32 0, i32* %6
br label %71
71: ; preds = %91, %70
%72 = load i32, i32* %6
%73 = icmp slt i32 %72, 512
br i1 %73, label %74, label %94
74: ; preds = %71
%75 = load i8*, i8** %12
%76 = load i32, i32* %7
%77 = mul nsw i32 %76, 512
%78 = load i32, i32* %6
%79 = add nsw i32 %77, %78
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* %75, i64 %80
%82 = load i8*, i8** %11
%83 = load i32, i32* %7
%84 = mul nsw i32 %83, 512
%85 = load i32, i32* %6
%86 = call i32 @swoz(i32 %85)
%87 = add nsw i32 %84, %86
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i8, i8* %82, i64 %88
%90 = call i32 @memcpy(i8* %81, i8* %89, i32 16)
br label %91
91: ; preds = %74
%92 = load i32, i32* %6
%93 = add nsw i32 %92, 16
store i32 %93, i32* %6
br label %71
94: ; preds = %71
br label %95
95: ; preds = %94
%96 = load i32, i32* %7
%97 = add nsw i32 %96, 1
store i32 %97, i32* %7
br label %65
98: ; preds = %65
%99 = load i32, i32* %8
%100 = call i32 @close(i32 %99)
%101 = load i32, i32* %9
%102 = call i32 @close(i32 %101)
store i32 0, i32* %3
br label %103
103: ; preds = %98, %55, %37, %29
%104 = load i32, i32* %3
ret i32 %104
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@SEEK_END = global i32 0
@PROT_READ = global i32 0
@MAP_PRIVATE = global i32 0
@.str = [10 x i8] c"ftruncate\00"
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = load i32, i32* @O_RDONLY
%6 = tail call i32 (i8*, i32, ...) @open(i8* %4, i32 %5)
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = load i32, i32* @O_RDWR
%10 = load i32, i32* @O_TRUNC
%11 = or i32 %10, %9
%12 = load i32, i32* @O_CREAT
%13 = or i32 %11, %12
%14 = tail call i32 (i8*, i32, ...) @open(i8* %8, i32 %13, i32 432)
%15 = icmp eq i32 %6, -1
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i8*, i8** %3
%18 = tail call i32 @perror(i8* %17)
br label %66
19: ; preds = %2
%20 = icmp eq i32 %14, -1
br i1 %20, label %21, label %24
21: ; preds = %19
%22 = load i8*, i8** %7
%23 = tail call i32 @perror(i8* %22)
br label %66
24: ; preds = %19
%25 = load i32, i32* @SEEK_END
%26 = tail call i32 @lseek(i32 %6, i32 0, i32 %25)
%27 = load i32, i32* @PROT_READ
%28 = load i32, i32* @MAP_PRIVATE
%29 = tail call i8* @mmap(i32 0, i32 %26, i32 %27, i32 %28, i32 %6, i32 0)
%30 = tail call i32 @ftruncate(i32 %14, i32 %26)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %34
32: ; preds = %24
%33 = tail call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %66
34: ; preds = %24
%35 = load i32, i32* @PROT_READ
%36 = load i32, i32* @PROT_WRITE
%37 = or i32 %36, %35
%38 = load i32, i32* @MAP_SHARED
%39 = tail call i8* @mmap(i32 0, i32 %26, i32 %37, i32 %38, i32 %14, i32 0)
%40 = icmp ult i32 %26, 512
br i1 %40, label %63, label %41
41: ; preds = %34
%42 = lshr i32 %26, 9
%43 = zext i32 %42 to i64
br label %44
44: ; preds = %41, %60
%45 = phi i64 [ 0, %41 ], [ %61, %60 ]
%46 = shl nsw i64 %45, 9
%47 = trunc i64 %46 to i32
br label %48
48: ; preds = %44, %48
%49 = phi i64 [ 0, %44 ], [ %58, %48 ]
%50 = add nuw nsw i64 %49, %46
%51 = getelementptr inbounds i8, i8* %39, i64 %50
%52 = trunc i64 %49 to i32
%53 = tail call i32 @swoz(i32 %52)
%54 = add nsw i32 %53, %47
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %29, i64 %55
%57 = tail call i32 @memcpy(i8* %51, i8* %56, i32 16)
%58 = add nuw nsw i64 %49, 16
%59 = icmp ult i64 %49, 496
br i1 %59, label %48, label %60
60: ; preds = %48
%61 = add nuw nsw i64 %45, 1
%62 = icmp eq i64 %61, %43
br i1 %62, label %63, label %44
63: ; preds = %60, %34
%64 = tail call i32 @close(i32 %6)
%65 = tail call i32 @close(i32 %14)
br label %66
66: ; preds = %63, %32, %21, %16
%67 = phi i32 [ 1, %16 ], [ 1, %21 ], [ 1, %32 ], [ 0, %63 ]
ret i32 %67
}