#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_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  FILE *infile, *outfile;
  char buf[0x20];
  int i;
  if (argc != 3) {
    printf("usage: %s in.adp out.adp\n", argv[0]);
    return 1;
  }
  if (!(infile = fopen(argv[1], "rb"))) {
    printf("error opening %s\n", argv[1]);
    return 1;
  }
  if (!(outfile = fopen(argv[2], "wb"))) {
    printf("error opening %s\n", argv[2]);
    return 1;
  }
  fseek(infile, 26, SEEK_SET);
  do {
    for (i = 0; i < 0x7e0; i += 0x20) {
      if (fread(buf, 0x20, 1, infile) != 1)
        break;
      fwrite(buf, 0x20, 1, outfile);
    }
  } while (fread(buf, 0x20, 1, infile) == 1);
  fclose(infile);
  fclose(outfile);
  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)
cmpl   $0x3,-0x8(%rbp)
je     119f <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe72(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12d6 <main+0x176>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11e1 <main+0x81>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe4d(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12d6 <main+0x176>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe3f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1223 <main+0xc3>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe0b(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12d6 <main+0x176>
mov    -0x18(%rbp),%rdi
mov    0x2db2(%rip),%rax
mov    (%rax),%edx
mov    $0x1a,%esi
call   1060 <fseek@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x7e0,-0x44(%rbp)
jge    1298 <main+0x138>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x20,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     1273 <main+0x113>
jmp    1298 <main+0x138>
lea    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x20,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x44(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x44(%rbp)
jmp    1241 <main+0xe1>
jmp    129d <main+0x13d>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x20,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     123a <main+0xda>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%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   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r15
cmp    $0x3,%edi
jne    122d <main+0xcd>
mov    0x8(%r15),%rdi
lea    0xe98(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     124d <main+0xed>
mov    %rax,%r12
mov    0x10(%r15),%rdi
lea    0xe91(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1253 <main+0xf3>
mov    %rax,%r14
mov    0x2e2a(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
mov    $0x1a,%esi
call   1060 <fseek@plt>
xor    %ebx,%ebx
mov    %rsp,%r15
jmp    11ef <main+0x8f>
nopl   0x0(%rax)
mov    %r15,%rdi
mov    $0x20,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1030 <fread@plt>
mov    $0x0,%ebx
cmp    $0x1,%eax
jne    1239 <main+0xd9>
mov    %r15,%rdi
mov    $0x20,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    11d0 <main+0x70>
mov    %r15,%rdi
mov    $0x20,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1080 <fwrite@plt>
lea    0x20(%rbx),%eax
cmp    $0x7c0,%ebx
mov    %eax,%ebx
jb     11ef <main+0x8f>
jmp    11d0 <main+0x70>
mov    (%r15),%rsi
lea    0xdc9(%rip),%rdi
jmp    125e <main+0xfe>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    1268 <main+0x108>
mov    0x8(%r15),%rsi
jmp    1257 <main+0xf7>
mov    0x10(%r15),%rsi
lea    0xdbf(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"usage: %s in.adp out.adp\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [18 x i8] c"error opening %s\0A\00"
@.str.3 = [3 x i8] c"wb\00"
@SEEK_SET = 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 [32 x i8]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 3
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 1, i32* %3
br label %71
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %6
%22 = icmp ne i32* %21, null
br i1 %22, label %28, label %23
23: ; preds = %17
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %26)
store i32 1, i32* %3
br label %71
28: ; preds = %17
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %32, i32** %7
%33 = icmp ne i32* %32, null
br i1 %33, label %39, label %34
34: ; preds = %28
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %37)
store i32 1, i32* %3
br label %71
39: ; preds = %28
%40 = load i32*, i32** %6
%41 = load i32, i32* @SEEK_SET
%42 = call i32 @fseek(i32* %40, i32 26, i32 %41)
br label %43
43: ; preds = %61, %39
store i32 0, i32* %9
br label %44
44: ; preds = %57, %43
%45 = load i32, i32* %9
%46 = icmp slt i32 %45, 2016
br i1 %46, label %47, label %60
47: ; preds = %44
%48 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%49 = load i32*, i32** %6
%50 = call i32 @fread(i8* %48, i32 32, i32 1, i32* %49)
%51 = icmp ne i32 %50, 1
br i1 %51, label %52, label %53
52: ; preds = %47
br label %60
53: ; preds = %47
%54 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%55 = load i32*, i32** %7
%56 = call i32 @fwrite(i8* %54, i32 32, i32 1, i32* %55)
br label %57
57: ; preds = %53
%58 = load i32, i32* %9
%59 = add nsw i32 %58, 32
store i32 %59, i32* %9
br label %44
60: ; preds = %52, %44
br label %61
61: ; preds = %60
%62 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%63 = load i32*, i32** %6
%64 = call i32 @fread(i8* %62, i32 32, i32 1, i32* %63)
%65 = icmp eq i32 %64, 1
br i1 %65, label %43, label %66
66: ; preds = %61
%67 = load i32*, i32** %6
%68 = call i32 @fclose(i32* %67)
%69 = load i32*, i32** %7
%70 = call i32 @fclose(i32* %69)
store i32 0, i32* %3
br label %71
71: ; preds = %66, %34, %23, %12
%72 = load i32, i32* %3
ret i32 %72
}

LLVM IR (-O2):
@.str = [26 x i8] c"usage: %s in.adp out.adp\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [18 x i8] c"error opening %s\0A\00"
@.str.3 = [3 x i8] c"wb\00"
@SEEK_SET = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [32 x i8]
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 3
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %44
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = load i8*, i8** %10
%16 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br label %44
17: ; preds = %9
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = load i8*, i8** %18
%24 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %23)
br label %44
25: ; preds = %17
%26 = load i32, i32* @SEEK_SET
%27 = tail call i32 @fseek(i32* %12, i32 26, i32 %26)
br label %28
28: ; preds = %36, %25
%29 = phi i32 [ 0, %25 ], [ %37, %36 ]
%30 = call i32 @fread(i8* %4, i32 32, i32 1, i32* %12)
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %38
32: ; preds = %28
%33 = call i32 @fwrite(i8* %4, i32 32, i32 1, i32* %20)
%34 = add nuw nsw i32 %29, 32
%35 = icmp ult i32 %29, 1984
br i1 %35, label %36, label %38
36: ; preds = %32, %38
%37 = phi i32 [ %34, %32 ], [ 0, %38 ]
br label %28
38: ; preds = %32, %28
%39 = call i32 @fread(i8* %4, i32 32, i32 1, i32* %12)
%40 = icmp eq i32 %39, 1
br i1 %40, label %36, label %41
41: ; preds = %38
%42 = tail call i32 @fclose(i32* %12)
%43 = tail call i32 @fclose(i32* %20)
br label %44
44: ; preds = %41, %22, %14, %6
%45 = phi i32 [ 1, %6 ], [ 0, %41 ], [ 1, %22 ], [ 1, %14 ]
ret i32 %45
}