#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*/ COLOR_PAIR(int);
scalar_t__ FALSE;
int /*<<< orphan*/ attrset(int /*<<< orphan*/);
int /*<<< orphan*/ clear();
int /*<<< orphan*/ curs_set(scalar_t__);
int /*<<< orphan*/ draw_point(int, int);
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/, int, int);
scalar_t__ has_colors();
int /*<<< orphan*/ init_pair(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ stdscr;
int /*<<< orphan*/ usleep(int);
int main(int argc, char *argv[]) {
  int x = 25, y = 5;
  int w, h;
  initscr();
  noecho();
  curs_set(FALSE);
  if (has_colors() == FALSE) {
    endwin();
    printf("Your terminal does not support color\n");
    exit(1);
  }
  start_color();
  init_pair(1, 1, 0);
  init_pair(2, 2, 0);
  init_pair(3, 3, 0);
  init_pair(4, 4, 0);
  init_pair(5, 5, 0);
  init_pair(6, 6, 0);
  init_pair(1, 7, 0);
  int xd = 1;
  int yd = 1;
  int color = 0;
  while (1) {
    getmaxyx(stdscr, h, w);
    if (y == 4) {
      yd = yd * -1;
    }
    if (y == h - 4) {
      yd = yd * -1;
    }
    if (x == 0) {
      xd = xd * -1;
    }
    if (x == w - 18) {
      xd = xd * -1;
    }
    if (color == 6) {
      color = -1;
    }
    y = y + yd;
    x = x + xd;
    color++;
    attrset(COLOR_PAIR(color));
    draw_point(x, y);
    usleep(30000);
    clear();
  }
  endwin();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x19,-0x14(%rbp)
movl   $0x5,-0x18(%rbp)
mov    $0x0,%al
call   1070 <initscr@plt>
mov    $0x0,%al
call   10d0 <noecho@plt>
mov    0x2daf(%rip),%rax
mov    (%rax),%rdi
call   1100 <curs_set@plt>
mov    $0x0,%al
call   1040 <has_colors@plt>
mov    0x2d99(%rip),%rcx
cmp    (%rcx),%rax
jne    1265 <main+0x75>
mov    $0x0,%al
call   10b0 <endwin@plt>
lea    0xdaa(%rip),%rdi
call   1060 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    $0x0,%al
call   1080 <start_color@plt>
mov    $0x1,%esi
xor    %edx,%edx
mov    %esi,%edi
call   1050 <init_pair@plt>
mov    $0x2,%esi
xor    %edx,%edx
mov    %esi,%edi
call   1050 <init_pair@plt>
mov    $0x3,%esi
xor    %edx,%edx
mov    %esi,%edi
call   1050 <init_pair@plt>
mov    $0x4,%esi
xor    %edx,%edx
mov    %esi,%edi
call   1050 <init_pair@plt>
mov    $0x5,%esi
xor    %edx,%edx
mov    %esi,%edi
call   1050 <init_pair@plt>
mov    $0x6,%esi
xor    %edx,%edx
mov    %esi,%edi
call   1050 <init_pair@plt>
mov    $0x1,%edi
mov    $0x7,%esi
xor    %edx,%edx
call   1050 <init_pair@plt>
movl   $0x1,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    0x2cfb(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1090 <getmaxyx@plt>
cmpl   $0x4,-0x18(%rbp)
jne    130b <main+0x11b>
imul   $0xffffffff,-0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x4,%ecx
cmp    %ecx,%eax
jne    1323 <main+0x133>
imul   $0xffffffff,-0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1334 <main+0x144>
imul   $0xffffffff,-0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x12,%ecx
cmp    %ecx,%eax
jne    134c <main+0x15c>
imul   $0xffffffff,-0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x6,-0x2c(%rbp)
jne    135d <main+0x16d>
movl   $0xffffffff,-0x2c(%rbp)
mov    -0x18(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   10a0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   10c0 <attrset@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <draw_point@plt>
mov    $0x7530,%edi
call   1110 <usleep@plt>
mov    $0x0,%al
call   10f0 <clear@plt>
jmp    12e6 <main+0xf6>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1070 <initscr@plt>
xor    %eax,%eax
call   10d0 <noecho@plt>
mov    0x2dc8(%rip),%rbx
mov    (%rbx),%rdi
call   1100 <curs_set@plt>
xor    %eax,%eax
call   1050 <has_colors@plt>
cmp    (%rbx),%rax
je     132a <main+0x13a>
xor    %eax,%eax
call   1080 <start_color@plt>
mov    $0x1,%r12d
mov    $0x1,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1060 <init_pair@plt>
mov    $0x2,%edi
mov    $0x2,%esi
xor    %edx,%edx
call   1060 <init_pair@plt>
mov    $0x3,%edi
mov    $0x3,%esi
xor    %edx,%edx
call   1060 <init_pair@plt>
mov    $0x4,%edi
mov    $0x4,%esi
xor    %edx,%edx
call   1060 <init_pair@plt>
mov    $0x5,%r14d
mov    $0x5,%edi
mov    $0x5,%esi
xor    %edx,%edx
call   1060 <init_pair@plt>
mov    $0x6,%edi
mov    $0x6,%esi
xor    %edx,%edx
call   1060 <init_pair@plt>
mov    $0x1,%edi
mov    $0x7,%esi
xor    %edx,%edx
call   1060 <init_pair@plt>
mov    $0x19,%ebp
mov    $0x1,%r15d
xor    %r13d,%r13d
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
call   1090 <getmaxyx@plt>
mov    %r15d,%eax
neg    %eax
cmp    $0x4,%r14d
cmove  %eax,%r15d
mov    %r12d,%eax
neg    %eax
test   %ebp,%ebp
cmove  %eax,%r12d
add    %r15d,%r14d
add    %r12d,%ebp
lea    0x1(%r13),%ebx
cmp    $0x6,%r13d
mov    $0x0,%eax
cmove  %eax,%ebx
mov    %ebx,%edi
call   10a0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   10c0 <attrset@plt>
mov    %ebp,%edi
mov    %r14d,%esi
call   1030 <draw_point@plt>
mov    $0x7530,%edi
call   1110 <usleep@plt>
xor    %eax,%eax
call   10f0 <clear@plt>
mov    %ebx,%r13d
jmp    12c0 <main+0xd0>
xor    %eax,%eax
call   10b0 <endwin@plt>
lea    0xcc8(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@FALSE = global i64 0
@.str = [38 x i8] c"Your terminal does not support color\0A\00"
@stdscr = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 25, i32* %6
store i32 5, i32* %7
%13 = call i32 (...) @initscr()
%14 = call i32 (...) @noecho()
%15 = load i64, i64* @FALSE
%16 = call i32 @curs_set(i64 %15)
%17 = call i64 (...) @has_colors()
%18 = load i64, i64* @FALSE
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %2
%21 = call i32 (...) @endwin()
%22 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %2
%25 = call i32 (...) @start_color()
%26 = call i32 @init_pair(i32 1, i32 1, i32 0)
%27 = call i32 @init_pair(i32 2, i32 2, i32 0)
%28 = call i32 @init_pair(i32 3, i32 3, i32 0)
%29 = call i32 @init_pair(i32 4, i32 4, i32 0)
%30 = call i32 @init_pair(i32 5, i32 5, i32 0)
%31 = call i32 @init_pair(i32 6, i32 6, i32 0)
%32 = call i32 @init_pair(i32 1, i32 7, i32 0)
store i32 1, i32* %10
store i32 1, i32* %11
store i32 0, i32* %12
br label %33
33: ; preds = %24, %69
%34 = load i32, i32* @stdscr
%35 = load i32, i32* %9
%36 = load i32, i32* %8
%37 = call i32 @getmaxyx(i32 %34, i32 %35, i32 %36)
%38 = load i32, i32* %7
%39 = icmp eq i32 %38, 4
br i1 %39, label %40, label %43
40: ; preds = %33
%41 = load i32, i32* %11
%42 = mul nsw i32 %41, -1
store i32 %42, i32* %11
br label %43
43: ; preds = %40, %33
%44 = load i32, i32* %7
%45 = load i32, i32* %9
%46 = sub nsw i32 %45, 4
%47 = icmp eq i32 %44, %46
br i1 %47, label %48, label %51
48: ; preds = %43
%49 = load i32, i32* %11
%50 = mul nsw i32 %49, -1
store i32 %50, i32* %11
br label %51
51: ; preds = %48, %43
%52 = load i32, i32* %6
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = load i32, i32* %10
%56 = mul nsw i32 %55, -1
store i32 %56, i32* %10
br label %57
57: ; preds = %54, %51
%58 = load i32, i32* %6
%59 = load i32, i32* %8
%60 = sub nsw i32 %59, 18
%61 = icmp eq i32 %58, %60
br i1 %61, label %62, label %65
62: ; preds = %57
%63 = load i32, i32* %10
%64 = mul nsw i32 %63, -1
store i32 %64, i32* %10
br label %65
65: ; preds = %62, %57
%66 = load i32, i32* %12
%67 = icmp eq i32 %66, 6
br i1 %67, label %68, label %69
68: ; preds = %65
store i32 -1, i32* %12
br label %69
69: ; preds = %68, %65
%70 = load i32, i32* %7
%71 = load i32, i32* %11
%72 = add nsw i32 %70, %71
store i32 %72, i32* %7
%73 = load i32, i32* %6
%74 = load i32, i32* %10
%75 = add nsw i32 %73, %74
store i32 %75, i32* %6
%76 = load i32, i32* %12
%77 = add nsw i32 %76, 1
store i32 %77, i32* %12
%78 = load i32, i32* %12
%79 = call i32 @COLOR_PAIR(i32 %78)
%80 = call i32 @attrset(i32 %79)
%81 = load i32, i32* %6
%82 = load i32, i32* %7
%83 = call i32 @draw_point(i32 %81, i32 %82)
%84 = call i32 @usleep(i32 30000)
%85 = call i32 (...) @clear()
br label %33
}

LLVM IR (-O2):
@FALSE = global i64 0
@stdscr = global i32 0
@str = [37 x i8] c"Your terminal does not support color\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @initscr()
%4 = tail call i32 (...) @noecho()
%5 = load i64, i64* @FALSE
%6 = tail call i32 @curs_set(i64 %5)
%7 = tail call i64 (...) @has_colors()
%8 = load i64, i64* @FALSE
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = tail call i32 (...) @endwin()
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = tail call i32 (...) @start_color()
%16 = tail call i32 @init_pair(i32 1, i32 1, i32 0)
%17 = tail call i32 @init_pair(i32 2, i32 2, i32 0)
%18 = tail call i32 @init_pair(i32 3, i32 3, i32 0)
%19 = tail call i32 @init_pair(i32 4, i32 4, i32 0)
%20 = tail call i32 @init_pair(i32 5, i32 5, i32 0)
%21 = tail call i32 @init_pair(i32 6, i32 6, i32 0)
%22 = tail call i32 @init_pair(i32 1, i32 7, i32 0)
br label %23
23: ; preds = %23, %14
%24 = phi i32 [ 25, %14 ], [ %39, %23 ]
%25 = phi i32 [ 5, %14 ], [ %38, %23 ]
%26 = phi i32 [ 1, %14 ], [ %36, %23 ]
%27 = phi i32 [ 1, %14 ], [ %33, %23 ]
%28 = phi i32 [ 0, %14 ], [ %41, %23 ]
%29 = load i32, i32* @stdscr
%30 = tail call i32 @getmaxyx(i32 %29, i32 undef, i32 undef)
%31 = icmp eq i32 %25, 4
%32 = sub nsw i32 0, %27
%33 = select i1 %31, i32 %32, i32 %27
%34 = icmp eq i32 %24, 0
%35 = sub nsw i32 0, %26
%36 = select i1 %34, i32 %35, i32 %26
%37 = icmp eq i32 %28, 6
%38 = add nsw i32 %33, %25
%39 = add nsw i32 %36, %24
%40 = add nsw i32 %28, 1
%41 = select i1 %37, i32 0, i32 %40
%42 = tail call i32 @COLOR_PAIR(i32 %41)
%43 = tail call i32 @attrset(i32 %42)
%44 = tail call i32 @draw_point(i32 %39, i32 %38)
%45 = tail call i32 @usleep(i32 30000)
%46 = tail call i32 (...) @clear()
br label %23
}