// File: /workspace/github_c_makefile_star2_O1/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 0xbd1f(%rip), %r14      # 0x14590
movq (%r14), %rax
movl 0xf0(%rax), %edi
xorl %eax, %eax
callq 0x7608
movl 0xbf25(%rip), %esi      # 0x147ac
leaq 0xbb92(%rip), %rbx      # 0x14420
movq %rbx, %rdi
xorl %eax, %eax
callq 0x6e78
cmpb $0x1, 0xbf19(%rip)      # 0x147b8
jne 0x88b1
leaq 0xbf08(%rip), %rsi      # 0x147b0
xorl %edi, %edi
xorl %eax, %eax
callq 0x79ae
movq (%r14), %rax
movl 0x108(%rax), %edi
xorl %eax, %eax
callq 0x7608
movaps (%rsp), %xmm3
divss 0x5d93(%rip), %xmm3     # 0xe660
movss 0x5d8f(%rip), %xmm0     # 0xe664
movaps %xmm3, %xmm1
addss %xmm0, %xmm1
movss 0x5d84(%rip), %xmm4     # 0xe668
movaps %xmm4, %xmm9
cmpnless %xmm3, %xmm9
movaps %xmm9, %xmm2
andnps %xmm1, %xmm2
andps %xmm3, %xmm9
orps %xmm2, %xmm9
movss 0x5d67(%rip), %xmm1     # 0xe66c
addss %xmm9, %xmm1
movss 0x5d5e(%rip), %xmm2     # 0xe670
addss %xmm9, %xmm2
xorps %xmm3, %xmm3
ucomiss %xmm1, %xmm3
seta %cl
movaps %xmm1, %xmm3
jbe 0x8929
addss %xmm4, %xmm3
ucomiss %xmm4, %xmm2
setae %dl
jb 0x8935
addss %xmm0, %xmm2
cvtss2sd %xmm9, %xmm10
cvtss2sd %xmm3, %xmm3
movsd 0x5722(%rip), %xmm0     # 0xe068
divsd %xmm0, %xmm3
cvttsd2si %xmm3, %eax
cvtss2sd %xmm2, %xmm2
divsd %xmm0, %xmm2
cvttsd2si %xmm2, %esi
movl $0x0, 0xbe48(%rip)      # 0x147ac
orb %dl, %cl
je 0x8a8e
xorpd %xmm2, %xmm2
ucomiss %xmm1, %xmm2
jbe 0x8b86
cmpl $0x11, %eax
jg 0x8c86
movl 0xbe24(%rip), %ecx      # 0x147ac
movsd 0x5c78(%rip), %xmm1     # 0xe608
addsd %xmm10, %xmm1
leaq 0xba84(%rip), %rbx      # 0x14420
movsd 0x5c0c(%rip), %xmm2     # 0xe5b0
movsd 0x5c54(%rip), %xmm3     # 0xe600
movsd 0x5c34(%rip), %xmm4     # 0xe5e8
leaq 0x5ce5(%rip), %rdx      # 0xe6a0
movl $0x1, %r8d
leaq 0x5cf8(%rip), %r9       # 0xe6c0
leaq 0x5e11(%rip), %r10      # 0xe7e0
movq %rbx, %rdi
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 (%rdx,%r11,4), %ebx
cmpl $0x2, %ebx
cmovll %r8d, %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, (%rdi,%r11)
movzwl (%r10,%r12), %ebp
movw %bp, 0x2(%rdi,%r11)
addq $0x4, %r11
cmpq %r11, %r15
jne 0x8a41
addl %ebx, %ecx
incl %eax
leaq (%rdi,%r11), %rbx
cmpl $0x12, %eax
jne 0x89cf
movl %ecx, 0xbd26(%rip)      # 0x147ac
addq %r11, %rdi
jmp 0x8c8d
cmpl %esi, %eax
jg 0x8ee6
movl 0xbd10(%rip), %ecx      # 0x147ac
movsd 0x5b0c(%rip), %xmm1     # 0xe5b0
movss 0x5bc8(%rip), %xmm2     # 0xe674
movss 0x5558(%rip), %xmm3     # 0xe00c
leaq 0x5be5(%rip), %rdx      # 0xe6a0
movl $0x1, %edi
leaq 0x5bf9(%rip), %r8       # 0xe6c0
leaq 0x5d12(%rip), %r9       # 0xe7e0
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 (%rdx,%r11,4), %r10d
cmpl $0x2, %r10d
cmovll %edi, %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 0x8b38
addl %r10d, %ecx
leal 0x1(%rax), %r10d
addq %r11, %rbx
cmpl %esi, %eax
movl %r10d, %eax
jne 0x8ace
movl %ecx, 0xbc2b(%rip)      # 0x147ac
jmp 0x8ee6
cmpl $0x11, %eax
jg 0x8da8
leaq 0xb88a(%rip), %rbx      # 0x14420
movl 0xbc10(%rip), %ecx      # 0x147ac
movsd 0x5a0c(%rip), %xmm1     # 0xe5b0
movss 0x5ac8(%rip), %xmm2     # 0xe674
movss 0x5458(%rip), %xmm3     # 0xe00c
leaq 0x5ae5(%rip), %rdx      # 0xe6a0
movl $0x1, %r8d
leaq 0x5af8(%rip), %r9       # 0xe6c0
leaq 0x5c11(%rip), %r10      # 0xe7e0
movq %rbx, %rdi
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 (%rdx,%r11,4), %ebx
cmpl $0x2, %ebx
cmovll %r8d, %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, (%rdi,%r11)
movzwl (%r10,%r12), %ebp
movw %bp, 0x2(%rdi,%r11)
addq $0x4, %r11
cmpq %r11, %r15
jne 0x8c39
addl %ebx, %ecx
incl %eax
leaq (%rdi,%r11), %rbx
cmpl $0x12, %eax
jne 0x8bcf
movl %ecx, 0xbb2e(%rip)      # 0x147ac
addq %r11, %rdi
jmp 0x8daf
leaq 0xb793(%rip), %rdi      # 0x14420
testl %esi, %esi
js 0x8ee6
xorpd %xmm1, %xmm1
movl 0xbb0c(%rip), %r8d      # 0x147ac
xorl %ecx, %ecx
movsd 0x5906(%rip), %xmm2     # 0xe5b0
movss 0x59c2(%rip), %xmm3     # 0xe674
movss 0x5352(%rip), %xmm4     # 0xe00c
leaq 0x59df(%rip), %r11      # 0xe6a0
movl $0x1, %ebx
leaq 0x59f3(%rip), %r14      # 0xe6c0
leaq 0x5b0c(%rip), %r15      # 0xe7e0
movsd 0x540c(%rip), %xmm5     # 0xe0e8
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, (%rdi,%rdx)
movzwl (%r15,%r9), %r9d
movw %r9w, 0x2(%rdi,%rdx)
addq $0x4, %rdx
cmpq %rdx, %rbp
jne 0x8d55
addl %r13d, %r8d
addsd %xmm5, %xmm1
movq %rcx, %rax
incq %rax
addq $0x30, %r12
addq %rdx, %rdi
cmpl %esi, %ecx
movq %rax, %rcx
jne 0x8cdf
jmp 0x8edf
leaq 0xb671(%rip), %rdi      # 0x14420
testl %esi, %esi
js 0x8ee6
movl 0xb9ee(%rip), %r8d      # 0x147ac
movsd 0x5832(%rip), %xmm1     # 0xe5f8
addsd %xmm10, %xmm1
xorps %xmm2, %xmm2
xorl %ecx, %ecx
movsd 0x57d8(%rip), %xmm3     # 0xe5b0
movsd 0x5820(%rip), %xmm4     # 0xe600
movsd 0x5800(%rip), %xmm5     # 0xe5e8
leaq 0x58b1(%rip), %r11      # 0xe6a0
movl $0x1, %ebx
leaq 0x58c5(%rip), %r14      # 0xe6c0
leaq 0x59de(%rip), %r15      # 0xe7e0
movsd 0x52de(%rip), %xmm6     # 0xe0e8
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, (%rdi,%rdx)
movzwl (%r15,%r9), %r9d
movw %r9w, 0x2(%rdi,%rdx)
addq $0x4, %rdx
cmpq %rdx, %rbp
jne 0x8e8f
addl %r13d, %r8d
addsd %xmm6, %xmm2
movq %rcx, %rax
incq %rax
addq $0x30, %r12
addq %rdx, %rdi
cmpl %esi, %ecx
movq %rax, %rcx
jne 0x8e0d
movl %r8d, 0xb8c6(%rip)      # 0x147ac
movsd %xmm10, 0x10(%rsp)
movl 0xb8b9(%rip), %esi      # 0x147ac
sarl %esi
movl %esi, 0xb8b1(%rip)      # 0x147ac
leaq 0xb51e(%rip), %rdi      # 0x14420
xorl %eax, %eax
movaps %xmm9, (%rsp)
callq 0x6e78
movaps (%rsp), %xmm0
movss 0x574e(%rip), %xmm1     # 0xe668
ucomiss %xmm0, %xmm1
jb 0x8f87
ucomiss 0x5752(%rip), %xmm0     # 0xe678
jb 0x8f87
movb $0x1, 0xb889(%rip)      # 0x147b8
movsd 0x10(%rsp), %xmm0
addsd 0x56d3(%rip), %xmm0     # 0xe610
mulsd 0x56bb(%rip), %xmm0     # 0xe600
addsd 0x569b(%rip), %xmm0     # 0xe5e8
addsd 0x56c3(%rip), %xmm0     # 0xe618
cvttsd2si %xmm0, %eax
movl %eax, 0xb851(%rip)      # 0x147b0
leaq 0xb84a(%rip), %rsi      # 0x147b0
movl $0x55, 0xb844(%rip)     # 0x147b4
xorl %edi, %edi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7909
movb $0x0, 0xb82a(%rip)      # 0x147b8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq