#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*/ cleardevice();
int /*<<< orphan*/ closegraph();
int /*<<< orphan*/ delay(int);
int /*<<< orphan*/ forwd(int);
int /*<<< orphan*/ getch();
int getmaxx();
int getmaxy();
int /*<<< orphan*/ hilbert_left(int, int);
int /*<<< orphan*/ home();
int /*<<< orphan*/ initgraph(int *, int *, char *);
scalar_t__ kbhit();
int /*<<< orphan*/ koch(int, int);
int /*<<< orphan*/ outtextxy(int /*<<< orphan*/, int, char *);
int powerof2(int);
int rand();
int /*<<< orphan*/ setbkcolor(int);
int /*<<< orphan*/ setcolor(int);
int /*<<< orphan*/ setheading(int);
int /*<<< orphan*/ setposition(int, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ sq_koch(int, int);
int /*<<< orphan*/ star(int);
int /*<<< orphan*/ star_20(int);
int /*<<< orphan*/ star_6(int);
int /*<<< orphan*/ tree(int, int);
int /*<<< orphan*/ turnright(int);
int /*<<< orphan*/ usleep(int);
int main(void) {
  int i, l, x, y, xc, gd, gm;
  char s[32];
  gd = 11;
  gm = 7;
  initgraph(&gd, &gm, "");
  setbkcolor(0);
  for (i = 0; i < 6; i++) {
    cleardevice();
    setcolor(2);
    outtextxy(0, 0, "Standard Koch curve:");
    setposition(0, getmaxy() / 2);
    setheading(90);
    setcolor(i + 1);
    koch(getmaxx() + 1, i);
    usleep(500000);
  }
  setcolor(14);
  outtextxy(0, 20, "PRESS A KEY TO CONTINUE:");
  getch();
  for (i = 0; i < 14; i++) {
    cleardevice();
    setcolor(14);
    outtextxy(0, 0, "Tree:");
    setposition(getmaxx() * 4 / 10, getmaxy());
    setheading(0);
    tree(getmaxy() / 3, i);
    usleep(500000);
  }
  setcolor(14);
  outtextxy(0, 20, "PRESS A KEY TO CONTINUE:");
  getch();
  for (i = 0; i < 6; i++) {
    cleardevice();
    setcolor(4);
    outtextxy(0, 0, "Square Koch curve:");
    setposition(0, getmaxy() / 2);
    setheading(90);
    setcolor(i + 1);
    sq_koch(getmaxx() + 1, i);
    usleep(500000);
  }
  setcolor(14);
  outtextxy(0, 20, "PRESS A KEY TO CONTINUE:");
  getch();
  cleardevice();
  setcolor(4);
  outtextxy(0, 0, "Rotating square:");
  home();
  setheading(0);
  l = getmaxx() / 2;
  for (i = 1; i < l; i++) {
    setcolor(1 + i % 15);
    forwd(i);
    turnright(89);
    delay(10);
    if (kbhit())
      break;
  }
  setcolor(14);
  outtextxy(0, 20, "PRESS A KEY TO CONTINUE:");
  getch();
  setbkcolor(15);
  cleardevice();
  xc = getmaxx() / 2;
  x = xc;
  for (i = 1; i < 8; i++) {
    l = getmaxy() / powerof2(i);
    x += l / 2;
    y = l / 2;
    setposition(x, y);
    setheading(270);
    setcolor(1);
    hilbert_left(l, i);
    sprintf(s, "Hilbert curve at level %d", i);
    setcolor(1);
    outtextxy(0, 0, s);
    getch();
    cleardevice();
  }
  outtextxy(0, 0, "PRESS A KEY TO EXIT:");
  while (!kbhit()) {
    setposition((rand() % (getmaxx())), (rand() % (getmaxy())));
    setheading((rand() % (360)));
    setcolor(1 + (rand() % (15)));
    star((rand() % (80)));
    star_6((rand() % (20)));
    star_20((rand() % (40)));
    usleep(50000);
  }
  closegraph();
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xb,-0x1c(%rbp)
movl   $0x7,-0x20(%rbp)
lea    -0x1c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    0xd51(%rip),%rdx
call   1030 <initgraph@plt>
xor    %edi,%edi
call   1060 <setbkcolor@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x6,-0x8(%rbp)
jge    1373 <main+0xc3>
mov    $0x0,%al
call   1050 <cleardevice@plt>
mov    $0x2,%edi
call   11a0 <setcolor@plt>
xor    %esi,%esi
lea    0xced(%rip),%rdx
mov    %esi,%edi
call   1070 <outtextxy@plt>
mov    $0x0,%al
call   1080 <getmaxy@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
xor    %edi,%edi
call   10f0 <setposition@plt>
mov    $0x5a,%edi
call   1120 <setheading@plt>
mov    -0x8(%rbp),%edi
add    $0x1,%edi
call   11a0 <setcolor@plt>
mov    $0x0,%al
call   1130 <getmaxx@plt>
mov    %eax,%edi
add    $0x1,%edi
mov    -0x8(%rbp),%esi
call   10e0 <koch@plt>
mov    $0x7a120,%edi
call   11d0 <usleep@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    12ef <main+0x3f>
mov    $0xe,%edi
call   11a0 <setcolor@plt>
xor    %edi,%edi
mov    $0x14,%esi
lea    0xc8a(%rip),%rdx
call   1070 <outtextxy@plt>
mov    $0x0,%al
call   1150 <getch@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xe,-0x8(%rbp)
jge    1427 <main+0x177>
mov    $0x0,%al
call   1050 <cleardevice@plt>
mov    $0xe,%edi
call   11a0 <setcolor@plt>
xor    %esi,%esi
lea    0xc6c(%rip),%rdx
mov    %esi,%edi
call   1070 <outtextxy@plt>
mov    $0x0,%al
call   1130 <getmaxx@plt>
shl    $0x2,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x44(%rbp)
mov    $0x0,%al
call   1080 <getmaxy@plt>
mov    -0x44(%rbp),%edi
mov    %eax,%esi
call   10f0 <setposition@plt>
xor    %edi,%edi
call   1120 <setheading@plt>
mov    $0x0,%al
call   1080 <getmaxy@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%esi
call   1170 <tree@plt>
mov    $0x7a120,%edi
call   11d0 <usleep@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    139e <main+0xee>
mov    $0xe,%edi
call   11a0 <setcolor@plt>
xor    %edi,%edi
mov    $0x14,%esi
lea    0xbd6(%rip),%rdx
call   1070 <outtextxy@plt>
mov    $0x0,%al
call   1150 <getch@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x6,-0x8(%rbp)
jge    14d6 <main+0x226>
mov    $0x0,%al
call   1050 <cleardevice@plt>
mov    $0x4,%edi
call   11a0 <setcolor@plt>
xor    %esi,%esi
lea    0xbbe(%rip),%rdx
mov    %esi,%edi
call   1070 <outtextxy@plt>
mov    $0x0,%al
call   1080 <getmaxy@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
xor    %edi,%edi
call   10f0 <setposition@plt>
mov    $0x5a,%edi
call   1120 <setheading@plt>
mov    -0x8(%rbp),%edi
add    $0x1,%edi
call   11a0 <setcolor@plt>
mov    $0x0,%al
call   1130 <getmaxx@plt>
mov    %eax,%edi
add    $0x1,%edi
mov    -0x8(%rbp),%esi
call   11b0 <sq_koch@plt>
mov    $0x7a120,%edi
call   11d0 <usleep@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1452 <main+0x1a2>
mov    $0xe,%edi
call   11a0 <setcolor@plt>
xor    %edi,%edi
mov    $0x14,%esi
lea    0xb27(%rip),%rdx
call   1070 <outtextxy@plt>
mov    $0x0,%al
call   1150 <getch@plt>
mov    $0x0,%al
call   1050 <cleardevice@plt>
mov    $0x4,%edi
call   11a0 <setcolor@plt>
xor    %esi,%esi
lea    0xb33(%rip),%rdx
mov    %esi,%edi
call   1070 <outtextxy@plt>
mov    $0x0,%al
call   10c0 <home@plt>
xor    %edi,%edi
call   1120 <setheading@plt>
mov    $0x0,%al
call   1130 <getmaxx@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    15a8 <main+0x2f8>
mov    -0x8(%rbp),%eax
mov    $0xf,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x1,%edi
call   11a0 <setcolor@plt>
mov    -0x8(%rbp),%edi
call   1160 <forwd@plt>
mov    $0x59,%edi
call   1140 <turnright@plt>
mov    $0xa,%edi
call   10b0 <delay@plt>
mov    $0x0,%al
call   1090 <kbhit@plt>
cmp    $0x0,%rax
je     1595 <main+0x2e5>
jmp    15a8 <main+0x2f8>
jmp    159a <main+0x2ea>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1542 <main+0x292>
mov    $0xe,%edi
call   11a0 <setcolor@plt>
xor    %edi,%edi
mov    $0x14,%esi
lea    0xa55(%rip),%rdx
call   1070 <outtextxy@plt>
mov    $0x0,%al
call   1150 <getch@plt>
mov    $0xf,%edi
call   1060 <setbkcolor@plt>
mov    $0x0,%al
call   1050 <cleardevice@plt>
mov    $0x0,%al
call   1130 <getmaxx@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    16b2 <main+0x402>
mov    $0x0,%al
call   1080 <getmaxy@plt>
mov    %eax,-0x48(%rbp)
mov    -0x8(%rbp),%edi
call   1100 <powerof2@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   10f0 <setposition@plt>
mov    $0x10e,%edi
call   1120 <setheading@plt>
mov    $0x1,%edi
call   11a0 <setcolor@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1110 <hilbert_left@plt>
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0x9de(%rip),%rsi
call   1190 <sprintf@plt>
mov    $0x1,%edi
call   11a0 <setcolor@plt>
lea    -0x40(%rbp),%rdx
xor    %esi,%esi
mov    %esi,%edi
call   1070 <outtextxy@plt>
mov    $0x0,%al
call   1150 <getch@plt>
mov    $0x0,%al
call   1050 <cleardevice@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    15fc <main+0x34c>
xor    %esi,%esi
lea    0x9b7(%rip),%rdx
mov    %esi,%edi
call   1070 <outtextxy@plt>
mov    $0x0,%al
call   1090 <kbhit@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    16df <main+0x42f>
jmp    179e <main+0x4ee>
mov    $0x0,%al
call   11c0 <rand@plt>
mov    %eax,-0x54(%rbp)
mov    $0x0,%al
call   1130 <getmaxx@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,-0x50(%rbp)
mov    $0x0,%al
call   11c0 <rand@plt>
mov    %eax,-0x4c(%rbp)
mov    $0x0,%al
call   1080 <getmaxy@plt>
mov    -0x50(%rbp),%edi
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,%esi
call   10f0 <setposition@plt>
mov    $0x0,%al
call   11c0 <rand@plt>
mov    $0x168,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1120 <setheading@plt>
mov    $0x0,%al
call   11c0 <rand@plt>
mov    $0xf,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x1,%edi
call   11a0 <setcolor@plt>
mov    $0x0,%al
call   11c0 <rand@plt>
mov    $0x50,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1040 <star@plt>
mov    $0x0,%al
call   11c0 <rand@plt>
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   10a0 <star_6@plt>
mov    $0x0,%al
call   11c0 <rand@plt>
mov    $0x28,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1180 <star_20@plt>
mov    $0xc350,%edi
call   11d0 <usleep@plt>
jmp    16c2 <main+0x412>
mov    $0x0,%al
call   10d0 <closegraph@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
movl   $0xb,0xc(%rsp)
movl   $0x7,0x8(%rsp)
lea    0xd5a(%rip),%rdx
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1030 <initgraph@plt>
xor    %edi,%edi
call   1060 <setbkcolor@plt>
lea    0xd10(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <cleardevice@plt>
mov    $0x2,%edi
call   11a0 <setcolor@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    %r14,%rdx
call   1070 <outtextxy@plt>
xor    %eax,%eax
call   1080 <getmaxy@plt>
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
xor    %edi,%edi
call   10f0 <setposition@plt>
mov    $0x5a,%edi
call   1120 <setheading@plt>
lea    0x1(%rbp),%ebx
mov    %ebx,%edi
call   11a0 <setcolor@plt>
xor    %eax,%eax
call   1130 <getmaxx@plt>
lea    0x1(%rax),%edi
mov    %ebp,%esi
call   10e0 <koch@plt>
mov    $0x7a120,%edi
call   11d0 <usleep@plt>
mov    %ebx,%ebp
cmp    $0x6,%ebx
jne    1300 <main+0x50>
mov    $0xe,%edi
call   11a0 <setcolor@plt>
lea    0xc9a(%rip),%rdx
xor    %edi,%edi
mov    $0x14,%esi
call   1070 <outtextxy@plt>
xor    %eax,%eax
call   1150 <getch@plt>
lea    0xc99(%rip),%r14
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <cleardevice@plt>
mov    $0xe,%edi
call   11a0 <setcolor@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    %r14,%rdx
call   1070 <outtextxy@plt>
xor    %eax,%eax
call   1130 <getmaxx@plt>
shl    $0x2,%eax
cltq
imul   $0x66666667,%rax,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
shr    $0x20,%rbx
sar    $0x2,%ebx
add    %eax,%ebx
xor    %eax,%eax
call   1080 <getmaxy@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   10f0 <setposition@plt>
xor    %edi,%edi
call   1120 <setheading@plt>
xor    %eax,%eax
call   1080 <getmaxy@plt>
cltq
imul   $0x55555556,%rax,%rdi
mov    %rdi,%rax
shr    $0x3f,%rax
shr    $0x20,%rdi
add    %eax,%edi
mov    %ebp,%esi
call   1170 <tree@plt>
mov    $0x7a120,%edi
call   11d0 <usleep@plt>
add    $0x1,%ebp
cmp    $0xe,%ebp
jne    13a0 <main+0xf0>
mov    $0xe,%edi
call   11a0 <setcolor@plt>
lea    0xbd3(%rip),%rdx
xor    %edi,%edi
mov    $0x14,%esi
call   1070 <outtextxy@plt>
xor    %eax,%eax
call   1150 <getch@plt>
lea    0xbd8(%rip),%r14
xor    %ebp,%ebp
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <cleardevice@plt>
mov    $0x4,%edi
call   11a0 <setcolor@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    %r14,%rdx
call   1070 <outtextxy@plt>
xor    %eax,%eax
call   1080 <getmaxy@plt>
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
xor    %edi,%edi
call   10f0 <setposition@plt>
mov    $0x5a,%edi
call   1120 <setheading@plt>
lea    0x1(%rbp),%ebx
mov    %ebx,%edi
call   11a0 <setcolor@plt>
xor    %eax,%eax
call   1130 <getmaxx@plt>
lea    0x1(%rax),%edi
mov    %ebp,%esi
call   11b0 <sq_koch@plt>
mov    $0x7a120,%edi
call   11d0 <usleep@plt>
mov    %ebx,%ebp
cmp    $0x6,%ebx
jne    1460 <main+0x1b0>
mov    $0xe,%edi
call   11a0 <setcolor@plt>
lea    0xb3a(%rip),%rdx
xor    %edi,%edi
mov    $0x14,%esi
call   1070 <outtextxy@plt>
xor    %eax,%eax
call   1150 <getch@plt>
xor    %eax,%eax
call   1050 <cleardevice@plt>
mov    $0x4,%edi
call   11a0 <setcolor@plt>
lea    0xb41(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
call   1070 <outtextxy@plt>
xor    %eax,%eax
call   10c0 <home@plt>
xor    %edi,%edi
call   1120 <setheading@plt>
xor    %eax,%eax
call   1130 <getmaxx@plt>
cmp    $0x4,%eax
jl     15a1 <main+0x2f1>
mov    %eax,%r14d
shr    $0x1f,%r14d
add    %eax,%r14d
sar    %r14d
mov    $0x1,%ebp
mov    $0x2,%ebx
mov    $0x88888889,%r15d
cs nopw 0x0(%rax,%rax,1)
lea    -0x1(%rbx),%r12d
mov    %ebp,%edi
imul   %r15,%rdi
shr    $0x23,%rdi
mov    %edi,%eax
shl    $0x4,%eax
sub    %eax,%edi
add    %ebx,%edi
call   11a0 <setcolor@plt>
mov    %r12d,%edi
call   1160 <forwd@plt>
mov    $0x59,%edi
call   1140 <turnright@plt>
mov    $0xa,%edi
call   10b0 <delay@plt>
xor    %eax,%eax
call   1090 <kbhit@plt>
test   %rax,%rax
jne    15a1 <main+0x2f1>
add    $0x1,%ebp
lea    0x1(%rbx),%eax
cmp    %r14d,%ebx
mov    %eax,%ebx
jl     1550 <main+0x2a0>
mov    $0xe,%edi
call   11a0 <setcolor@plt>
lea    0xa63(%rip),%rdx
xor    %edi,%edi
mov    $0x14,%esi
call   1070 <outtextxy@plt>
xor    %eax,%eax
call   1150 <getch@plt>
mov    $0xf,%edi
call   1060 <setbkcolor@plt>
xor    %eax,%eax
call   1050 <cleardevice@plt>
xor    %eax,%eax
call   1130 <getmaxx@plt>
mov    %eax,%r12d
shr    $0x1f,%r12d
add    %eax,%r12d
sar    %r12d
mov    $0x1,%ebp
lea    0xa62(%rip),%r14
lea    0x10(%rsp),%r15
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <getmaxy@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1100 <powerof2@plt>
mov    %eax,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
mov    %eax,%ebx
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
add    %esi,%r12d
mov    %r12d,%edi
call   10f0 <setposition@plt>
mov    $0x10e,%edi
call   1120 <setheading@plt>
mov    $0x1,%edi
call   11a0 <setcolor@plt>
mov    %ebx,%edi
mov    %ebp,%esi
call   1110 <hilbert_left@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1190 <sprintf@plt>
mov    $0x1,%edi
call   11a0 <setcolor@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    %r15,%rdx
call   1070 <outtextxy@plt>
xor    %eax,%eax
call   1150 <getch@plt>
xor    %eax,%eax
call   1050 <cleardevice@plt>
add    $0x1,%ebp
cmp    $0x8,%ebp
jne    1600 <main+0x350>
lea    0x9e4(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
call   1070 <outtextxy@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <kbhit@plt>
test   %rax,%rax
jne    17da <main+0x52a>
xor    %eax,%eax
call   11c0 <rand@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1130 <getmaxx@plt>
mov    %eax,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
mov    %edx,%ebx
xor    %eax,%eax
call   11c0 <rand@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1080 <getmaxy@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %ebx,%edi
mov    %edx,%esi
call   10f0 <setposition@plt>
xor    %eax,%eax
call   11c0 <rand@plt>
movslq %eax,%rdi
imul   $0xffffffffb60b60b7,%rdi,%rax
shr    $0x20,%rax
add    %edi,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x8,%eax
add    %ecx,%eax
imul   $0x168,%eax,%eax
sub    %eax,%edi
call   1120 <setheading@plt>
xor    %eax,%eax
call   11c0 <rand@plt>
cltq
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x3,%ecx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
lea    (%rcx,%rcx,2),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%edi
add    $0x1,%edi
call   11a0 <setcolor@plt>
xor    %eax,%eax
call   11c0 <rand@plt>
movslq %eax,%rdi
imul   $0x66666667,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
shl    $0x4,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edi
call   1040 <star@plt>
xor    %eax,%eax
call   11c0 <rand@plt>
movslq %eax,%rdi
imul   $0x66666667,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
shl    $0x2,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edi
call   10a0 <star_6@plt>
xor    %eax,%eax
call   11c0 <rand@plt>
movslq %eax,%rdi
imul   $0x66666667,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x24,%rax
add    %ecx,%eax
shl    $0x3,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edi
call   1180 <star_20@plt>
mov    $0xc350,%edi
call   11d0 <usleep@plt>
jmp    16a0 <main+0x3f0>
xor    %eax,%eax
call   10d0 <closegraph@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [21 x i8] c"Standard Koch curve:\00"
@.str.2 = [25 x i8] c"PRESS A KEY TO CONTINUE:\00"
@.str.3 = [6 x i8] c"Tree:\00"
@.str.4 = [19 x i8] c"Square Koch curve:\00"
@.str.5 = [17 x i8] c"Rotating square:\00"
@.str.6 = [26 x i8] c"Hilbert curve at level %d\00"
@.str.7 = [21 x i8] c"PRESS A KEY TO EXIT:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [32 x i8]
store i32 0, i32* %1
store i32 11, i32* %7
store i32 7, i32* %8
%10 = call i32 @initgraph(i32* %7, i32* %8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @setbkcolor(i32 0)
store i32 0, i32* %2
br label %12
12: ; preds = %31, %0
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 6
br i1 %14, label %15, label %34
15: ; preds = %12
%16 = call i32 (...) @cleardevice()
%17 = call i32 @setcolor(i32 2)
%18 = call i32 @outtextxy(i32 0, i32 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 (...) @getmaxy()
%20 = sdiv i32 %19, 2
%21 = call i32 @setposition(i32 0, i32 %20)
%22 = call i32 @setheading(i32 90)
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
%25 = call i32 @setcolor(i32 %24)
%26 = call i32 (...) @getmaxx()
%27 = add nsw i32 %26, 1
%28 = load i32, i32* %2
%29 = call i32 @koch(i32 %27, i32 %28)
%30 = call i32 @usleep(i32 500000)
br label %31
31: ; preds = %15
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %12
34: ; preds = %12
%35 = call i32 @setcolor(i32 14)
%36 = call i32 @outtextxy(i32 0, i32 20, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%37 = call i32 (...) @getch()
store i32 0, i32* %2
br label %38
38: ; preds = %56, %34
%39 = load i32, i32* %2
%40 = icmp slt i32 %39, 14
br i1 %40, label %41, label %59
41: ; preds = %38
%42 = call i32 (...) @cleardevice()
%43 = call i32 @setcolor(i32 14)
%44 = call i32 @outtextxy(i32 0, i32 0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%45 = call i32 (...) @getmaxx()
%46 = mul nsw i32 %45, 4
%47 = sdiv i32 %46, 10
%48 = call i32 (...) @getmaxy()
%49 = call i32 @setposition(i32 %47, i32 %48)
%50 = call i32 @setheading(i32 0)
%51 = call i32 (...) @getmaxy()
%52 = sdiv i32 %51, 3
%53 = load i32, i32* %2
%54 = call i32 @tree(i32 %52, i32 %53)
%55 = call i32 @usleep(i32 500000)
br label %56
56: ; preds = %41
%57 = load i32, i32* %2
%58 = add nsw i32 %57, 1
store i32 %58, i32* %2
br label %38
59: ; preds = %38
%60 = call i32 @setcolor(i32 14)
%61 = call i32 @outtextxy(i32 0, i32 20, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%62 = call i32 (...) @getch()
store i32 0, i32* %2
br label %63
63: ; preds = %82, %59
%64 = load i32, i32* %2
%65 = icmp slt i32 %64, 6
br i1 %65, label %66, label %85
66: ; preds = %63
%67 = call i32 (...) @cleardevice()
%68 = call i32 @setcolor(i32 4)
%69 = call i32 @outtextxy(i32 0, i32 0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%70 = call i32 (...) @getmaxy()
%71 = sdiv i32 %70, 2
%72 = call i32 @setposition(i32 0, i32 %71)
%73 = call i32 @setheading(i32 90)
%74 = load i32, i32* %2
%75 = add nsw i32 %74, 1
%76 = call i32 @setcolor(i32 %75)
%77 = call i32 (...) @getmaxx()
%78 = add nsw i32 %77, 1
%79 = load i32, i32* %2
%80 = call i32 @sq_koch(i32 %78, i32 %79)
%81 = call i32 @usleep(i32 500000)
br label %82
82: ; preds = %66
%83 = load i32, i32* %2
%84 = add nsw i32 %83, 1
store i32 %84, i32* %2
br label %63
85: ; preds = %63
%86 = call i32 @setcolor(i32 14)
%87 = call i32 @outtextxy(i32 0, i32 20, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%88 = call i32 (...) @getch()
%89 = call i32 (...) @cleardevice()
%90 = call i32 @setcolor(i32 4)
%91 = call i32 @outtextxy(i32 0, i32 0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%92 = call i32 (...) @home()
%93 = call i32 @setheading(i32 0)
%94 = call i32 (...) @getmaxx()
%95 = sdiv i32 %94, 2
store i32 %95, i32* %3
store i32 1, i32* %2
br label %96
96: ; preds = %113, %85
%97 = load i32, i32* %2
%98 = load i32, i32* %3
%99 = icmp slt i32 %97, %98
br i1 %99, label %100, label %116
100: ; preds = %96
%101 = load i32, i32* %2
%102 = srem i32 %101, 15
%103 = add nsw i32 1, %102
%104 = call i32 @setcolor(i32 %103)
%105 = load i32, i32* %2
%106 = call i32 @forwd(i32 %105)
%107 = call i32 @turnright(i32 89)
%108 = call i32 @delay(i32 10)
%109 = call i64 (...) @kbhit()
%110 = icmp ne i64 %109, 0
br i1 %110, label %111, label %112
111: ; preds = %100
br label %116
112: ; preds = %100
br label %113
113: ; preds = %112
%114 = load i32, i32* %2
%115 = add nsw i32 %114, 1
store i32 %115, i32* %2
br label %96
116: ; preds = %111, %96
%117 = call i32 @setcolor(i32 14)
%118 = call i32 @outtextxy(i32 0, i32 20, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%119 = call i32 (...) @getch()
%120 = call i32 @setbkcolor(i32 15)
%121 = call i32 (...) @cleardevice()
%122 = call i32 (...) @getmaxx()
%123 = sdiv i32 %122, 2
store i32 %123, i32* %6
%124 = load i32, i32* %6
store i32 %124, i32* %4
store i32 1, i32* %2
br label %125
125: ; preds = %155, %116
%126 = load i32, i32* %2
%127 = icmp slt i32 %126, 8
br i1 %127, label %128, label %158
128: ; preds = %125
%129 = call i32 (...) @getmaxy()
%130 = load i32, i32* %2
%131 = call i32 @powerof2(i32 %130)
%132 = sdiv i32 %129, %131
store i32 %132, i32* %3
%133 = load i32, i32* %3
%134 = sdiv i32 %133, 2
%135 = load i32, i32* %4
%136 = add nsw i32 %135, %134
store i32 %136, i32* %4
%137 = load i32, i32* %3
%138 = sdiv i32 %137, 2
store i32 %138, i32* %5
%139 = load i32, i32* %4
%140 = load i32, i32* %5
%141 = call i32 @setposition(i32 %139, i32 %140)
%142 = call i32 @setheading(i32 270)
%143 = call i32 @setcolor(i32 1)
%144 = load i32, i32* %3
%145 = load i32, i32* %2
%146 = call i32 @hilbert_left(i32 %144, i32 %145)
%147 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%148 = load i32, i32* %2
%149 = call i32 @sprintf(i8* %147, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i32 %148)
%150 = call i32 @setcolor(i32 1)
%151 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%152 = call i32 @outtextxy(i32 0, i32 0, i8* %151)
%153 = call i32 (...) @getch()
%154 = call i32 (...) @cleardevice()
br label %155
155: ; preds = %128
%156 = load i32, i32* %2
%157 = add nsw i32 %156, 1
store i32 %157, i32* %2
br label %125
158: ; preds = %125
%159 = call i32 @outtextxy(i32 0, i32 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %160
160: ; preds = %164, %158
%161 = call i64 (...) @kbhit()
%162 = icmp ne i64 %161, 0
%163 = xor i1 %162, true
br i1 %163, label %164, label %189
164: ; preds = %160
%165 = call i32 (...) @rand()
%166 = call i32 (...) @getmaxx()
%167 = srem i32 %165, %166
%168 = call i32 (...) @rand()
%169 = call i32 (...) @getmaxy()
%170 = srem i32 %168, %169
%171 = call i32 @setposition(i32 %167, i32 %170)
%172 = call i32 (...) @rand()
%173 = srem i32 %172, 360
%174 = call i32 @setheading(i32 %173)
%175 = call i32 (...) @rand()
%176 = srem i32 %175, 15
%177 = add nsw i32 1, %176
%178 = call i32 @setcolor(i32 %177)
%179 = call i32 (...) @rand()
%180 = srem i32 %179, 80
%181 = call i32 @star(i32 %180)
%182 = call i32 (...) @rand()
%183 = srem i32 %182, 20
%184 = call i32 @star_6(i32 %183)
%185 = call i32 (...) @rand()
%186 = srem i32 %185, 40
%187 = call i32 @star_20(i32 %186)
%188 = call i32 @usleep(i32 50000)
br label %160
189: ; preds = %160
%190 = call i32 (...) @closegraph()
ret i32 0
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [21 x i8] c"Standard Koch curve:\00"
@.str.2 = [25 x i8] c"PRESS A KEY TO CONTINUE:\00"
@.str.3 = [6 x i8] c"Tree:\00"
@.str.4 = [19 x i8] c"Square Koch curve:\00"
@.str.5 = [17 x i8] c"Rotating square:\00"
@.str.6 = [26 x i8] c"Hilbert curve at level %d\00"
@.str.7 = [21 x i8] c"PRESS A KEY TO EXIT:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [32 x i8]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
store i32 11, i32* %1
store i32 7, i32* %2
%7 = call i32 @initgraph(i32* %1, i32* %2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @setbkcolor(i32 0)
br label %9
9: ; preds = %0, %9
%10 = phi i32 [ 0, %0 ], [ %18, %9 ]
%11 = call i32 (...) @cleardevice()
%12 = call i32 @setcolor(i32 2)
%13 = call i32 @outtextxy(i32 0, i32 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (...) @getmaxy()
%15 = sdiv i32 %14, 2
%16 = call i32 @setposition(i32 0, i32 %15)
%17 = call i32 @setheading(i32 90)
%18 = add nuw nsw i32 %10, 1
%19 = call i32 @setcolor(i32 %18)
%20 = call i32 (...) @getmaxx()
%21 = add nsw i32 %20, 1
%22 = call i32 @koch(i32 %21, i32 %10)
%23 = call i32 @usleep(i32 500000)
%24 = icmp eq i32 %18, 6
br i1 %24, label %25, label %9
25: ; preds = %9
%26 = call i32 @setcolor(i32 14)
%27 = call i32 @outtextxy(i32 0, i32 20, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 (...) @getch()
br label %29
29: ; preds = %25, %29
%30 = phi i32 [ 0, %25 ], [ %44, %29 ]
%31 = call i32 (...) @cleardevice()
%32 = call i32 @setcolor(i32 14)
%33 = call i32 @outtextxy(i32 0, i32 0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%34 = call i32 (...) @getmaxx()
%35 = shl nsw i32 %34, 2
%36 = sdiv i32 %35, 10
%37 = call i32 (...) @getmaxy()
%38 = call i32 @setposition(i32 %36, i32 %37)
%39 = call i32 @setheading(i32 0)
%40 = call i32 (...) @getmaxy()
%41 = sdiv i32 %40, 3
%42 = call i32 @tree(i32 %41, i32 %30)
%43 = call i32 @usleep(i32 500000)
%44 = add nuw nsw i32 %30, 1
%45 = icmp eq i32 %44, 14
br i1 %45, label %46, label %29
46: ; preds = %29
%47 = call i32 @setcolor(i32 14)
%48 = call i32 @outtextxy(i32 0, i32 20, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%49 = call i32 (...) @getch()
br label %50
50: ; preds = %46, %50
%51 = phi i32 [ 0, %46 ], [ %59, %50 ]
%52 = call i32 (...) @cleardevice()
%53 = call i32 @setcolor(i32 4)
%54 = call i32 @outtextxy(i32 0, i32 0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%55 = call i32 (...) @getmaxy()
%56 = sdiv i32 %55, 2
%57 = call i32 @setposition(i32 0, i32 %56)
%58 = call i32 @setheading(i32 90)
%59 = add nuw nsw i32 %51, 1
%60 = call i32 @setcolor(i32 %59)
%61 = call i32 (...) @getmaxx()
%62 = add nsw i32 %61, 1
%63 = call i32 @sq_koch(i32 %62, i32 %51)
%64 = call i32 @usleep(i32 500000)
%65 = icmp eq i32 %59, 6
br i1 %65, label %66, label %50
66: ; preds = %50
%67 = call i32 @setcolor(i32 14)
%68 = call i32 @outtextxy(i32 0, i32 20, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%69 = call i32 (...) @getch()
%70 = call i32 (...) @cleardevice()
%71 = call i32 @setcolor(i32 4)
%72 = call i32 @outtextxy(i32 0, i32 0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%73 = call i32 (...) @home()
%74 = call i32 @setheading(i32 0)
%75 = call i32 (...) @getmaxx()
%76 = sdiv i32 %75, 2
%77 = icmp sgt i32 %75, 3
br i1 %77, label %78, label %91
78: ; preds = %66, %78
%79 = phi i32 [ %88, %78 ], [ 1, %66 ]
%80 = urem i32 %79, 15
%81 = add nuw nsw i32 %80, 1
%82 = call i32 @setcolor(i32 %81)
%83 = call i32 @forwd(i32 %79)
%84 = call i32 @turnright(i32 89)
%85 = call i32 @delay(i32 10)
%86 = call i64 (...) @kbhit()
%87 = icmp eq i64 %86, 0
%88 = add nuw nsw i32 %79, 1
%89 = icmp slt i32 %88, %76
%90 = select i1 %87, i1 %89, i1 false
br i1 %90, label %78, label %91
91: ; preds = %78, %66
%92 = call i32 @setcolor(i32 14)
%93 = call i32 @outtextxy(i32 0, i32 20, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%94 = call i32 (...) @getch()
%95 = call i32 @setbkcolor(i32 15)
%96 = call i32 (...) @cleardevice()
%97 = call i32 (...) @getmaxx()
%98 = sdiv i32 %97, 2
br label %99
99: ; preds = %91, %99
%100 = phi i32 [ 1, %91 ], [ %116, %99 ]
%101 = phi i32 [ %98, %91 ], [ %106, %99 ]
%102 = call i32 (...) @getmaxy()
%103 = call i32 @powerof2(i32 %100)
%104 = sdiv i32 %102, %103
%105 = sdiv i32 %104, 2
%106 = add nsw i32 %105, %101
%107 = call i32 @setposition(i32 %106, i32 %105)
%108 = call i32 @setheading(i32 270)
%109 = call i32 @setcolor(i32 1)
%110 = call i32 @hilbert_left(i32 %104, i32 %100)
%111 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i32 %100)
%112 = call i32 @setcolor(i32 1)
%113 = call i32 @outtextxy(i32 0, i32 0, i8* %6)
%114 = call i32 (...) @getch()
%115 = call i32 (...) @cleardevice()
%116 = add nuw nsw i32 %100, 1
%117 = icmp eq i32 %116, 8
br i1 %117, label %118, label %99
118: ; preds = %99
%119 = call i32 @outtextxy(i32 0, i32 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
%120 = call i64 (...) @kbhit()
%121 = icmp eq i64 %120, 0
br i1 %121, label %122, label %149
122: ; preds = %118, %122
%123 = call i32 (...) @rand()
%124 = call i32 (...) @getmaxx()
%125 = srem i32 %123, %124
%126 = call i32 (...) @rand()
%127 = call i32 (...) @getmaxy()
%128 = srem i32 %126, %127
%129 = call i32 @setposition(i32 %125, i32 %128)
%130 = call i32 (...) @rand()
%131 = srem i32 %130, 360
%132 = call i32 @setheading(i32 %131)
%133 = call i32 (...) @rand()
%134 = srem i32 %133, 15
%135 = add nsw i32 %134, 1
%136 = call i32 @setcolor(i32 %135)
%137 = call i32 (...) @rand()
%138 = srem i32 %137, 80
%139 = call i32 @star(i32 %138)
%140 = call i32 (...) @rand()
%141 = srem i32 %140, 20
%142 = call i32 @star_6(i32 %141)
%143 = call i32 (...) @rand()
%144 = srem i32 %143, 40
%145 = call i32 @star_20(i32 %144)
%146 = call i32 @usleep(i32 50000)
%147 = call i64 (...) @kbhit()
%148 = icmp eq i64 %147, 0
br i1 %148, label %122, label %149
149: ; preds = %122, %118
%150 = call i32 (...) @closegraph()
ret i32 0
}