#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 /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int i;
  FILE *file;
  file = fopen("main.smc", "rb+");
  if (file == NULL)
    return 0;
  fseek(file, 0x8000 * 4, SEEK_SET);
  float zoom = 0x340;
  float sub;
  int byte[0x200];
  float div = zoom * 0.024;
  int ozoom;
  float pr, tzoom = zoom;
  for (i = 0; i < 0x80; i++) {
    sub = zoom / div;
    pr = ((float)zoom / tzoom);
    byte[i] = zoom;
    ozoom = zoom;
    fputc(ozoom & 0xFF, file);
    fputc((ozoom >> 8) & 0xFF, file);
    zoom -= (sub * pr);
  }
  fclose(file);
  file = fopen("m7.bin", "wb");
  for (i = 0; i < 0x100; i++) {
    ozoom = byte[i];
    fputc(ozoom & 0xFF, file);
    fputc((ozoom >> 8) & 0xFF, file);
  }
  fclose(file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeac(%rip),%rdi
lea    0xeae(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1187 <main+0x47>
movl   $0x0,-0x4(%rbp)
jmp    1326 <main+0x1e6>
mov    -0x20(%rbp),%rdi
mov    0x2e4e(%rip),%rax
mov    (%rax),%edx
mov    $0x20000,%esi
call   1050 <fseek@plt>
movss  0xe62(%rip),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe44(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x834(%rbp)
ff
movss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x840(%rbp)
ff
movl   $0x0,-0x14(%rbp)
cmpl   $0x80,-0x14(%rbp)
jge    1296 <main+0x156>
movss  -0x24(%rbp),%xmm0
divss  -0x834(%rbp),%xmm0
ff
movss  %xmm0,-0x28(%rbp)
movss  -0x24(%rbp),%xmm0
divss  -0x840(%rbp),%xmm0
ff
movss  %xmm0,-0x83c(%rbp)
ff
cvttss2si -0x24(%rbp),%ecx
movslq -0x14(%rbp),%rax
mov    %ecx,-0x830(%rbp,%rax,4)
cvttss2si -0x24(%rbp),%eax
mov    %eax,-0x838(%rbp)
mov    -0x838(%rbp),%edi
and    $0xff,%edi
mov    -0x20(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x838(%rbp),%edi
sar    $0x8,%edi
and    $0xff,%edi
mov    -0x20(%rbp),%rsi
call   1040 <fputc@plt>
movss  -0x28(%rbp),%xmm0
movss  -0x83c(%rbp),%xmm2
ff
movss  -0x24(%rbp),%xmm1
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e0 <main+0xa0>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xd73(%rip),%rdi
lea    0xd73(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    1316 <main+0x1d6>
movslq -0x14(%rbp),%rax
mov    -0x830(%rbp,%rax,4),%eax
mov    %eax,-0x838(%rbp)
mov    -0x838(%rbp),%edi
and    $0xff,%edi
mov    -0x20(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x838(%rbp),%edi
sar    $0x8,%edi
and    $0xff,%edi
mov    -0x20(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12bd <main+0x17d>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x810,%rsp
lea    0xeb6(%rip),%rdi
lea    0xeb8(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1253 <main+0x113>
mov    %rax,%r14
mov    0x2e6f(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0x20000,%esi
call   1050 <fseek@plt>
movss  0xe78(%rip),%xmm0
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movss  %xmm0,0x8(%rsp)
movaps %xmm0,%xmm1
divss  0xe5f(%rip),%xmm1
movss  %xmm1,0xc(%rsp)
cvttss2si %xmm0,%eax
mov    %eax,0x10(%rsp,%rbx,4)
movzbl %al,%edi
mov    %eax,%ebp
mov    %r14,%rsi
call   1040 <fputc@plt>
mov    %ebp,%eax
movzbl %ah,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
movss  0x8(%rsp),%xmm0
divss  0xe2d(%rip),%xmm0
mulss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
movss  0x8(%rsp),%xmm0
add    $0x1,%rbx
cmp    $0x80,%rbx
jne    1190 <main+0x50>
mov    %r14,%rdi
call   1030 <fclose@plt>
lea    0xe06(%rip),%rdi
lea    0xe06(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
xor    %ebx,%ebx
mov    0x10(%rsp,%rbx,4),%eax
movzbl %al,%edi
mov    %eax,%ebp
mov    %r14,%rsi
call   1040 <fputc@plt>
mov    %ebp,%eax
movzbl %ah,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    1220 <main+0xe0>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x810,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"main.smc\00"
@.str.1 = [4 x i8] c"rb+\00"
@SEEK_SET = global i32 0
@.str.2 = [7 x i8] c"m7.bin\00"
@.str.3 = [3 x i8] c"wb\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca float
%9 = alloca float
%10 = alloca [512 x i32]
%11 = alloca float
%12 = alloca i32
%13 = alloca float
%14 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32* %15, i32** %7
%16 = load i32*, i32** %7
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %19
18: ; preds = %2
store i32 0, i32* %3
br label %89
19: ; preds = %2
%20 = load i32*, i32** %7
%21 = load i32, i32* @SEEK_SET
%22 = call i32 @fseek(i32* %20, i32 131072, i32 %21)
store float 8.320000e+02, float* %8
%23 = load float, float* %8
%24 = fpext float %23 to double
%25 = fmul double %24, 2.400000e-02
%26 = fptrunc double %25 to float
store float %26, float* %11
%27 = load float, float* %8
store float %27, float* %14
store i32 0, i32* %6
br label %28
28: ; preds = %59, %19
%29 = load i32, i32* %6
%30 = icmp slt i32 %29, 128
br i1 %30, label %31, label %62
31: ; preds = %28
%32 = load float, float* %8
%33 = load float, float* %11
%34 = fdiv float %32, %33
store float %34, float* %9
%35 = load float, float* %8
%36 = load float, float* %14
%37 = fdiv float %35, %36
store float %37, float* %13
%38 = load float, float* %8
%39 = fptosi float %38 to i32
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [512 x i32], [512 x i32]* %10, i64 0, i64 %41
store i32 %39, i32* %42
%43 = load float, float* %8
%44 = fptosi float %43 to i32
store i32 %44, i32* %12
%45 = load i32, i32* %12
%46 = and i32 %45, 255
%47 = load i32*, i32** %7
%48 = call i32 @fputc(i32 %46, i32* %47)
%49 = load i32, i32* %12
%50 = ashr i32 %49, 8
%51 = and i32 %50, 255
%52 = load i32*, i32** %7
%53 = call i32 @fputc(i32 %51, i32* %52)
%54 = load float, float* %9
%55 = load float, float* %13
%56 = load float, float* %8
%57 = fneg float %54
%58 = call float @llvm.fmuladd.f32(float %57, float %55, float %56)
store float %58, float* %8
br label %59
59: ; preds = %31
%60 = load i32, i32* %6
%61 = add nsw i32 %60, 1
store i32 %61, i32* %6
br label %28
62: ; preds = %28
%63 = load i32*, i32** %7
%64 = call i32 @fclose(i32* %63)
%65 = call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 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* %65, i32** %7
store i32 0, i32* %6
br label %66
66: ; preds = %83, %62
%67 = load i32, i32* %6
%68 = icmp slt i32 %67, 256
br i1 %68, label %69, label %86
69: ; preds = %66
%70 = load i32, i32* %6
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [512 x i32], [512 x i32]* %10, i64 0, i64 %71
%73 = load i32, i32* %72
store i32 %73, i32* %12
%74 = load i32, i32* %12
%75 = and i32 %74, 255
%76 = load i32*, i32** %7
%77 = call i32 @fputc(i32 %75, i32* %76)
%78 = load i32, i32* %12
%79 = ashr i32 %78, 8
%80 = and i32 %79, 255
%81 = load i32*, i32** %7
%82 = call i32 @fputc(i32 %80, i32* %81)
br label %83
83: ; preds = %69
%84 = load i32, i32* %6
%85 = add nsw i32 %84, 1
store i32 %85, i32* %6
br label %66
86: ; preds = %66
%87 = load i32*, i32** %7
%88 = call i32 @fclose(i32* %87)
store i32 0, i32* %3
br label %89
89: ; preds = %86, %18
%90 = load i32, i32* %3
ret i32 %90
}

LLVM IR (-O2):
@.str = [9 x i8] c"main.smc\00"
@.str.1 = [4 x i8] c"rb+\00"
@SEEK_SET = global i32 0
@.str.2 = [7 x i8] c"m7.bin\00"
@.str.3 = [3 x i8] c"wb\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [512 x i32]
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %41, label %6
6: ; preds = %2
%7 = load i32, i32* @SEEK_SET
%8 = tail call i32 @fseek(i32* %4, i32 131072, i32 %7)
%9 = bitcast [512 x i32]* %3 to i8*
br label %10
10: ; preds = %6, %10
%11 = phi i64 [ 0, %6 ], [ %23, %10 ]
%12 = phi float [ 8.320000e+02, %6 ], [ %22, %10 ]
%13 = fdiv float %12, 8.320000e+02
%14 = fptosi float %12 to i32
%15 = getelementptr inbounds [512 x i32], [512 x i32]* %3, i64 0, i64 %11
store i32 %14, i32* %15
%16 = and i32 %14, 255
%17 = tail call i32 @fputc(i32 %16, i32* %4)
%18 = lshr i32 %14, 8
%19 = and i32 %18, 255
%20 = tail call i32 @fputc(i32 %19, i32* %4)
%21 = fdiv float %12, 0xC033F7CEE0000000
%22 = tail call float @llvm.fmuladd.f32(float %21, float %13, float %12)
%23 = add nuw nsw i64 %11, 1
%24 = icmp eq i64 %23, 128
br i1 %24, label %25, label %10
25: ; preds = %10
%26 = tail call i32 @fclose(i32* %4)
%27 = tail call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 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 %28
28: ; preds = %25, %28
%29 = phi i64 [ 0, %25 ], [ %37, %28 ]
%30 = getelementptr inbounds [512 x i32], [512 x i32]* %3, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = and i32 %31, 255
%33 = tail call i32 @fputc(i32 %32, i32* %27)
%34 = lshr i32 %31, 8
%35 = and i32 %34, 255
%36 = tail call i32 @fputc(i32 %35, i32* %27)
%37 = add nuw nsw i64 %29, 1
%38 = icmp eq i64 %37, 256
br i1 %38, label %39, label %28
39: ; preds = %28
%40 = tail call i32 @fclose(i32* %27)
br label %41
41: ; preds = %2, %39
ret i32 0
}