#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 _read_GC4016(char *BASE1) {
  FILE *fid;
  int temp, i;
  fid = fopen("GC4016_settings.out", "w");
  for (i = 0; i <= 0x07c; i += 0x04) {
    fprintf(fid, "%000.3x	%00000000.8x", i,
            *((unsigned int *)(BASE1 + 0x800 + i)));
    fprintf(fid, "	%00000000.8x",
            *((unsigned int *)(BASE1 + 0x1000 + i)));
    fprintf(fid, "	%00000000.8x\n",
            *((unsigned int *)(BASE1 + 0x1800 + i)));
  }
  fprintf(fid, "\n\n\n");
  i = 0;
  for (i = 0x200; i <= 0x45c; i += 0x04) {
    fprintf(fid, "%000.3x	%00000000.8x", i,
            *((unsigned int *)(BASE1 + 0x800 + i)));
    fprintf(fid, "	%00000000.8x",
            *((unsigned int *)(BASE1 + 0x1000 + i)));
    fprintf(fid, "	%00000000.8x\n",
            *((unsigned int *)(BASE1 + 0x1800 + i)));
  }
  fclose(fid);
}


x86 assembly (clang, -O0):
<_read_GC4016>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xebd(%rip),%rdi
lea    0xeca(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x7c,-0x20(%rbp)
jg     11d8 <_read_GC4016+0xa8>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    0x800(%rax,%rcx,1),%ecx
lea    0xe95(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    0x1000(%rax,%rcx,1),%edx
lea    0xe7b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    0x1800(%rax,%rcx,1),%edx
lea    0xe68(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x20(%rbp)
jmp    115a <_read_GC4016+0x2a>
mov    -0x18(%rbp),%rdi
lea    0xe57(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x20(%rbp)
movl   $0x200,-0x20(%rbp)
cmpl   $0x45c,-0x20(%rbp)
jg     1279 <_read_GC4016+0x149>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    0x800(%rax,%rcx,1),%ecx
lea    0xdf4(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    0x1000(%rax,%rcx,1),%edx
lea    0xdda(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    0x1800(%rax,%rcx,1),%edx
lea    0xdc7(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x20(%rbp)
jmp    11f8 <_read_GC4016+0xc8>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_read_GC4016>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xeab(%rip),%rdi
lea    0xeb8(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
lea    0xeab(%rip),%r15
lea    0xeab(%rip),%r12
lea    0xeb2(%rip),%r13
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    0x800(%r14,%rbp,1),%ecx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x1000(%r14,%rbp,1),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x1800(%r14,%rbp,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0x4(%rbp),%rax
cmp    $0x79,%rbp
mov    %rax,%rbp
jb     1180 <_read_GC4016+0x40>
lea    0xe65(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
mov    $0x1a00,%r15d
lea    0xe29(%rip),%r12
lea    0xe30(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    -0x1000(%r14,%r15,1),%ecx
ff
lea    -0x1800(%r15),%rbp
mov    %rbx,%rdi
lea    0xdfd(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    -0x800(%r14,%r15,1),%edx
ff
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14,%r15,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x4,%r15
cmp    $0x459,%rbp
jb     1200 <_read_GC4016+0xc0>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"GC4016_settings.out\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [21 x i8] c"%000.3x\09%00000000.8x\00"
@.str.3 = [14 x i8] c"\09%00000000.8x\00"
@.str.4 = [15 x i8] c"\09%00000000.8x\0A\00"
@.str.5 = [4 x i8] c"\0A\0A\0A\00"
define i32 @_read_GC4016(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
%7 = call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %4
store i32 0, i32* %6
br label %8
8: ; preds = %40, %1
%9 = load i32, i32* %6
%10 = icmp sle i32 %9, 124
br i1 %10, label %11, label %43
11: ; preds = %8
%12 = load i32*, i32** %4
%13 = load i32, i32* %6
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 2048
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = bitcast i8* %18 to i32*
%20 = load i32, i32* %19
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 %20)
%22 = load i32*, i32** %4
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 4096
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = bitcast i8* %27 to i32*
%29 = load i32, i32* %28
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = load i32*, i32** %4
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i64 6144
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = bitcast i8* %36 to i32*
%38 = load i32, i32* %37
%39 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %11
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 4
store i32 %42, i32* %6
br label %8
43: ; preds = %8
%44 = load i32*, i32** %4
%45 = call i32 (i32*, i8*, ...) @fprintf(i32* %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %6
store i32 512, i32* %6
br label %46
46: ; preds = %78, %43
%47 = load i32, i32* %6
%48 = icmp sle i32 %47, 1116
br i1 %48, label %49, label %81
49: ; preds = %46
%50 = load i32*, i32** %4
%51 = load i32, i32* %6
%52 = load i8*, i8** %3
%53 = getelementptr inbounds i8, i8* %52, i64 2048
%54 = load i32, i32* %6
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
%57 = bitcast i8* %56 to i32*
%58 = load i32, i32* %57
%59 = call i32 (i32*, i8*, ...) @fprintf(i32* %50, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %51, i32 %58)
%60 = load i32*, i32** %4
%61 = load i8*, i8** %3
%62 = getelementptr inbounds i8, i8* %61, i64 4096
%63 = load i32, i32* %6
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
%66 = bitcast i8* %65 to i32*
%67 = load i32, i32* %66
%68 = call i32 (i32*, i8*, ...) @fprintf(i32* %60, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %67)
%69 = load i32*, i32** %4
%70 = load i8*, i8** %3
%71 = getelementptr inbounds i8, i8* %70, i64 6144
%72 = load i32, i32* %6
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %71, i64 %73
%75 = bitcast i8* %74 to i32*
%76 = load i32, i32* %75
%77 = call i32 (i32*, i8*, ...) @fprintf(i32* %69, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %76)
br label %78
78: ; preds = %49
%79 = load i32, i32* %6
%80 = add nsw i32 %79, 4
store i32 %80, i32* %6
br label %46
81: ; preds = %46
%82 = load i32*, i32** %4
%83 = call i32 @fclose(i32* %82)
%84 = load i32, i32* %2
ret i32 %84
}

LLVM IR (-O2):
@.str = [20 x i8] c"GC4016_settings.out\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [21 x i8] c"%000.3x\09%00000000.8x\00"
@.str.3 = [14 x i8] c"\09%00000000.8x\00"
@.str.4 = [15 x i8] c"\09%00000000.8x\0A\00"
@.str.5 = [4 x i8] c"\0A\0A\0A\00"
define i32 @_read_GC4016(i8* nocapture %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = getelementptr inbounds i8, i8* %0, i64 2048
%4 = getelementptr inbounds i8, i8* %0, i64 4096
%5 = getelementptr inbounds i8, i8* %0, i64 6144
br label %6
6: ; preds = %1, %6
%7 = phi i64 [ 0, %1 ], [ %21, %6 ]
%8 = getelementptr inbounds i8, i8* %3, i64 %7
%9 = bitcast i8* %8 to i32*
%10 = load i32, i32* %9
%11 = trunc i64 %7 to i32
%12 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %11, i32 %10)
%13 = getelementptr inbounds i8, i8* %4, i64 %7
%14 = bitcast i8* %13 to i32*
%15 = load i32, i32* %14
%16 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds i8, i8* %5, i64 %7
%18 = bitcast i8* %17 to i32*
%19 = load i32, i32* %18
%20 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = add nuw nsw i64 %7, 4
%22 = icmp ult i64 %7, 121
br i1 %22, label %6, label %23
23: ; preds = %6
%24 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 3, i64 1, i32* %2)
br label %25
25: ; preds = %23, %25
%26 = phi i64 [ 512, %23 ], [ %40, %25 ]
%27 = getelementptr inbounds i8, i8* %3, i64 %26
%28 = bitcast i8* %27 to i32*
%29 = load i32, i32* %28
%30 = trunc i64 %26 to i32
%31 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %30, i32 %29)
%32 = getelementptr inbounds i8, i8* %4, i64 %26
%33 = bitcast i8* %32 to i32*
%34 = load i32, i32* %33
%35 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds i8, i8* %5, i64 %26
%37 = bitcast i8* %36 to i32*
%38 = load i32, i32* %37
%39 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %38)
%40 = add nuw nsw i64 %26, 4
%41 = icmp ult i64 %26, 1113
br i1 %41, label %25, label %42
42: ; preds = %25
%43 = tail call i32 @fclose(i32* %2)
ret i32 undef
}