#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*/ bgnline();
int /*<<< orphan*/ clear();
int /*<<< orphan*/ color(int);
int /*<<< orphan*/ endline();
int /*<<< orphan*/ gexit();
int /*<<< orphan*/ ortho2(double, int, double, double);
int /*<<< orphan*/ qdevice(int);
int qread(short *);
float sin(float);
int /*<<< orphan*/ unqdevice(int);
int /*<<< orphan*/ v2f(float *);
int /*<<< orphan*/ vinit(char *);
int /*<<< orphan*/ winopen(char *);
main() {
  float a;
  int i;
  float v[2];
  short val;
  vinit("mswin");
  winopen("bgnline/endline test");
  unqdevice(262);
  qdevice(257);
  while (qread(&val) != 261)
    ;
  color(0);
  clear();
  ortho2(-0.5, 2 * 3.14159265358979 + .5, -1.5, 1.5);
  color(2);
  bgnline();
  v[0] = -0.5;
  v[1] = 0.0;
  v2f(v);
  v[0] = 2 * 3.14159265358979 + .5;
  v[1] = 0.0;
  v2f(v);
  endline();
  color(1);
  bgnline();
  v[0] = 0.0;
  v[1] = -1.3;
  v2f(v);
  v[0] = 0.0;
  v[1] = 1.3;
  v2f(v);
  endline();
  color(3);
  bgnline();
  v[0] = v[1] = 0.0;
  v2f(v);
  for (a = 0.0; a <= 2 * 3.14159265358979; a += 3.14159265358979 / 180.0) {
    v[0] = a;
    v[1] = sin(a);
    v2f(v);
  }
  endline();
  qread(&val);
  gexit();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe52(%rip),%rdi
call   10b0 <vinit@plt>
lea    0xe4c(%rip),%rdi
call   1090 <winopen@plt>
mov    $0x106,%edi
call   1080 <unqdevice@plt>
mov    $0x101,%edi
call   1030 <qdevice@plt>
lea    -0x16(%rbp),%rdi
call   10c0 <qread@plt>
cmp    $0x105,%eax
je     1224 <main+0x54>
jmp    120b <main+0x3b>
xor    %edi,%edi
call   10a0 <color@plt>
mov    $0x0,%al
call   10f0 <clear@plt>
movsd  0xdd6(%rip),%xmm0
mov    $0x6,%edi
movsd  0xdd1(%rip),%xmm1
movsd  0xdd1(%rip),%xmm2
call   1050 <ortho2@plt>
mov    $0x2,%edi
call   10a0 <color@plt>
mov    $0x0,%al
call   1060 <bgnline@plt>
movss  0xd9f(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   10e0 <v2f@plt>
movss  0xd7d(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   10e0 <v2f@plt>
mov    $0x0,%al
call   10d0 <endline@plt>
mov    $0x1,%edi
call   10a0 <color@plt>
mov    $0x0,%al
call   1060 <bgnline@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xd3b(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   10e0 <v2f@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xd19(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   10e0 <v2f@plt>
mov    $0x0,%al
call   10d0 <endline@plt>
mov    $0x3,%edi
call   10a0 <color@plt>
mov    $0x0,%al
call   1060 <bgnline@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   10e0 <v2f@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xce9(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     138e <main+0x1be>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
call   1070 <sin@plt>
movss  %xmm0,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   10e0 <v2f@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xcb4(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    132e <main+0x15e>
mov    $0x0,%al
call   10d0 <endline@plt>
lea    -0x16(%rbp),%rdi
call   10c0 <qread@plt>
mov    $0x0,%al
call   1040 <gexit@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xe4c(%rip),%rdi
call   10b0 <vinit@plt>
lea    0xe46(%rip),%rdi
call   1090 <winopen@plt>
mov    $0x106,%edi
call   1080 <unqdevice@plt>
mov    $0x101,%edi
call   1030 <qdevice@plt>
lea    0x16(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   10c0 <qread@plt>
cmp    $0x105,%eax
jne    1210 <main+0x40>
xor    %edi,%edi
call   10a0 <color@plt>
xor    %eax,%eax
call   10f0 <clear@plt>
movsd  0xdcb(%rip),%xmm0
movsd  0xdcb(%rip),%xmm1
movsd  0xdcb(%rip),%xmm2
mov    $0x6,%edi
call   1050 <ortho2@plt>
mov    $0x2,%edi
call   10a0 <color@plt>
xor    %eax,%eax
call   1060 <bgnline@plt>
mov    $0xbf000000,%eax
mov    %rax,0xc(%rsp)
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   10e0 <v2f@plt>
movq   $0x40d90fdb,0xc(%rsp)
d9 40
mov    %rbx,%rdi
call   10e0 <v2f@plt>
xor    %eax,%eax
call   10d0 <endline@plt>
mov    $0x1,%edi
call   10a0 <color@plt>
xor    %eax,%eax
call   1060 <bgnline@plt>
movabs $0xbfa6666600000000,%rax
66 a6 bf
mov    %rax,0xc(%rsp)
mov    %rbx,%rdi
call   10e0 <v2f@plt>
movabs $0x3fa6666600000000,%rax
66 a6 3f
mov    %rax,0xc(%rsp)
mov    %rbx,%rdi
call   10e0 <v2f@plt>
xor    %eax,%eax
call   10d0 <endline@plt>
mov    $0x3,%edi
call   10a0 <color@plt>
xor    %eax,%eax
call   1060 <bgnline@plt>
movq   $0x0,0xc(%rsp)
mov    %rbx,%rdi
call   10e0 <v2f@plt>
xorps  %xmm0,%xmm0
xorps  %xmm1,%xmm1
nopl   (%rax)
movsd  %xmm1,0x18(%rsp)
movss  %xmm0,0xc(%rsp)
call   1070 <sin@plt>
movss  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
call   10e0 <v2f@plt>
movsd  0x18(%rsp),%xmm0
addsd  0xceb(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xce0(%rip),%xmm2
ucomisd %xmm1,%xmm2
jae    1300 <main+0x130>
xor    %eax,%eax
call   10d0 <endline@plt>
lea    0x16(%rsp),%rdi
call   10c0 <qread@plt>
xor    %eax,%eax
call   1040 <gexit@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"mswin\00"
@.str.1 = [21 x i8] c"bgnline/endline test\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca i32
%4 = alloca [2 x float]
%5 = alloca i16
store i32 0, i32* %1
%6 = call i32 @vinit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @winopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @unqdevice(i32 262)
%9 = call i32 @qdevice(i32 257)
br label %10
10: ; preds = %13, %0
%11 = call i32 @qread(i16* %5)
%12 = icmp ne i32 %11, 261
br i1 %12, label %13, label %14
13: ; preds = %10
br label %10
14: ; preds = %10
%15 = call i32 @color(i32 0)
%16 = call i32 (...) @clear()
%17 = call i32 @ortho2(double -5.000000e-01, i32 6, double -1.500000e+00, double 1.500000e+00)
%18 = call i32 @color(i32 2)
%19 = call i32 (...) @bgnline()
%20 = getelementptr inbounds [2 x float], [2 x float]* %4, i64 0, i64 0
store float -5.000000e-01, float* %20
%21 = getelementptr inbounds [2 x float], [2 x float]* %4, i64 0, i64 1
store float 0.000000e+00, float* %21
%22 = getelementptr inbounds [2 x float], [2 x float]* %4, i64 0, i64 0
%23 = call i32 @v2f(float* %22)
%24 = getelementptr inbounds [2 x float], [2 x float]* %4, i64 0, i64 0
store float 0x401B21FB60000000, float* %24
%25 = getelementptr inbounds [2 x float], [2 x float]* %4, i64 0, i64 1
store float 0.000000e+00, float* %25
%26 = getelementptr inbounds [2 x float], [2 x float]* %4, i64 0, i64 0
%27 = call i32 @v2f(float* %26)
%28 = call i32 (...) @endline()
%29 = call i32 @color(i32 1)
%30 = call i32 (...) @bgnline()
%31 = getelementptr inbounds [2 x float], [2 x float]* %4, i64 0, i64 0
store float 0.000000e+00, float* %31
%32 = getelementptr inbounds [2 x float], [2 x float]* %4, i64 0, i64 1
store float 0xBFF4CCCCC0000000, float* %32
%33 = getelementptr inbounds [2 x float], [2 x float]* %4, i64 0, i64 0
%34 = call i32 @v2f(float* %33)
%35 = getelementptr inbounds [2 x float], [2 x float]* %4, i64 0, i64 0
store float 0.000000e+00, float* %35
%36 = getelementptr inbounds [2 x float], [2 x float]* %4, i64 0, i64 1
store float 0x3FF4CCCCC0000000, float* %36
%37 = getelementptr inbounds [2 x float], [2 x float]* %4, i64 0, i64 0
%38 = call i32 @v2f(float* %37)
%39 = call i32 (...) @endline()
%40 = call i32 @color(i32 3)
%41 = call i32 (...) @bgnline()
%42 = getelementptr inbounds [2 x float], [2 x float]* %4, i64 0, i64 1
store float 0.000000e+00, float* %42
%43 = getelementptr inbounds [2 x float], [2 x float]* %4, i64 0, i64 0
store float 0.000000e+00, float* %43
%44 = getelementptr inbounds [2 x float], [2 x float]* %4, i64 0, i64 0
%45 = call i32 @v2f(float* %44)
store float 0.000000e+00, float* %2
br label %46
46: ; preds = %58, %14
%47 = load float, float* %2
%48 = fpext float %47 to double
%49 = fcmp ole double %48, 0x401921FB54442D11
br i1 %49, label %50, label %63
50: ; preds = %46
%51 = load float, float* %2
%52 = getelementptr inbounds [2 x float], [2 x float]* %4, i64 0, i64 0
store float %51, float* %52
%53 = load float, float* %2
%54 = call float @sin(float %53)
%55 = getelementptr inbounds [2 x float], [2 x float]* %4, i64 0, i64 1
store float %54, float* %55
%56 = getelementptr inbounds [2 x float], [2 x float]* %4, i64 0, i64 0
%57 = call i32 @v2f(float* %56)
br label %58
58: ; preds = %50
%59 = load float, float* %2
%60 = fpext float %59 to double
%61 = fadd double %60, 0x3F91DF46A2529D34
%62 = fptrunc double %61 to float
store float %62, float* %2
br label %46
63: ; preds = %46
%64 = call i32 (...) @endline()
%65 = call i32 @qread(i16* %5)
%66 = call i32 (...) @gexit()
%67 = load i32, i32* %1
ret i32 %67
}

LLVM IR (-O2):
@.str = [6 x i8] c"mswin\00"
@.str.1 = [21 x i8] c"bgnline/endline test\00"
define i32 @main() {
%1 = alloca [2 x float]
%2 = alloca i16
%3 = bitcast [2 x float]* %1 to i8*
%4 = bitcast i16* %2 to i8*
%5 = tail call i32 @vinit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @winopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @unqdevice(i32 262)
%8 = tail call i32 @qdevice(i32 257)
br label %9
9: ; preds = %9, %0
%10 = call i32 @qread(i16* %2)
%11 = icmp eq i32 %10, 261
br i1 %11, label %12, label %9
12: ; preds = %9
%13 = call i32 @color(i32 0)
%14 = call i32 (...) @clear()
%15 = call i32 @ortho2(double -5.000000e-01, i32 6, double -1.500000e+00, double 1.500000e+00)
%16 = call i32 @color(i32 2)
%17 = call i32 (...) @bgnline()
%18 = getelementptr inbounds [2 x float], [2 x float]* %1, i64 0, i64 0
store float -5.000000e-01, float* %18
%19 = getelementptr inbounds [2 x float], [2 x float]* %1, i64 0, i64 1
store float 0.000000e+00, float* %19
%20 = call i32 @v2f(float* %18)
store float 0x401B21FB60000000, float* %18
store float 0.000000e+00, float* %19
%21 = call i32 @v2f(float* %18)
%22 = call i32 (...) @endline()
%23 = call i32 @color(i32 1)
%24 = call i32 (...) @bgnline()
store float 0.000000e+00, float* %18
store float 0xBFF4CCCCC0000000, float* %19
%25 = call i32 @v2f(float* %18)
store float 0.000000e+00, float* %18
store float 0x3FF4CCCCC0000000, float* %19
%26 = call i32 @v2f(float* %18)
%27 = call i32 (...) @endline()
%28 = call i32 @color(i32 3)
%29 = call i32 (...) @bgnline()
store float 0.000000e+00, float* %19
store float 0.000000e+00, float* %18
%30 = call i32 @v2f(float* %18)
br label %31
31: ; preds = %12, %31
%32 = phi double [ 0.000000e+00, %12 ], [ %38, %31 ]
%33 = phi float [ 0.000000e+00, %12 ], [ %37, %31 ]
store float %33, float* %18
%34 = call float @sin(float %33)
store float %34, float* %19
%35 = call i32 @v2f(float* %18)
%36 = fadd double %32, 0x3F91DF46A2529D34
%37 = fptrunc double %36 to float
%38 = fpext float %37 to double
%39 = fcmp ugt double %38, 0x401921FB54442D11
br i1 %39, label %40, label %31
40: ; preds = %31
%41 = call i32 (...) @endline()
%42 = call i32 @qread(i16* %2)
%43 = call i32 (...) @gexit()
ret i32 0
}