#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*/ winopen(char *);
main() {
  float a;
  int i;
  float v[2];
  short val;
  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    0xe62(%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   10b0 <qread@plt>
cmp    $0x105,%eax
je     1208 <main+0x48>
jmp    11ef <main+0x2f>
xor    %edi,%edi
call   10a0 <color@plt>
mov    $0x0,%al
call   10e0 <clear@plt>
movsd  0xdf2(%rip),%xmm0
mov    $0x6,%edi
movsd  0xded(%rip),%xmm1
movsd  0xded(%rip),%xmm2
call   1050 <ortho2@plt>
mov    $0x2,%edi
call   10a0 <color@plt>
mov    $0x0,%al
call   1060 <bgnline@plt>
movss  0xdbb(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   10d0 <v2f@plt>
movss  0xd99(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   10d0 <v2f@plt>
mov    $0x0,%al
call   10c0 <endline@plt>
mov    $0x1,%edi
call   10a0 <color@plt>
mov    $0x0,%al
call   1060 <bgnline@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xd57(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   10d0 <v2f@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xd35(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   10d0 <v2f@plt>
mov    $0x0,%al
call   10c0 <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   10d0 <v2f@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xd05(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1372 <main+0x1b2>
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   10d0 <v2f@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xcd0(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1312 <main+0x152>
mov    $0x0,%al
call   10c0 <endline@plt>
lea    -0x16(%rbp),%rdi
call   10b0 <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    0xe5c(%rip),%rdi
call   1090 <winopen@plt>
mov    $0x106,%edi
call   1080 <unqdevice@plt>
mov    $0x101,%edi
call   1030 <qdevice@plt>
lea    0x16(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   10b0 <qread@plt>
cmp    $0x105,%eax
jne    11f0 <main+0x30>
xor    %edi,%edi
call   10a0 <color@plt>
xor    %eax,%eax
call   10e0 <clear@plt>
movsd  0xdeb(%rip),%xmm0
movsd  0xdeb(%rip),%xmm1
movsd  0xdeb(%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   10d0 <v2f@plt>
movq   $0x40d90fdb,0xc(%rsp)
d9 40
mov    %rbx,%rdi
call   10d0 <v2f@plt>
xor    %eax,%eax
call   10c0 <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   10d0 <v2f@plt>
movabs $0x3fa6666600000000,%rax
66 a6 3f
mov    %rax,0xc(%rsp)
mov    %rbx,%rdi
call   10d0 <v2f@plt>
xor    %eax,%eax
call   10c0 <endline@plt>
mov    $0x3,%edi
call   10a0 <color@plt>
xor    %eax,%eax
call   1060 <bgnline@plt>
movq   $0x0,0xc(%rsp)
mov    %rbx,%rdi
call   10d0 <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   10d0 <v2f@plt>
movsd  0x18(%rsp),%xmm0
addsd  0xd0b(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xd00(%rip),%xmm2
ucomisd %xmm1,%xmm2
jae    12e0 <main+0x120>
xor    %eax,%eax
call   10c0 <endline@plt>
lea    0x16(%rsp),%rdi
call   10b0 <qread@plt>
xor    %eax,%eax
call   1040 <gexit@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

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

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