#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*/ cga_end();
int /*<<< orphan*/ cga_start();
double get_msdos_time();
int /*<<< orphan*/ hat_slab(int, int);
int /*<<< orphan*/ printf(char *, double, double, double);
double sin(int);
double sqrt(int);
int /*<<< orphan*/ wait_for_key();
int main() {
  double start = get_msdos_time() / 100.0;
  int p = 160;
  int q = 100;
  int xp = 144;
  int yp = 56;
  int zp = 64;
  int yr = 1;
  double xr = 1.5 * 3.14159265358979323846;
  double xf = (double)xr / (double)xp;
  double yf = (double)yp / (double)yr;
  int zi;
  double finish;
  cga_start();
  for (zi = -q; zi < q; ++zi) {
    if ((zi >= -zp) && (zi <= zp)) {
      double zt = (double)zi * (double)xp / (double)zp;
      int zz = zi;
      int xl = 0.5 + sqrt((double)xp * (double)xp - zt * zt);
      int xi;
      for (xi = -xl; xi <= xl; ++xi) {
        double xt = sqrt(xi * xi + zt * zt) * xf;
        double xx = xi;
        double yy = (sin(xt) + 0.4 * sin(3 * xt)) * yf;
        int x1 = p - xx - zz;
        int y1 = q - yy + zz;
        hat_slab(x1, y1);
      }
    }
  }
  finish = get_msdos_time() / 100.0;
  wait_for_key();
  cga_end();
  printf("Start time: %5.2lf\nFinish time: %5.2lf\nTime spent: %5.2lf", start,
         finish, finish - start);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <get_msdos_time@plt>
movsd  0xe67(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0xa0,-0x14(%rbp)
movl   $0x64,-0x18(%rbp)
movl   $0x90,-0x1c(%rbp)
movl   $0x38,-0x20(%rbp)
movl   $0x40,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
movsd  0xe24(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
cvtsi2sdl -0x20(%rbp),%xmm0
cvtsi2sdl -0x28(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    $0x0,%al
call   1070 <cga_start@plt>
xor    %eax,%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    13bb <main+0x23b>
mov    -0x44(%rbp),%eax
xor    %ecx,%ecx
sub    -0x24(%rbp),%ecx
cmp    %ecx,%eax
jl     13a8 <main+0x228>
mov    -0x44(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     13a8 <main+0x228>
cvtsi2sdl -0x44(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x5c(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xd69(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x60(%rbp)
xor    %eax,%eax
sub    -0x60(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x60(%rbp),%eax
jg     13a3 <main+0x223>
mov    -0x64(%rbp),%eax
imul   -0x64(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  -0x58(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <sqrt@plt>
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
cvtsi2sdl -0x64(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
cvttsd2si -0x70(%rbp),%edi
call   1080 <sin@plt>
movsd  %xmm0,-0x90(%rbp)
ff
movsd  0xd06(%rip),%xmm0
mulsd  -0x70(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1080 <sin@plt>
movsd  -0x90(%rbp),%xmm1
ff
movsd  0xce0(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
subsd  -0x78(%rbp),%xmm0
cvtsi2sdl -0x5c(%rbp),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x84(%rbp)
cvtsi2sdl -0x18(%rbp),%xmm0
subsd  -0x80(%rbp),%xmm0
cvtsi2sdl -0x5c(%rbp),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x88(%rbp)
mov    -0x84(%rbp),%edi
mov    -0x88(%rbp),%esi
call   1060 <hat_slab@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    12ba <main+0x13a>
jmp    13a8 <main+0x228>
jmp    13ad <main+0x22d>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1216 <main+0x96>
mov    $0x0,%al
call   1040 <get_msdos_time@plt>
movsd  0xc3e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    $0x0,%al
call   1090 <wait_for_key@plt>
mov    $0x0,%al
call   1030 <cga_end@plt>
movsd  -0x10(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
subsd  -0x10(%rbp),%xmm2
lea    0xc2c(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
xor    %eax,%eax
call   1040 <get_msdos_time@plt>
movaps %xmm0,0x40(%rsp)
xor    %eax,%eax
call   1070 <cga_start@plt>
mov    $0xffffff9c,%r14d
movsd  0xe57(%rip),%xmm0
jmp    11cc <main+0x4c>
nopl   0x0(%rax,%rax,1)
movsd  0x8(%rsp),%xmm0
addsd  0xe9a(%rip),%xmm0
add    $0x1,%r14d
cmp    $0x64,%r14d
je     12e8 <main+0x168>
movsd  %xmm0,0x8(%rsp)
lea    0x40(%r14),%eax
cmp    $0x80,%eax
ja     11b0 <main+0x30>
movsd  0x8(%rsp),%xmm1
mulsd  0xe1d(%rip),%xmm1
mulsd  0xe1d(%rip),%xmm1
mulsd  %xmm1,%xmm1
movsd  0xe19(%rip),%xmm0
movsd  %xmm1,0x28(%rsp)
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <sqrt@plt>
addsd  0xe06(%rip),%xmm0
cvttsd2si %xmm0,%eax
test   %eax,%eax
js     11b0 <main+0x30>
mov    %eax,%ebp
neg    %ebp
lea    (%rax,%rax,1),%ebx
add    $0x1,%ebx
nopl   0x0(%rax)
mov    %ebp,%eax
imul   %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x28(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <sqrt@plt>
xorps  %xmm2,%xmm2
cvtsi2sd %ebp,%xmm2
mulsd  0xdce(%rip),%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  0xde0(%rip),%xmm1
subsd  %xmm2,%xmm1
movsd  %xmm1,0x10(%rsp)
cvttsd2si %xmm0,%edi
call   1080 <sin@plt>
movsd  %xmm0,0x38(%rsp)
movsd  0x30(%rsp),%xmm0
mulsd  0xda1(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1080 <sin@plt>
mulsd  0xd98(%rip),%xmm0
addsd  0x38(%rsp),%xmm0
mulsd  0xd92(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
subsd  %xmm1,%xmm2
cvttsd2si %xmm2,%edi
addsd  0xd86(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
call   1060 <hat_slab@plt>
add    $0x1,%ebp
add    $0xffffffff,%ebx
jne    1230 <main+0xb0>
jmp    11b0 <main+0x30>
xor    %eax,%eax
call   1040 <get_msdos_time@plt>
unpcklpd 0x40(%rsp),%xmm0
divpd  0xd63(%rip),%xmm0
movapd %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1090 <wait_for_key@plt>
xor    %eax,%eax
call   1030 <cga_end@plt>
movapd 0x10(%rsp),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
lea    0xd42(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [58 x i8] c"Start time: %5.2lf\0AFinish time: %5.2lf\0ATime spent: %5.2lf\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca i32
%22 = alloca i32
store i32 0, i32* %1
%23 = call double (...) @get_msdos_time()
%24 = fdiv double %23, 1.000000e+02
store double %24, double* %2
store i32 160, i32* %3
store i32 100, i32* %4
store i32 144, i32* %5
store i32 56, i32* %6
store i32 64, i32* %7
store i32 1, i32* %8
store double 0x4012D97C7F3321D2, double* %9
%25 = load double, double* %9
%26 = load i32, i32* %5
%27 = sitofp i32 %26 to double
%28 = fdiv double %25, %27
store double %28, double* %10
%29 = load i32, i32* %6
%30 = sitofp i32 %29 to double
%31 = load i32, i32* %8
%32 = sitofp i32 %31 to double
%33 = fdiv double %30, %32
store double %33, double* %11
%34 = call i32 (...) @cga_start()
%35 = load i32, i32* %4
%36 = sub nsw i32 0, %35
store i32 %36, i32* %12
br label %37
37: ; preds = %127, %0
%38 = load i32, i32* %12
%39 = load i32, i32* %4
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %130
41: ; preds = %37
%42 = load i32, i32* %12
%43 = load i32, i32* %7
%44 = sub nsw i32 0, %43
%45 = icmp sge i32 %42, %44
br i1 %45, label %46, label %126
46: ; preds = %41
%47 = load i32, i32* %12
%48 = load i32, i32* %7
%49 = icmp sle i32 %47, %48
br i1 %49, label %50, label %126
50: ; preds = %46
%51 = load i32, i32* %12
%52 = sitofp i32 %51 to double
%53 = load i32, i32* %5
%54 = sitofp i32 %53 to double
%55 = fmul double %52, %54
%56 = load i32, i32* %7
%57 = sitofp i32 %56 to double
%58 = fdiv double %55, %57
store double %58, double* %14
%59 = load i32, i32* %12
store i32 %59, i32* %15
%60 = load i32, i32* %5
%61 = sitofp i32 %60 to double
%62 = load i32, i32* %5
%63 = sitofp i32 %62 to double
%64 = load double, double* %14
%65 = load double, double* %14
%66 = fmul double %64, %65
%67 = fneg double %66
%68 = call double @llvm.fmuladd.f64(double %61, double %63, double %67)
%69 = fptosi double %68 to i32
%70 = call double @sqrt(i32 %69)
%71 = fadd double 5.000000e-01, %70
%72 = fptosi double %71 to i32
store i32 %72, i32* %16
%73 = load i32, i32* %16
%74 = sub nsw i32 0, %73
store i32 %74, i32* %17
br label %75
75: ; preds = %122, %50
%76 = load i32, i32* %17
%77 = load i32, i32* %16
%78 = icmp sle i32 %76, %77
br i1 %78, label %79, label %125
79: ; preds = %75
%80 = load i32, i32* %17
%81 = load i32, i32* %17
%82 = mul nsw i32 %80, %81
%83 = sitofp i32 %82 to double
%84 = load double, double* %14
%85 = load double, double* %14
%86 = call double @llvm.fmuladd.f64(double %84, double %85, double %83)
%87 = fptosi double %86 to i32
%88 = call double @sqrt(i32 %87)
%89 = load double, double* %10
%90 = fmul double %88, %89
store double %90, double* %18
%91 = load i32, i32* %17
%92 = sitofp i32 %91 to double
store double %92, double* %19
%93 = load double, double* %18
%94 = fptosi double %93 to i32
%95 = call double @sin(i32 %94)
%96 = load double, double* %18
%97 = fmul double 3.000000e+00, %96
%98 = fptosi double %97 to i32
%99 = call double @sin(i32 %98)
%100 = call double @llvm.fmuladd.f64(double 4.000000e-01, double %99, double %95)
%101 = load double, double* %11
%102 = fmul double %100, %101
store double %102, double* %20
%103 = load i32, i32* %3
%104 = sitofp i32 %103 to double
%105 = load double, double* %19
%106 = fsub double %104, %105
%107 = load i32, i32* %15
%108 = sitofp i32 %107 to double
%109 = fsub double %106, %108
%110 = fptosi double %109 to i32
store i32 %110, i32* %21
%111 = load i32, i32* %4
%112 = sitofp i32 %111 to double
%113 = load double, double* %20
%114 = fsub double %112, %113
%115 = load i32, i32* %15
%116 = sitofp i32 %115 to double
%117 = fadd double %114, %116
%118 = fptosi double %117 to i32
store i32 %118, i32* %22
%119 = load i32, i32* %21
%120 = load i32, i32* %22
%121 = call i32 @hat_slab(i32 %119, i32 %120)
br label %122
122: ; preds = %79
%123 = load i32, i32* %17
%124 = add nsw i32 %123, 1
store i32 %124, i32* %17
br label %75
125: ; preds = %75
br label %126
126: ; preds = %125, %46, %41
br label %127
127: ; preds = %126
%128 = load i32, i32* %12
%129 = add nsw i32 %128, 1
store i32 %129, i32* %12
br label %37
130: ; preds = %37
%131 = call double (...) @get_msdos_time()
%132 = fdiv double %131, 1.000000e+02
store double %132, double* %13
%133 = call i32 (...) @wait_for_key()
%134 = call i32 (...) @cga_end()
%135 = load double, double* %2
%136 = load double, double* %13
%137 = load double, double* %13
%138 = load double, double* %2
%139 = fsub double %137, %138
%140 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), double %135, double %136, double %139)
ret i32 0
}

LLVM IR (-O2):
@.str = [58 x i8] c"Start time: %5.2lf\0AFinish time: %5.2lf\0ATime spent: %5.2lf\00"
define i32 @main() {
%1 = tail call double (...) @get_msdos_time()
%2 = tail call i32 (...) @cga_start()
br label %3
3: ; preds = %0, %45
%4 = phi i32 [ -100, %0 ], [ %46, %45 ]
%5 = add nsw i32 %4, 64
%6 = icmp ult i32 %5, 129
br i1 %6, label %7, label %45
7: ; preds = %3
%8 = sitofp i32 %4 to double
%9 = fmul double %8, 1.440000e+02
%10 = fmul double %9, 1.562500e-02
%11 = fmul double %10, %10
%12 = fsub double 2.073600e+04, %11
%13 = fptosi double %12 to i32
%14 = tail call double @sqrt(i32 %13)
%15 = fadd double %14, 5.000000e-01
%16 = fptosi double %15 to i32
%17 = icmp slt i32 %16, 0
br i1 %17, label %45, label %18
18: ; preds = %7
%19 = sub nsw i32 0, %16
br label %20
20: ; preds = %18, %20
%21 = phi i32 [ %43, %20 ], [ %19, %18 ]
%22 = mul nsw i32 %21, %21
%23 = sitofp i32 %22 to double
%24 = tail call double @llvm.fmuladd.f64(double %10, double %10, double %23)
%25 = fptosi double %24 to i32
%26 = tail call double @sqrt(i32 %25)
%27 = fmul double %26, 0x3FA0C152382D7365
%28 = sitofp i32 %21 to double
%29 = fptosi double %27 to i32
%30 = tail call double @sin(i32 %29)
%31 = fmul double %27, 3.000000e+00
%32 = fptosi double %31 to i32
%33 = tail call double @sin(i32 %32)
%34 = tail call double @llvm.fmuladd.f64(double %33, double 4.000000e-01, double %30)
%35 = fmul double %34, 5.600000e+01
%36 = fsub double 1.600000e+02, %28
%37 = fsub double %36, %8
%38 = fptosi double %37 to i32
%39 = fsub double 1.000000e+02, %35
%40 = fadd double %39, %8
%41 = fptosi double %40 to i32
%42 = tail call i32 @hat_slab(i32 %38, i32 %41)
%43 = add i32 %21, 1
%44 = icmp eq i32 %21, %16
br i1 %44, label %45, label %20
45: ; preds = %20, %7, %3
%46 = add nsw i32 %4, 1
%47 = icmp eq i32 %46, 100
br i1 %47, label %48, label %3
48: ; preds = %45
%49 = tail call double (...) @get_msdos_time()
%50 = insertelement <2 x double> poison, double %1, i64 1
%51 = insertelement <2 x double> %50, double %49, i64 0
%52 = fdiv <2 x double> %51, <double 1.000000e+02, double 1.000000e+02>
%53 = tail call i32 (...) @wait_for_key()
%54 = tail call i32 (...) @cga_end()
%55 = extractelement <2 x double> %52, i64 0
%56 = extractelement <2 x double> %52, i64 1
%57 = fsub double %55, %56
%58 = tail call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), double %56, double %55, double %57)
ret i32 0
}