// File: /workspace/github_c_makefile_star2_O3/kobolt[P]curses-collection/racer/racer.c
// Function: main
int main(int argc, char *argv[])
{
  int c;
  bool disable_color = false;
  bool disable_ascii = false;
  int ch;
  int player_speed = 5;
  int player_hpos = 25;
  int cars_passed = 0;
  int curve = 0;
  bool quit = false;
  car_t cars[CARS_MAX];

  srandom(time(NULL));

  /* Initialize: */
  for (int i = 0; i < CARS_MAX; i++) {
    cars[i].distance = 0;
    car_init(&cars[i], false);
  }

  while ((c = getopt(argc, argv, "hca")) != -1) {
    switch (c) {
    case 'h':
      display_help(argv[0]);
      return EXIT_SUCCESS;

    case 'c':
      disable_color = true;
      break;

    case 'a':
      disable_ascii = true;
      break;

    case '?':
    default:
      display_help(argv[0]);
      return EXIT_FAILURE;
    }
  }

  if (disable_color && disable_ascii) {
    fprintf(stdout, "Disabling both color and ASCII makes no sense!\n");
    return EXIT_FAILURE;
  }

  initscr();
  noecho();
  keypad(stdscr, TRUE);
  timeout(0);

  if (has_colors()) {
    if (! disable_color) {
      start_color();
    }
    init_pair(COL_BLACK,   COLOR_WHITE, COLOR_BLACK);
    init_pair(COL_RED,     COLOR_BLACK, COLOR_RED);
    init_pair(COL_GREEN,   COLOR_BLACK, COLOR_GREEN);
    init_pair(COL_YELLOW,  COLOR_BLACK, COLOR_YELLOW);
    init_pair(COL_BLUE,    COLOR_BLACK, COLOR_BLUE);
    init_pair(COL_MAGENTA, COLOR_BLACK, COLOR_MAGENTA);
    init_pair(COL_CYAN,    COLOR_BLACK, COLOR_CYAN);
    init_pair(COL_WHITE,   COLOR_BLACK, COLOR_WHITE);
  }

  while (! quit) {
    /* Player input: */
    ch = getch();
    switch (ch) {
    case KEY_LEFT:
    case 'a':
      if (player_hpos < HPOS_MAX) {
        player_hpos++;
      }
      break;

    case KEY_RIGHT:
    case 'd':
      if (player_hpos > HPOS_MIN) {
        player_hpos--;
      }
      break;

    case KEY_UP:
    case 'w':
      if (player_speed < SPEED_MAX) {
        player_speed++;
      }
      break;

    case KEY_DOWN:
    case 's':
      if (player_speed > SPEED_MIN) {
        player_speed--;
      }
      break;

    case 'q':
      quit = true;
      break;

    default:
      break;
    }

    /* Position update of other cars: */
    for (int i = 0; i < CARS_MAX; i++) {
      cars[i].distance += (cars[i].speed - player_speed);

      /* Re-spawn car if it goes out of range: */
      if (cars[i].distance > 6000) {
        car_init(&cars[i], true);
      } else if (cars[i].distance < -100) {
        car_init(&cars[i], true);
        cars_passed++;
      }

      car_row_update(&cars[i]);
    }

    /* Collision check: */
    for (int i = 0; i < CARS_MAX; i++) {
      if (car_collision(&cars[i], player_hpos)) {
        endwin();
        fprintf(stdout, "Crashed!\n");
        quit = true;
      }
    }

    /* Draw screen: */
    erase();
    draw_horizon(curve, player_speed, disable_ascii);
    draw_road(curve, player_speed, disable_ascii);
    for (int i = 0; i < CARS_MAX; i++) {
      draw_car(curve, cars[i].row, cars[i].hpos, false, disable_ascii);
    }
    draw_car(curve, 20, player_hpos, true, disable_ascii); /* The player */
    mvprintw(6, 0, "Score: %d", cars_passed);
    mvprintw(7, 0, "%dkm/h", player_speed * 10);
    refresh();

    usleep(20000);

    /* Trajectory and road change: */
    curve = curve_ahead(player_speed);
  }

  endwin();
  fprintf(stdout, "Final score: %d\n", cars_passed);
  return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %rbx
movl %edi, %ebp
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x1100
movl %eax, %edi
callq 0x1050
leaq (%rsp,%r14), %rdi
addq $0x40, %rdi
movl $0x0, (%rdi)
xorl %esi, %esi
callq 0x1c21
addq $0x10, %r14
cmpq $0x50, %r14
jne 0x12d3
xorl %r14d, %r14d
leaq 0x24d1(%rip), %r15      # 0x37cd
xorl %eax, %eax
movl %eax, %ecx
movl %ecx, %r12d
movl %ebp, %edi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1130
movb $0x1, %cl
cmpl $0x61, %eax
je 0x1300
movl %r12d, 0xc(%rsp)
cmpl $-0x1, %eax
je 0x136f
cmpl $0x63, %eax
jne 0x132f
movb $0x1, %r14b
movl 0xc(%rsp), %eax
jmp 0x12fe
cmpl $0x68, %eax
jne 0x1394
movq (%rbx), %rdx
movq 0x3c9a(%rip), %r14      # 0x4fd8
movq (%r14), %rdi
leaq 0x24e5(%rip), %rsi      # 0x382d
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x10d0
movq (%r14), %rcx
leaq 0x24e7(%rip), %rdi      # 0x3842
movl $0x58, %esi
movl $0x1, %edx
callq 0x1160
jmp 0x1c0d
testb $0x1, %r14b
je 0x13d2
testb $0x1, 0xc(%rsp)
je 0x13d2
movq 0x3c55(%rip), %rax      # 0x4fd8
movq (%rax), %rcx
leaq 0x2444(%rip), %rdi      # 0x37d1
movl $0x2f, %esi
jmp 0x13be
movq (%rbx), %rdx
movq 0x3c3a(%rip), %rbx      # 0x4fd8
movq (%rbx), %rdi
leaq 0x2485(%rip), %rsi      # 0x382d
xorl %eax, %eax
callq 0x10d0
movq (%rbx), %rcx
leaq 0x2489(%rip), %rdi      # 0x3842
movl $0x58, %esi
movl $0x1, %edx
callq 0x1160
movl $0x1, %ebx
jmp 0x1c0d
callq 0x1080
callq 0x1070
movq 0x3bfd(%rip), %r12      # 0x4fe0
movq (%r12), %rdi
movl $0x1, %esi
callq 0x10b0
movq (%r12), %rdi
xorl %esi, %esi
callq 0x10f0
callq 0x1030
testb %al, %al
je 0x149c
testb $0x1, %r14b
jne 0x1414
callq 0x10a0
movl $0x1, %edi
movl $0x7, %esi
xorl %edx, %edx
callq 0x1120
movl $0x2, %edi
xorl %esi, %esi
movl $0x1, %edx
callq 0x1120
movl $0x3, %edi
xorl %esi, %esi
movl $0x2, %edx
callq 0x1120
movl $0x4, %edi
xorl %esi, %esi
movl $0x3, %edx
callq 0x1120
movl $0x5, %edi
xorl %esi, %esi
movl $0x4, %edx
callq 0x1120
movl $0x6, %edi
xorl %esi, %esi
movl $0x5, %edx
callq 0x1120
movl $0x7, %edi
xorl %esi, %esi
movl $0x6, %edx
callq 0x1120
movl $0x8, %edi
xorl %esi, %esi
movl $0x7, %edx
callq 0x1120
movl 0xc(%rsp), %r14d
movl %r14d, %eax
notb %al
movzbl %al, %eax
andl $0x1, %eax
leal (%rax,%rax,2), %eax
addl $0x20, %eax
movl %eax, 0x20(%rsp)
testb $0x1, %r14b
movl $0x20, %eax
movl $0x7c, %ecx
cmovnel %eax, %ecx
movl %ecx, 0x24(%rsp)
movl $0x5, %r13d
movl $0x19, %ebp
movq $0x0, 0x18(%rsp)
movl $0x0, 0x14(%rsp)
movq (%r12), %rdi
callq 0x1060
cmpl $0x72, %eax
jg 0x150c
cmpl $0x61, %eax
je 0x1527
cmpl $0x64, %eax
je 0x1533
cmpl $0x71, %eax
jne 0x1562
movb $0x1, %al
movl %eax, 0x8(%rsp)
jmp 0x156a
leal -0x102(%rax), %ecx
cmpl $0x3, %ecx
ja 0x153f
leaq 0x1b72(%rip), %rdx      # 0x3090
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
xorl %eax, %eax
cmpl $0x23, %ebp
setl %al
addl %eax, %ebp
jmp 0x1562
xorl %eax, %eax
cmpl $-0x22, %ebp
setge %al
subl %eax, %ebp
jmp 0x1562
cmpl $0x73, %eax
je 0x1557
cmpl $0x77, %eax
jne 0x1562
xorl %eax, %eax
cmpl $0x1e, %r13d
setl %al
addl %eax, %r13d
jmp 0x1562
xorl %eax, %eax
testl %r13d, %r13d
setg %al
subl %eax, %r13d
movl $0x0, 0x8(%rsp)
xorl %ebx, %ebx
leaq (%rsp,%rbx), %r15
addq $0x40, %r15
movl 0x8(%r15), %eax
subl %r13d, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
addss (%r15), %xmm0
movss %xmm0, (%r15)
ucomiss 0x1a71(%rip), %xmm0     # 0x3004
jbe 0x15a4
movq %r15, %rdi
movl $0x1, %esi
callq 0x1c21
jmp 0x15c2
movss 0x1a5c(%rip), %xmm1     # 0x3008
ucomiss %xmm0, %xmm1
jbe 0x15c7
movq %r15, %rdi
movl $0x1, %esi
callq 0x1c21
incl 0x14(%rsp)
movss (%r15), %xmm0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
ucomiss 0x1a39(%rip), %xmm0     # 0x300c
ja 0x16fc
movl $0x6, %eax
ucomiss 0x1a2b(%rip), %xmm0     # 0x3010
ja 0x16fc
movl $0x7, %eax
ucomiss 0x1a1d(%rip), %xmm0     # 0x3014
ja 0x16fc
movl $0x8, %eax
ucomiss 0x1a0f(%rip), %xmm0     # 0x3018
ja 0x16fc
movl $0x9, %eax
ucomiss 0x1a01(%rip), %xmm0     # 0x301c
ja 0x16fc
movl $0xa, %eax
ucomiss 0x19f3(%rip), %xmm0     # 0x3020
ja 0x16fc
movl $0xb, %eax
ucomiss 0x19e5(%rip), %xmm0     # 0x3024
ja 0x16fc
movl $0xc, %eax
ucomiss 0x19d7(%rip), %xmm0     # 0x3028
ja 0x16fc
movl $0xd, %eax
ucomiss 0x19c9(%rip), %xmm0     # 0x302c
ja 0x16fc
movl $0xe, %eax
ucomiss 0x19bb(%rip), %xmm0     # 0x3030
ja 0x16fc
movl $0xf, %eax
ucomiss 0x19ad(%rip), %xmm0     # 0x3034
ja 0x16fc
movl $0x10, %eax
ucomiss 0x19a3(%rip), %xmm0     # 0x3038
ja 0x16fc
movl $0x11, %eax
ucomiss 0x1999(%rip), %xmm0     # 0x303c
ja 0x16fc
movl $0x12, %eax
ucomiss 0x198f(%rip), %xmm0     # 0x3040
ja 0x16fc
movl $0x13, %eax
ucomiss 0x1985(%rip), %xmm0     # 0x3044
ja 0x16fc
movl $0x14, %eax
ucomiss 0x198f(%rip), %xmm0     # 0x305c
ja 0x16fc
movl $0x15, %eax
ucomiss 0x196d(%rip), %xmm0     # 0x3048
ja 0x16fc
movl $0x16, %eax
ucomiss 0x1963(%rip), %xmm0     # 0x304c
ja 0x16fc
xorl %eax, %eax
ucomiss 0x195c(%rip), %xmm0     # 0x3050
setbe %al
negl %eax
orl $0x17, %eax
movl %eax, 0x44(%rsp,%rbx)
addq $0x10, %rbx
cmpq $0x50, %rbx
jne 0x156c
xorl %ebx, %ebx
movss 0x40(%rsp,%rbx), %xmm0
andps 0x1943(%rip), %xmm0     # 0x3060
ucomiss 0x1920(%rip), %xmm0     # 0x3044
ja 0x1763
movl 0x4c(%rsp,%rbx), %eax
subl %ebp, %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
cmpl $0xc, %ecx
ja 0x1763
callq 0x1170
movq 0x3894(%rip), %rax      # 0x4fd8
movq (%rax), %rcx
movl $0x9, %esi
movl $0x1, %edx
leaq 0x20a9(%rip), %rdi      # 0x3801
callq 0x1160
movb $0x1, %al
movl %eax, 0x8(%rsp)
addq $0x10, %rbx
cmpq $0x50, %rbx
jne 0x1710
movl %ebp, 0x10(%rsp)
movq (%r12), %rdi
callq 0x1040
movq %r13, 0x30(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x18(%rsp), %xmm1
divsd 0x18d8(%rip), %xmm0     # 0x3070
mulsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtss2sd 0x3945(%rip), %xmm0     # 0x50ec
divsd 0x18c9(%rip), %xmm1     # 0x3078
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movaps %xmm0, %xmm1
cmpltss 0x1899(%rip), %xmm1     # 0x305c
movaps %xmm1, %xmm2
andnps %xmm0, %xmm2
movss 0x1883(%rip), %xmm0     # 0x3054
andps %xmm0, %xmm1
orps %xmm2, %xmm1
cmpltss %xmm1, %xmm0
andnps %xmm1, %xmm0
movss %xmm0, 0x3905(%rip)     # 0x50ec
xorl %r13d, %r13d
leaq 0x18cf(%rip), %rbx      # 0x30c0
xorl %ebp, %ebp
cvttss2si 0x38f1(%rip), %eax # 0x50ec
addl %ebp, %eax
cltq
imulq $-0x49f49f49, %rax, %rcx # imm = 0xB60B60B7
shrq $0x20, %rcx
addl %eax, %ecx
movl %ecx, %edx
shrl $0x1f, %edx
sarl $0x8, %ecx
addl %edx, %ecx
imull $0x168, %ecx, %ecx      # imm = 0x168
subl %ecx, %eax
cltq
imulq $0x169, %r13, %rcx      # imm = 0x169
addq %rbx, %rcx
movsbl (%rax,%rcx), %r15d
callq 0x1030
testb %al, %al
je 0x1861
xorl %eax, %eax
cmpb $0x4d, %r15b
sete %cl
movl $0x400, %esi            # imm = 0x400
cmpb $0x2a, %r15b
je 0x1856
movb %cl, %al
orl $0x2, %eax
shll $0x8, %eax
movl %eax, %esi
movq (%r12), %rdi
xorl %edx, %edx
callq 0x10c0
movq (%r12), %rdi
movl %r13d, %esi
movl %ebp, %edx
callq 0x1140
testb $0x1, %r14b
je 0x1885
cmpl $-0x1, %eax
je 0x1896
movq (%r12), %rdi
movl $0x20, %esi
jmp 0x1891
cmpl $-0x1, %eax
je 0x1896
movq (%r12), %rdi
movl %r15d, %esi
callq 0x1150
callq 0x1030
testb %al, %al
je 0x18c8
xorl %eax, %eax
cmpb $0x4d, %r15b
sete %cl
movl $0x400, %esi            # imm = 0x400
cmpb $0x2a, %r15b
je 0x18bd
movb %cl, %al
orl $0x2, %eax
shll $0x8, %eax
movl %eax, %esi
movq (%r12), %rdi
xorl %edx, %edx
callq 0x1190
incl %ebp
cmpl $0x50, %ebp
jne 0x17f3
incq %r13
cmpq $0x5, %r13
jne 0x17f1
movq 0x18(%rsp), %rax
addl $0x24, %eax
movl 0x3802(%rip), %edx      # 0x50f0
imull 0x30(%rsp), %edx
movl $0x88888889, %ecx       # imm = 0x88888889
imulq %rcx, %rdx
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
shrq $0x24, %rdx
movq %rdx, 0x38(%rsp)
divss 0x1744(%rip), %xmm0     # 0x3058
movss %xmm0, 0x28(%rsp)
xorl %ebx, %ebx
movl $0x3, %r15d
movl %r15d, 0x2c(%rsp)
movl $0x12, %eax
subl %ebx, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
mulss 0x28(%rsp), %xmm0
cvttss2si %xmm0, %r13d
cmpl $-0x2, %r13d
jl 0x19b4
leal 0x5(%rbx), %ebp
leal 0x2(%r13), %r14d
xorl %r15d, %r15d
testl %r14d, %r14d
cmovlel %r15d, %r14d
incl %r14d
callq 0x1030
testb %al, %al
je 0x1973
movq (%r12), %rdi
movl $0x300, %esi            # imm = 0x300
xorl %edx, %edx
callq 0x10c0
movq (%r12), %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x1140
cmpl $-0x1, %eax
je 0x1993
movq (%r12), %rdi
movl 0x20(%rsp), %esi
callq 0x1150
callq 0x1030
testb %al, %al
je 0x19ac
movq (%r12), %rdi
movl $0x300, %esi            # imm = 0x300
xorl %edx, %edx
callq 0x1190
incl %r15d
cmpl %r15d, %r14d
jne 0x195a
cmpl $0x2, %ebx
movl 0x2c(%rsp), %r15d
jb 0x1a1d
movl %ebx, %eax
xorl 0x38(%rsp), %eax
testb $0x1, %al
jne 0x1a1d
callq 0x1030
testb %al, %al
je 0x19e1
movq (%r12), %rdi
movl $0x800, %esi            # imm = 0x800
xorl %edx, %edx
callq 0x10c0
movq (%r12), %rdi
leal 0x5(%rbx), %esi
leal 0x3(%r13,%rbx,2), %edx
callq 0x1140
cmpl $-0x1, %eax
je 0x1a04
movq (%r12), %rdi
movl 0x24(%rsp), %esi
callq 0x1150
callq 0x1030
testb %al, %al
je 0x1a1d
movq (%r12), %rdi
movl $0x800, %esi            # imm = 0x800
xorl %edx, %edx
callq 0x1190
leal (,%rbx,4), %eax
addl %r13d, %eax
addl $0x4, %eax
cmpl $0x4f, %eax
movl 0xc(%rsp), %r14d
jg 0x1a95
leal 0x5(%rbx), %ebp
addl %r15d, %r13d
callq 0x1030
testb %al, %al
je 0x1a53
movq (%r12), %rdi
movl $0x300, %esi            # imm = 0x300
xorl %edx, %edx
callq 0x10c0
incl %r13d
movq (%r12), %rdi
movl %ebp, %esi
movl %r13d, %edx
callq 0x1140
cmpl $-0x1, %eax
je 0x1a76
movq (%r12), %rdi
movl 0x20(%rsp), %esi
callq 0x1150
callq 0x1030
testb %al, %al
je 0x1a8f
movq (%r12), %rdi
movl $0x300, %esi            # imm = 0x300
xorl %edx, %edx
callq 0x1190
cmpl $0x4f, %r13d
jl 0x1a3a
incl %ebx
addl $0x4, %r15d
cmpl $0x13, %ebx
jne 0x1922
incl 0x3646(%rip)            # 0x50f0
movl $0xc, %ebx
movq 0x18(%rsp), %r15
movl 0x38(%rsp,%rbx), %esi
movl 0x40(%rsp,%rbx), %edx
movzbl %r14b, %ebp
andl $0x1, %ebp
movl %r15d, %edi
xorl %ecx, %ecx
movl %ebp, %r8d
callq 0x1ce0
addq $0x10, %rbx
cmpq $0x5c, %rbx
jne 0x1ab4
movl %r15d, %edi
movl $0x14, %esi
movl 0x10(%rsp), %edx
movl $0x1, %ecx
movl %ebp, %r8d
callq 0x1ce0
movl $0x6, %edi
xorl %esi, %esi
leaq 0x1d0a(%rip), %rdx      # 0x380b
movl 0x14(%rsp), %ecx
xorl %eax, %eax
callq 0x10e0
movq 0x30(%rsp), %r13
leal (,%r13,2), %eax
leal (%rax,%rax,4), %ecx
movl $0x7, %edi
xorl %esi, %esi
leaq 0x1ceb(%rip), %rdx      # 0x3815
xorl %eax, %eax
callq 0x10e0
movq (%r12), %rdi
callq 0x1090
movl $0x4e20, %edi           # imm = 0x4E20
callq 0x11a0
xorps %xmm0, %xmm0
cvtsi2ss %r13d, %xmm0
addss 0x35a4(%rip), %xmm0     # 0x50f8
movss %xmm0, 0x359c(%rip)     # 0x50f8
ucomiss 0x14d1(%rip), %xmm0     # 0x3034
jbe 0x1bce
callq 0x1110
movq %rax, %rcx
movabsq $0x5555555555555556, %rdx # imm = 0x5555555555555556
imulq %rdx
movq %rdx, %rax
shrq $0x3f, %rax
addl %edx, %eax
leal (%rax,%rax,2), %eax
movl 0x3568(%rip), %edx      # 0x50f4
subl %ecx, %eax
leal (%rdx,%rax), %ecx
incl %ecx
movl %ecx, 0x355b(%rip)      # 0x50f4
movl $0x1e, %eax
cmpl $0x1e, %ecx
movl 0x8(%rsp), %edx
jg 0x1bb1
movl $0xffffffe2, %eax       # imm = 0xFFFFFFE2
cmpl $-0x1f, %ecx
jg 0x1bb9
movl %eax, 0x353d(%rip)      # 0x50f4
movl %eax, %ecx
movq %rcx, 0x18(%rsp)
movl $0x0, 0x3530(%rip)      # 0x50f8
movl 0x10(%rsp), %ebp
jmp 0x1be1
movl 0x3520(%rip), %eax      # 0x50f4
movq %rax, 0x18(%rsp)
movl 0x10(%rsp), %ebp
movl 0x8(%rsp), %edx
testb $0x1, %dl
je 0x14e7
callq 0x1170
movq 0x33e2(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
leaq 0x1c1c(%rip), %rsi      # 0x381c
xorl %ebx, %ebx
movl 0x14(%rsp), %edx
xorl %eax, %eax
callq 0x10d0
movl %ebx, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq