#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*/ drawLine(int, int, int, int);
int /*<<< orphan*/ drawRect(int, int, int, int);
int sin(double);
int main() {
  drawLine(10, 150, 400, 150);
  drawLine(20, 10, 20, 290);
  for (double i = 0; i < 3.1416 * 2; i += 0.01) {
    drawRect((int)(i / (2 * 3.1416) * 380) + 20, 150 + (int)(sin(i) * 140), 1,
             1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xa,%edi
mov    $0x96,%ecx
mov    $0x190,%edx
mov    %ecx,%esi
call   1030 <drawLine@plt>
mov    $0x14,%edx
mov    $0xa,%esi
mov    $0x122,%ecx
mov    %edx,%edi
call   1030 <drawLine@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe85(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11e9 <main+0xb9>
movsd  -0x10(%rbp),%xmm0
movsd  0xe6d(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe69(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x14,%eax
mov    %eax,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <sin@plt>
mov    -0x14(%rbp),%edi
imul   $0x8c,%eax,%esi
add    $0x96,%esi
mov    $0x1,%ecx
mov    %ecx,%edx
call   1050 <drawRect@plt>
movsd  0xe36(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1173 <main+0x43>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0xa,%edi
mov    $0x96,%esi
mov    $0x190,%edx
mov    $0x96,%ecx
call   1030 <drawLine@plt>
mov    $0x14,%edi
mov    $0xa,%esi
mov    $0x14,%edx
mov    $0x122,%ecx
call   1030 <drawLine@plt>
xorpd  %xmm0,%xmm0
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0xe7c(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  0xe78(%rip),%xmm0
cvttsd2si %xmm0,%ebx
add    $0x14,%ebx
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
imul   $0x8c,%eax,%esi
add    $0x96,%esi
mov    %ebx,%edi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1050 <drawRect@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xe43(%rip),%xmm0
movsd  0xe2b(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     1170 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca double
store i32 0, i32* %1
%3 = call i32 @drawLine(i32 10, i32 150, i32 400, i32 150)
%4 = call i32 @drawLine(i32 20, i32 10, i32 20, i32 290)
store double 0.000000e+00, double* %2
br label %5
5: ; preds = %19, %0
%6 = load double, double* %2
%7 = fcmp olt double %6, 6.283200e+00
br i1 %7, label %8, label %22
8: ; preds = %5
%9 = load double, double* %2
%10 = fdiv double %9, 6.283200e+00
%11 = fmul double %10, 3.800000e+02
%12 = fptosi double %11 to i32
%13 = add nsw i32 %12, 20
%14 = load double, double* %2
%15 = call i32 @sin(double %14)
%16 = mul nsw i32 %15, 140
%17 = add nsw i32 150, %16
%18 = call i32 @drawRect(i32 %13, i32 %17, i32 1, i32 1)
br label %19
19: ; preds = %8
%20 = load double, double* %2
%21 = fadd double %20, 1.000000e-02
store double %21, double* %2
br label %5
22: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @drawLine(i32 10, i32 150, i32 400, i32 150)
%2 = tail call i32 @drawLine(i32 20, i32 10, i32 20, i32 290)
br label %4
3: ; preds = %4
ret i32 0
4: ; preds = %0, %4
%5 = phi double [ 0.000000e+00, %0 ], [ %14, %4 ]
%6 = fdiv double %5, 6.283200e+00
%7 = fmul double %6, 3.800000e+02
%8 = fptosi double %7 to i32
%9 = add nsw i32 %8, 20
%10 = tail call i32 @sin(double %5)
%11 = mul nsw i32 %10, 140
%12 = add nsw i32 %11, 150
%13 = tail call i32 @drawRect(i32 %9, i32 %12, i32 1, i32 1)
%14 = fadd double %5, 1.000000e-02
%15 = fcmp olt double %14, 6.283200e+00
br i1 %15, label %4, label %3
}