// File: /workspace/github_c_makefile_star2_O2/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 $0x38, %rsp
cvtsd2ss %xmm0, %xmm0
movaps %xmm0, (%rsp)
leaq 0xb4fe(%rip), %r14      # 0x13590
movq (%r14), %rax
movl 0xf0(%rax), %edi
xorl %eax, %eax
callq 0x7092
movl 0xb704(%rip), %esi      # 0x137ac
leaq 0xb371(%rip), %rbx      # 0x13420
movq %rbx, %rdi
xorl %eax, %eax
callq 0x6abd
cmpb $0x1, 0xb6f8(%rip)      # 0x137b8
jne 0x80d2
leaq 0xb6e7(%rip), %rsi      # 0x137b0
xorl %edi, %edi
xorl %eax, %eax
callq 0x7335
movq (%r14), %rax
movl 0x108(%rax), %edi
xorl %eax, %eax
callq 0x7092
movaps (%rsp), %xmm3
divss 0x5616(%rip), %xmm3     # 0xd704
movss 0x5612(%rip), %xmm0     # 0xd708
movaps %xmm3, %xmm1
addss %xmm0, %xmm1
movss 0x5607(%rip), %xmm4     # 0xd70c
movaps %xmm4, %xmm9
cmpnless %xmm3, %xmm9
movaps %xmm9, %xmm2
andnps %xmm1, %xmm2
andps %xmm3, %xmm9
orps %xmm2, %xmm9
movss 0x55ea(%rip), %xmm1     # 0xd710
addss %xmm9, %xmm1
movss 0x55e1(%rip), %xmm2     # 0xd714
addss %xmm9, %xmm2
xorps %xmm3, %xmm3
ucomiss %xmm1, %xmm3
seta %al
movaps %xmm1, %xmm3
jbe 0x814a
addss %xmm4, %xmm3
ucomiss %xmm4, %xmm2
setae %dl
jb 0x8156
addss %xmm0, %xmm2
cvtss2sd %xmm9, %xmm6
cvtss2sd %xmm3, %xmm3
movsd 0x4f11(%rip), %xmm0     # 0xd078
divsd %xmm0, %xmm3
cvttsd2si %xmm3, %ecx
cvtss2sd %xmm2, %xmm2
divsd %xmm0, %xmm2
cvttsd2si %xmm2, %esi
movl %esi, (%rsp)
orb %dl, %al
movaps %xmm9, 0x20(%rsp)
movsd %xmm6, 0x18(%rsp)
je 0x828e
xorpd %xmm2, %xmm2
ucomiss %xmm1, %xmm2
jbe 0x8355
movsd 0x5441(%rip), %xmm2     # 0xd5e8
addsd %xmm6, %xmm2
leaq 0xb26e(%rip), %rbx      # 0x13420
movsd 0x5406(%rip), %xmm1     # 0xd5c0
movsd 0x5416(%rip), %xmm3     # 0xd5d8
movsd 0x5416(%rip), %xmm4     # 0xd5e0
pushq $0x6
popq %r14
leaq 0x557b(%rip), %r8       # 0xd750
leaq 0x5594(%rip), %r10      # 0xd770
leaq 0x56ad(%rip), %r11      # 0xd890
xorl %r9d, %r9d
xorl %ebp, %ebp
cmpl $0x12, %ecx
jge 0x8430
cvtsi2sd %ecx, %xmm5
mulsd %xmm0, %xmm5
addsd %xmm1, %xmm5
cvtsd2ss %xmm5, %xmm5
cvtss2sd %xmm5, %xmm5
movapd %xmm2, %xmm6
subsd %xmm5, %xmm6
mulsd %xmm3, %xmm6
addsd %xmm4, %xmm6
cvtsd2ss %xmm6, %xmm5
movl %ecx, %eax
cltd
idivl %r14d
movslq %edx, %rdx
movl (%r8,%rdx,4), %eax
testl %eax, %eax
movl $0x0, %esi
cmovlel %esi, %eax
imulq $0x30, %rdx, %r15
movl %ebp, %r12d
xorl %r13d, %r13d
movl %ebp, %esi
movq %rbx, %rdx
cmpq %r13, %rax
je 0x8281
leaq (%r15,%r13,4), %rdi
cvtsi2ssl (%r10,%rdi), %xmm6
addss %xmm5, %xmm6
cvttss2si %xmm6, %r9d
movw %r9w, (%rbx,%r13,4)
movzwl (%r11,%rdi), %edi
addq $0x4, %rdx
movw %di, 0x2(%rbx,%r13,4)
incl %esi
leal (%r12,%r13), %edi
incl %edi
movl %edi, 0xb533(%rip)      # 0x137ac
incq %r13
movl %esi, %r9d
jmp 0x823f
incl %ecx
addl %r13d, %ebp
movq %rdx, %rbx
jmp 0x81e8
xorl %esi, %esi
movsd 0x5328(%rip), %xmm1     # 0xd5c0
movss 0x5478(%rip), %xmm2     # 0xd718
movss 0x5474(%rip), %xmm3     # 0xd71c
pushq $0x6
popq %r8
leaq 0x549d(%rip), %r10      # 0xd750
leaq 0x54b6(%rip), %r11      # 0xd770
leaq 0x55cf(%rip), %r14      # 0xd890
xorl %r9d, %r9d
cmpl (%rsp), %ecx
jg 0x85e7
cvtsi2sd %ecx, %xmm4
mulsd %xmm0, %xmm4
addsd %xmm1, %xmm4
cvtsd2ss %xmm4, %xmm5
movaps %xmm9, %xmm4
subss %xmm5, %xmm4
mulss %xmm2, %xmm4
addss %xmm3, %xmm4
movl %ecx, %eax
cltd
idivl %r8d
movslq %edx, %rdx
movl (%r10,%rdx,4), %eax
testl %eax, %eax
cmovlel %esi, %eax
imulq $0x30, %rdx, %r15
movl %r9d, %r13d
xorl %r12d, %r12d
movq %rbx, %rdx
cmpq %r12, %rax
je 0x8348
leaq (%r15,%r12,4), %rbp
cvtsi2ssl (%r11,%rbp), %xmm5
addss %xmm4, %xmm5
cvttss2si %xmm5, %edi
movw %di, (%rbx,%r12,4)
movzwl (%r14,%rbp), %edi
addq $0x4, %rdx
movw %di, 0x2(%rbx,%r12,4)
leal (%r12,%r13), %edi
incl %edi
movl %edi, 0xb469(%rip)      # 0x137ac
incq %r12
jmp 0x830c
incl %ecx
addl %r12d, %r9d
movq %rdx, %rbx
jmp 0x82c4
leaq 0xb0c4(%rip), %rbx      # 0x13420
movsd 0x525c(%rip), %xmm1     # 0xd5c0
movss 0x53ac(%rip), %xmm2     # 0xd718
movss 0x53a8(%rip), %xmm3     # 0xd71c
pushq $0x6
popq %rsi
leaq 0x53d2(%rip), %r14      # 0xd750
leaq 0x53eb(%rip), %r10      # 0xd770
leaq 0x5504(%rip), %r11      # 0xd890
xorl %r9d, %r9d
xorl %ebp, %ebp
cmpl $0x12, %ecx
jge 0x84fe
cvtsi2sd %ecx, %xmm4
mulsd %xmm0, %xmm4
addsd %xmm1, %xmm4
cvtsd2ss %xmm4, %xmm5
movaps %xmm9, %xmm4
subss %xmm5, %xmm4
mulss %xmm2, %xmm4
addss %xmm3, %xmm4
movl %ecx, %eax
cltd
idivl %esi
movslq %edx, %rdx
movl (%r14,%rdx,4), %eax
testl %eax, %eax
movl $0x0, %edi
cmovlel %edi, %eax
imulq $0x30, %rdx, %r15
movl %ebp, %r12d
xorl %r13d, %r13d
movl %ebp, %r8d
movq %rbx, %rdx
cmpq %r13, %rax
je 0x8423
leaq (%r15,%r13,4), %rdi
cvtsi2ssl (%r10,%rdi), %xmm5
addss %xmm4, %xmm5
cvttss2si %xmm5, %r9d
movw %r9w, (%rbx,%r13,4)
movzwl (%r11,%rdi), %edi
addq $0x4, %rdx
movw %di, 0x2(%rbx,%r13,4)
incl %r8d
leal (%r12,%r13), %edi
incl %edi
movl %edi, 0xb391(%rip)      # 0x137ac
incq %r13
movl %r8d, %r9d
jmp 0x83e0
incl %ecx
addl %r13d, %ebp
movq %rdx, %rbx
jmp 0x8391
xorpd %xmm2, %xmm2
pushq $0x6
popq %r15
movss 0x52d8(%rip), %xmm3     # 0xd718
movss 0x52d4(%rip), %xmm4     # 0xd71c
movsd 0x4ca8(%rip), %xmm5     # 0xd0f8
xorl %ecx, %ecx
movq %rcx, %rax
xorl %edx, %edx
divq %r15
cmpl (%rsp), %ecx
jg 0x85e7
imulq $-0x120, %rax, %r12     # imm = 0xFEE0
leaq (%r10,%r12), %r13
addq %r11, %r12
movapd %xmm2, %xmm6
mulsd %xmm0, %xmm6
addsd %xmm1, %xmm6
cvtsd2ss %xmm6, %xmm7
movaps %xmm9, %xmm6
subss %xmm7, %xmm6
mulss %xmm3, %xmm6
addss %xmm4, %xmm6
movl %ecx, %eax
xorl %edx, %edx
divl %r14d
movl (%r8,%rdx,4), %ebp
testl %ebp, %ebp
movl $0x0, %eax
cmovlel %eax, %ebp
movl %r9d, %esi
xorl %edx, %edx
movq %rbx, %rax
cmpq %rdx, %rbp
je 0x84e4
cvtsi2ssl (%r13,%rdx,4), %xmm7
addss %xmm6, %xmm7
cvttss2si %xmm7, %edi
movw %di, (%rbx,%rdx,4)
movzwl (%r12,%rdx,4), %edi
addq $0x4, %rax
movw %di, 0x2(%rbx,%rdx,4)
leal (%rsi,%rdx), %edi
incl %edi
movl %edi, 0xb2cd(%rip)      # 0x137ac
incq %rdx
jmp 0x84ae
addsd %xmm5, %xmm2
incq %rcx
addq $0x30, %r10
addq $0x30, %r11
addl %edx, %r9d
movq %rax, %rbx
jmp 0x8452
movsd 0x50ca(%rip), %xmm2     # 0xd5d0
addsd %xmm6, %xmm2
xorpd %xmm3, %xmm3
pushq $0x6
popq %r15
movsd 0x50be(%rip), %xmm4     # 0xd5d8
movsd 0x50be(%rip), %xmm5     # 0xd5e0
movsd 0x4bce(%rip), %xmm6     # 0xd0f8
xorl %ecx, %ecx
movq %rcx, %rax
xorl %edx, %edx
divq %r15
cmpl (%rsp), %ecx
jg 0x85e7
imulq $-0x120, %rax, %r12     # imm = 0xFEE0
leaq (%r10,%r12), %r13
movapd %xmm3, %xmm7
mulsd %xmm0, %xmm7
addsd %xmm1, %xmm7
cvtsd2ss %xmm7, %xmm7
addq %r11, %r12
cvtss2sd %xmm7, %xmm7
movapd %xmm2, %xmm8
subsd %xmm7, %xmm8
mulsd %xmm4, %xmm8
addsd %xmm5, %xmm8
cvtsd2ss %xmm8, %xmm7
movl %ecx, %eax
xorl %edx, %edx
divl %esi
movl (%r14,%rdx,4), %ebp
testl %ebp, %ebp
movl $0x0, %eax
cmovlel %eax, %ebp
movl %r9d, %r8d
xorl %edx, %edx
movq %rbx, %rax
cmpq %rdx, %rbp
je 0x85cd
cvtsi2ssl (%r13,%rdx,4), %xmm8
addss %xmm7, %xmm8
cvttss2si %xmm8, %edi
movw %di, (%rbx,%rdx,4)
movzwl (%r12,%rdx,4), %edi
addq $0x4, %rax
movw %di, 0x2(%rbx,%rdx,4)
leal (%r8,%rdx), %edi
incl %edi
movl %edi, 0xb1e4(%rip)      # 0x137ac
incq %rdx
jmp 0x8594
addsd %xmm6, %xmm3
incq %rcx
addq $0x30, %r10
addq $0x30, %r11
addl %edx, %r9d
movq %rax, %rbx
jmp 0x852c
sarl %r9d
movl %r9d, 0xb1bb(%rip)      # 0x137ac
leaq 0xae28(%rip), %rdi      # 0x13420
movl %r9d, %esi
xorl %eax, %eax
callq 0x6abd
movaps 0x20(%rsp), %xmm0
movss 0x50fd(%rip), %xmm1     # 0xd70c
ucomiss %xmm0, %xmm1
jb 0x867c
ucomiss 0x5105(%rip), %xmm0     # 0xd720
jb 0x867c
movb $0x1, 0xb194(%rip)      # 0x137b8
movsd 0x18(%rsp), %xmm0
addsd 0x4fbe(%rip), %xmm0     # 0xd5f0
mulsd 0x4f9e(%rip), %xmm0     # 0xd5d8
addsd 0x4f9e(%rip), %xmm0     # 0xd5e0
addsd 0x4fae(%rip), %xmm0     # 0xd5f8
cvttsd2si %xmm0, %eax
movl %eax, 0xb15c(%rip)      # 0x137b0
leaq 0xb155(%rip), %rsi      # 0x137b0
movl $0x55, 0xb14f(%rip)     # 0x137b4
xorl %edi, %edi
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x72c1
movb $0x0, 0xb135(%rip)      # 0x137b8
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq