// File: /workspace/github_c_makefile_star2_O3/jrrk[P]cbzone/c_graphics.c
// Function: drawhorizon
void drawhorizon(azm)
     float azm;
{
  static short horizon[] = {500, 240, 500, 240, 500, 240, 500, 240,
                              500, 240, 500, 240, 500, 240, 500, 240,
                              500, 240, 500, 240, 500, 240, 500, 240,
                              500, 240, 500, 240, 500, 240, 500, 240,
                              500, 240, 500, 240, 500, 240, 500, 240,
                              500, 240, 500, 240, 500, 240, 500, 240,
                              500, 240, 500, 240, 500, 240, 500, 240,
                              500, 240, 500, 240, 500, 240, 500, 240,
                              500, 240, 500, 240, 500, 240, 500, 240,
                              500, 240, 500, 240, 500, 240, 500, 240,
                              500, 240, 500, 240, 500, 240, 500, 240,
                              500, 240, 500, 240, 500, 240, 500, 240};
  static int number = 0;
  static float rdc = 0.01745329251;
  static float scale = 15.0;
  static int numclust[] = {8, 12, 10, 12, 10, 10};
  static int clustux[][12] = {150, 140, 150, 60, 85, -100, -50, -150, 0, 0,
                                0, 0, 150, 50, 75, 0, 0, 7, 0, -40, 0, -110,
                                -25, -150, 150, 115, 115, 105, 115, -10, 0,
                                -125, -85, -150, 0, 0, 150, 130, 150, 10, 25,
                                -35, -35, 0, -35, -140, -110, -150, 150, -10,
                                25, -70, -50, -125, -125, -100, -125, -150,
                                0, 0, 150, 100, 140, 0, 0, -30, 0, -120, -60,
                                -150, 0, 0};
  static int clustuy[][12] = {160, 220, 160, 250, 225, 245, 250, 240, 0, 0, 0,
                                0, 240, 227, 245, 190, 190, 215, 190, 225, 190,
                                213, 240, 200, 200, 189, 189, 225, 189, 244,
                                250, 165, 213, 135, 0, 0, 135, 200, 135, 210,
                                225, 165, 165, 230, 165, 228, 210, 215, 215,
                                217, 230, 195, 210, 150, 150, 210, 150, 173,
                                0, 0, 173, 209, 225, 170, 170, 225, 170, 230,
                                200, 160, 0, 0};
  static int pt[2];
  static Bool moon = False;

  float center, xoff;
  float deg, degmin, degmax;
  int indmin, indmax, i, i1, j;
  Bool flag1, flag2;
  short* current;

  gprsetdrawvalue(opt->cpi[COLOR_BG]);
  multiline(horizon, number);           /* erase horizon */
  if (moon)
    removepixmap(0, pt);                /* erase moon    */
  gprsetdrawvalue(opt->cpi[COLOR_HORIZON]);
  deg = azm / rdc;
  if (deg >= 360.0)
    deg -= 360.0;
  degmin = deg - 30.0;
  degmax = deg + 30.0;
  flag1 = False;
  flag2 = False;
  if (degmin < 0.0) {
    degmin += 360.0;
    flag1 = True;
  }
  if (degmax >= 360.0) {
    degmax -= 360.0;
    flag2 = True;
  }
  indmin = (int) (degmin / 20.0);
  indmax = (int) (degmax / 20.0) + 1;
  number = 0;
  current = horizon;
  if (!flag1 && !flag2)
    for (i=indmin; i<indmax; i++) {
      center = 10.0 + i * 20.0;
      xoff = (deg - center) * scale + 500.0;
      i1 = i % 6;
      for (j= 0; j<numclust[i1]; j++){
        *current++ = clustux[i1][j] + xoff;
        *current++ = clustuy[i1][j];
        number++;
      }
    }
  else if (flag1) {
    for (i= indmin; i<18; i++) {
      center = 10.0 + i * 20.0;
      xoff = (360.0 + deg - center) * scale + 500.0;
      i1 = i % 6;
      for (j=0; j<numclust[i1]; j++) {
        *current++ = clustux[i1][j] + xoff;
        *current++ = clustuy[i1][j];
        number++;
      }
    }
    for (i=0; i<indmax; i++) {
      center = 10.0 + i * 20.0;
      xoff = (deg - center) * scale + 500.0;
      i1 = i % 6;
      for (j=0; j<numclust[i1]; j++) {
        *current++ = clustux[i1][j] + xoff;
        *current++ = clustuy[i1][j];
        number++;
      }
    }
  }
  else {
    for (i=indmin; i<18; i++) {
      center = 10.0 + i * 20.0;
      xoff = (deg - center) * scale + 500.0;
      i1 = i % 6;
      for (j=0; j<numclust[i1]; j++) {
        *current++ = clustux[i1][j] + xoff;
        *current++ = clustuy[i1][j];
        number++;
      }
    }
    for (i=0; i<indmax; i++) {
      center = 10.0 + i * 20.0;
      xoff = (deg - 360.0 - center) * scale + 500.0;
      i1 = i % 6;
      for (j=0; j<numclust[i1]; j++) {
        *current++ = clustux[i1][j] + xoff;
        *current++ = clustuy[i1][j];
        number++;
      }
    }
  }
  number >>= 1;
  multiline(horizon, number);           /* draw horizon */
  if (deg <= 360.0 && deg >= 270.0) {
    moon = True;
    pt[0] = 500 + (deg - 315.0) * scale - 20;
    pt[1] = 105 - 20;
    putpixmap(0, pt);                   /* draw moon    */
  }
  else
    moon = False;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
cvtsd2ss %xmm0, %xmm0
movaps %xmm0, (%rsp)
leaq 0xbd7c(%rip), %r14      # 0x14580
movq (%r14), %rax
movl 0xf0(%rax), %edi
xorl %eax, %eax
callq 0x7660
movl 0xbf82(%rip), %esi      # 0x1479c
leaq 0xbbef(%rip), %rbx      # 0x14410
movq %rbx, %rdi
xorl %eax, %eax
callq 0x6ed0
cmpb $0x1, 0xbf76(%rip)      # 0x147a8
jne 0x8844
leaq 0xbf65(%rip), %rsi      # 0x147a0
xorl %edi, %edi
xorl %eax, %eax
callq 0x7a06
movq (%r14), %rax
movl 0x108(%rax), %edi
xorl %eax, %eax
callq 0x7660
movaps (%rsp), %xmm3
divss 0x5ed4(%rip), %xmm3     # 0xe734
movss 0x5ed0(%rip), %xmm0     # 0xe738
movaps %xmm3, %xmm1
addss %xmm0, %xmm1
movss 0x5ec5(%rip), %xmm4     # 0xe73c
movaps %xmm4, %xmm9
cmpnless %xmm3, %xmm9
movaps %xmm9, %xmm2
andnps %xmm1, %xmm2
andps %xmm3, %xmm9
orps %xmm2, %xmm9
movss 0x5ea8(%rip), %xmm1     # 0xe740
addss %xmm9, %xmm1
movss 0x5e9f(%rip), %xmm2     # 0xe744
addss %xmm9, %xmm2
xorps %xmm3, %xmm3
ucomiss %xmm1, %xmm3
seta %cl
movaps %xmm1, %xmm3
jbe 0x88bc
addss %xmm4, %xmm3
ucomiss %xmm4, %xmm2
setae %dl
jb 0x88c8
addss %xmm0, %xmm2
cvtss2sd %xmm9, %xmm6
cvtss2sd %xmm3, %xmm3
movsd 0x579f(%rip), %xmm0     # 0xe078
divsd %xmm0, %xmm3
cvttsd2si %xmm3, %eax
cvtss2sd %xmm2, %xmm2
divsd %xmm0, %xmm2
cvttsd2si %xmm2, %edi
orb %dl, %cl
movsd %xmm6, 0x10(%rsp)
je 0x8a10
xorpd %xmm2, %xmm2
ucomiss %xmm1, %xmm2
jbe 0x8b00
cmpl $0x11, %eax
jg 0x8bf4
movsd 0x5cff(%rip), %xmm1     # 0xe618
addsd %xmm6, %xmm1
xorl %esi, %esi
leaq 0xbaea(%rip), %rbx      # 0x14410
movsd 0x5cc2(%rip), %xmm2     # 0xe5f0
movsd 0x5cd2(%rip), %xmm3     # 0xe608
movsd 0x5cd2(%rip), %xmm4     # 0xe610
leaq 0x5e3b(%rip), %rcx      # 0xe780
movl $0x1, %edx
leaq 0x5e4f(%rip), %r9       # 0xe7a0
leaq 0x5f68(%rip), %r10      # 0xe8c0
movq %rbx, %r8
xorps %xmm5, %xmm5
cvtsi2sd %eax, %xmm5
mulsd %xmm0, %xmm5
addsd %xmm2, %xmm5
cvtsd2ss %xmm5, %xmm5
cvtss2sd %xmm5, %xmm5
movapd %xmm1, %xmm6
subsd %xmm5, %xmm6
mulsd %xmm3, %xmm6
addsd %xmm4, %xmm6
xorps %xmm5, %xmm5
cvtsd2ss %xmm6, %xmm5
movslq %eax, %r11
imulq $0x2aaaaaab, %r11, %rbx # imm = 0x2AAAAAAB
movq %rbx, %r14
shrq $0x3f, %r14
shrq $0x20, %rbx
addl %r14d, %ebx
addl %ebx, %ebx
leal (%rbx,%rbx,2), %ebx
subl %ebx, %r11d
movslq %r11d, %r11
movl (%rcx,%r11,4), %ebx
cmpl $0x2, %ebx
cmovll %edx, %ebx
shlq $0x4, %r11
leaq (%r11,%r11,2), %r14
leaq (,%rbx,4), %r15
xorl %r11d, %r11d
leaq (%r14,%r11), %r12
xorps %xmm6, %xmm6
cvtsi2ssl (%r9,%r12), %xmm6
addss %xmm5, %xmm6
cvttss2si %xmm6, %ebp
movw %bp, (%r8,%r11)
movzwl (%r10,%r12), %ebp
movw %bp, 0x2(%r8,%r11)
addq $0x4, %r11
cmpq %r11, %r15
jne 0x89c9
addl %ebx, %esi
incl %eax
leaq (%r8,%r11), %rbx
cmpl $0x12, %eax
jne 0x8958
addq %r11, %r8
jmp 0x8bfd
xorl %esi, %esi
cmpl %edi, %eax
jg 0x8e42
xorl %esi, %esi
movsd 0x5bcc(%rip), %xmm1     # 0xe5f0
movss 0x5d1c(%rip), %xmm2     # 0xe748
movss 0x5d18(%rip), %xmm3     # 0xe74c
leaq 0x5d45(%rip), %rcx      # 0xe780
movl $0x1, %edx
leaq 0x5d59(%rip), %r8       # 0xe7a0
leaq 0x5e72(%rip), %r9       # 0xe8c0
xorps %xmm4, %xmm4
cvtsi2sd %eax, %xmm4
mulsd %xmm0, %xmm4
addsd %xmm1, %xmm4
xorps %xmm5, %xmm5
cvtsd2ss %xmm4, %xmm5
movaps %xmm9, %xmm4
subss %xmm5, %xmm4
mulss %xmm2, %xmm4
addss %xmm3, %xmm4
movslq %eax, %r10
imulq $0x2aaaaaab, %r10, %r11 # imm = 0x2AAAAAAB
movq %r11, %r14
shrq $0x3f, %r14
shrq $0x20, %r11
addl %r14d, %r11d
addl %r11d, %r11d
leal (%r11,%r11,2), %r11d
subl %r11d, %r10d
movslq %r10d, %r11
movl (%rcx,%r11,4), %r10d
cmpl $0x2, %r10d
cmovll %edx, %r10d
shlq $0x4, %r11
leaq (%r11,%r11,2), %r14
leaq (,%r10,4), %r15
xorl %r11d, %r11d
leaq (%r14,%r11), %r12
xorps %xmm5, %xmm5
cvtsi2ssl (%r8,%r12), %xmm5
addss %xmm4, %xmm5
cvttss2si %xmm5, %ebp
movw %bp, (%rbx,%r11)
movzwl (%r9,%r12), %ebp
movw %bp, 0x2(%rbx,%r11)
addq $0x4, %r11
cmpq %r11, %r15
jne 0x8ab8
addl %r10d, %esi
leal 0x1(%rax), %r10d
addq %r11, %rbx
cmpl %edi, %eax
movl %r10d, %eax
jne 0x8a4e
jmp 0x8e42
cmpl $0x11, %eax
jg 0x8d11
xorl %esi, %esi
leaq 0xb8fe(%rip), %rbx      # 0x14410
movsd 0x5ad6(%rip), %xmm1     # 0xe5f0
movss 0x5c26(%rip), %xmm2     # 0xe748
movss 0x5c22(%rip), %xmm3     # 0xe74c
leaq 0x5c4f(%rip), %rcx      # 0xe780
movl $0x1, %edx
leaq 0x5c63(%rip), %r9       # 0xe7a0
leaq 0x5d7c(%rip), %r10      # 0xe8c0
movq %rbx, %r8
xorps %xmm4, %xmm4
cvtsi2sd %eax, %xmm4
mulsd %xmm0, %xmm4
addsd %xmm1, %xmm4
xorps %xmm5, %xmm5
cvtsd2ss %xmm4, %xmm5
movaps %xmm9, %xmm4
subss %xmm5, %xmm4
mulss %xmm2, %xmm4
addss %xmm3, %xmm4
movslq %eax, %r11
imulq $0x2aaaaaab, %r11, %rbx # imm = 0x2AAAAAAB
movq %rbx, %r14
shrq $0x3f, %r14
shrq $0x20, %rbx
addl %r14d, %ebx
addl %ebx, %ebx
leal (%rbx,%rbx,2), %ebx
subl %ebx, %r11d
movslq %r11d, %r11
movl (%rcx,%r11,4), %ebx
cmpl $0x2, %ebx
cmovll %edx, %ebx
shlq $0x4, %r11
leaq (%r11,%r11,2), %r14
leaq (,%rbx,4), %r15
xorl %r11d, %r11d
leaq (%r14,%r11), %r12
xorps %xmm5, %xmm5
cvtsi2ssl (%r9,%r12), %xmm5
addss %xmm4, %xmm5
cvttss2si %xmm5, %ebp
movw %bp, (%r8,%r11)
movzwl (%r10,%r12), %ebp
movw %bp, 0x2(%r8,%r11)
addq $0x4, %r11
cmpq %r11, %r15
jne 0x8bad
addl %ebx, %esi
incl %eax
leaq (%r8,%r11), %rbx
cmpl $0x12, %eax
jne 0x8b44
addq %r11, %r8
jmp 0x8d1a
leaq 0xb815(%rip), %r8       # 0x14410
xorl %esi, %esi
testl %edi, %edi
js 0x8e42
xorpd %xmm1, %xmm1
xorl %ecx, %ecx
movsd 0x59dd(%rip), %xmm2     # 0xe5f0
movss 0x5b2d(%rip), %xmm3     # 0xe748
movss 0x5b29(%rip), %xmm4     # 0xe74c
leaq 0x5b56(%rip), %r11      # 0xe780
movl $0x1, %ebx
leaq 0x5b6a(%rip), %r14      # 0xe7a0
leaq 0x5c83(%rip), %r15      # 0xe8c0
movsd 0x54e3(%rip), %xmm5     # 0xe128
xorl %r12d, %r12d
movq %rcx, %rax
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rdx
shlq $0x3, %rdx
andq $-0x20, %rdx
leaq (%rdx,%rdx,8), %rdx
movq %r12, %rax
subq %rdx, %rax
movapd %xmm1, %xmm6
mulsd %xmm0, %xmm6
addsd %xmm2, %xmm6
xorps %xmm7, %xmm7
cvtsd2ss %xmm6, %xmm7
movaps %xmm9, %xmm6
subss %xmm7, %xmm6
mulss %xmm3, %xmm6
addss %xmm4, %xmm6
movl %ecx, %edx
movl $0xaaaaaaab, %r9d       # imm = 0xAAAAAAAB
imulq %r9, %rdx
shrq $0x22, %rdx
addl %edx, %edx
leal (%rdx,%rdx,2), %edx
movl %ecx, %r13d
subl %edx, %r13d
movl (%r11,%r13,4), %r13d
cmpl $0x2, %r13d
cmovll %ebx, %r13d
leaq (,%r13,4), %rbp
xorl %edx, %edx
leaq (%rax,%rdx), %r9
xorps %xmm7, %xmm7
cvtsi2ssl (%r14,%r9), %xmm7
addss %xmm6, %xmm7
cvttss2si %xmm7, %r10d
movw %r10w, (%r8,%rdx)
movzwl (%r15,%r9), %r9d
movw %r9w, 0x2(%r8,%rdx)
addq $0x4, %rdx
cmpq %rdx, %rbp
jne 0x8cbe
addl %r13d, %esi
addsd %xmm5, %xmm1
movq %rcx, %rax
incq %rax
addq $0x30, %r12
addq %rdx, %r8
cmpl %edi, %ecx
movq %rax, %rcx
jne 0x8c48
jmp 0x8e42
leaq 0xb6f8(%rip), %r8       # 0x14410
xorl %esi, %esi
testl %edi, %edi
js 0x8e42
movsd 0x58d6(%rip), %xmm1     # 0xe600
addsd %xmm6, %xmm1
xorps %xmm2, %xmm2
xorl %ecx, %ecx
movsd 0x58b5(%rip), %xmm3     # 0xe5f0
movsd 0x58c5(%rip), %xmm4     # 0xe608
movsd 0x58c5(%rip), %xmm5     # 0xe610
leaq 0x5a2e(%rip), %r11      # 0xe780
movl $0x1, %ebx
leaq 0x5a42(%rip), %r14      # 0xe7a0
leaq 0x5b5b(%rip), %r15      # 0xe8c0
movsd 0x53bb(%rip), %xmm6     # 0xe128
xorl %r12d, %r12d
movq %rcx, %rax
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rdx
shlq $0x3, %rdx
andq $-0x20, %rdx
leaq (%rdx,%rdx,8), %rdx
movq %r12, %rax
subq %rdx, %rax
movaps %xmm2, %xmm7
mulsd %xmm0, %xmm7
addsd %xmm3, %xmm7
cvtsd2ss %xmm7, %xmm7
cvtss2sd %xmm7, %xmm7
movapd %xmm1, %xmm8
subsd %xmm7, %xmm8
mulsd %xmm4, %xmm8
addsd %xmm5, %xmm8
xorps %xmm7, %xmm7
cvtsd2ss %xmm8, %xmm7
movl %ecx, %edx
movl $0xaaaaaaab, %r9d       # imm = 0xAAAAAAAB
imulq %r9, %rdx
shrq $0x22, %rdx
addl %edx, %edx
leal (%rdx,%rdx,2), %edx
movl %ecx, %r13d
subl %edx, %r13d
movl (%r11,%r13,4), %r13d
cmpl $0x2, %r13d
cmovll %ebx, %r13d
leaq (,%r13,4), %rbp
xorl %edx, %edx
leaq (%rax,%rdx), %r9
xorps %xmm8, %xmm8
cvtsi2ssl (%r14,%r9), %xmm8
addss %xmm7, %xmm8
cvttss2si %xmm8, %r10d
movw %r10w, (%r8,%rdx)
movzwl (%r15,%r9), %r9d
movw %r9w, 0x2(%r8,%rdx)
addq $0x4, %rdx
cmpq %rdx, %rbp
jne 0x8df2
addl %r13d, %esi
addsd %xmm6, %xmm2
movq %rcx, %rax
incq %rax
addq $0x30, %r12
addq %rdx, %r8
cmpl %edi, %ecx
movq %rax, %rcx
jne 0x8d70
sarl %esi
movl %esi, 0xb952(%rip)      # 0x1479c
leaq 0xb5bf(%rip), %rdi      # 0x14410
xorl %eax, %eax
movaps %xmm9, (%rsp)
callq 0x6ed0
movaps (%rsp), %xmm0
movss 0x58d3(%rip), %xmm1     # 0xe73c
ucomiss %xmm0, %xmm1
jb 0x8ed6
ucomiss 0x58db(%rip), %xmm0     # 0xe750
jb 0x8ed6
movb $0x1, 0xb92a(%rip)      # 0x147a8
movsd 0x10(%rsp), %xmm0
addsd 0x5794(%rip), %xmm0     # 0xe620
mulsd 0x5774(%rip), %xmm0     # 0xe608
addsd 0x5774(%rip), %xmm0     # 0xe610
addsd 0x5784(%rip), %xmm0     # 0xe628
cvttsd2si %xmm0, %eax
movl %eax, 0xb8f2(%rip)      # 0x147a0
leaq 0xb8eb(%rip), %rsi      # 0x147a0
movl $0x55, 0xb8e5(%rip)     # 0x147a4
xorl %edi, %edi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7961
movb $0x0, 0xb8cb(%rip)      # 0x147a8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq