#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 */
typedef int /*<<< orphan*/ ushort;
typedef int /*<<< orphan*/ WINDOW;

/* Variables and functions */
int /*<<< orphan*/ A_BOLD;
int /*<<< orphan*/ A_STANDOUT;
int /*<<< orphan*/ COLOR_BLACK;
int /*<<< orphan*/ COLOR_BLUE;
int /*<<< orphan*/ COLOR_CYAN;
int /*<<< orphan*/ COLOR_GREEN;
int /*<<< orphan*/ COLOR_MAGENTA;
int /*<<< orphan*/ COLOR_PAIR(int);
int /*<<< orphan*/ COLOR_RED;
int /*<<< orphan*/ COLOR_WHITE;
int /*<<< orphan*/ COLOR_YELLOW;
#define KEY_DOWN 131
#define KEY_LEFT 130
#define KEY_RIGHT 129
#define KEY_UP 128
int LINES;
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ attron(int /*<<< orphan*/);
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ curs_set(int /*<<< orphan*/);
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ erase();
int getch();
int /*<<< orphan*/ init_pair(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ *initscr();
int /*<<< orphan*/ keypad(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ mvprintw(int, int /*<<< orphan*/, char *, unsigned char);
int /*<<< orphan*/ nodelay(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ printwave(double, double, short, int /*<<< orphan*/);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ usleep(int);
int main(int argc, char *argv[]) {
  WINDOW *screen = initscr();
  start_color();
  nodelay(screen, 1);
  cbreak();
  noecho();
  curs_set(0);
  keypad(screen, TRUE);
  init_pair(1, COLOR_RED, COLOR_BLACK);
  init_pair(2, COLOR_GREEN, COLOR_BLACK);
  init_pair(3, COLOR_YELLOW, COLOR_BLACK);
  init_pair(4, COLOR_BLUE, COLOR_BLACK);
  init_pair(5, COLOR_MAGENTA, COLOR_BLACK);
  init_pair(6, COLOR_CYAN, COLOR_BLACK);
  init_pair(7, COLOR_WHITE, COLOR_BLACK);
  attron(A_BOLD);
  attron(A_STANDOUT);
  unsigned char delayx = 150;
  ushort color_index = 0;
  short phase_shift = 0;
  double amplitude = (LINES / 2) * 1;
  double period = .35;
  while (1) {
    erase();
    color_index = printwave(amplitude, period, phase_shift, color_index);
    attron(COLOR_PAIR(7));
    mvprintw(0, 0, "PERIOD %.2f", period);
    mvprintw(1, 0, "AMP: %.2f", amplitude);
    mvprintw(2, 0, "PHASE: %d", phase_shift);
    mvprintw(3, 0, "DELAY: x%hu", delayx);
    refresh();
    switch (getch()) {
    case KEY_UP:
    case 'k':
      amplitude += 1.0;
      break;
    case KEY_DOWN:
    case 'j':
      amplitude -= 1.0;
      break;
    case KEY_LEFT:
    case 'h':
      period -= .05;
      break;
    case KEY_RIGHT:
    case 'l':
      period += .05;
      break;
    case ' ':
      phase_shift = 0.0;
      break;
    case '+':
      delayx += 1;
      break;
    case '-':
      delayx -= 1;
      break;
    case 'q':
      endwin();
      return 0;
    default:
      break;
    }
    usleep(100 * delayx);
    phase_shift += 1;
    if (phase_shift * period >= LINES)
      phase_shift = 0;
  }
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <initscr@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1080 <start_color@plt>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
call   10b0 <nodelay@plt>
mov    $0x0,%al
call   1030 <cbreak@plt>
mov    $0x0,%al
call   1100 <noecho@plt>
xor    %edi,%edi
call   1110 <curs_set@plt>
mov    -0x18(%rbp),%rdi
mov    0x2d7a(%rip),%rax
mov    (%rax),%esi
call   1050 <keypad@plt>
mov    0x2d14(%rip),%rax
mov    (%rax),%esi
mov    0x2d5b(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%edi
call   1040 <init_pair@plt>
mov    0x2d38(%rip),%rax
mov    (%rax),%esi
mov    0x2d3f(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%edi
call   1040 <init_pair@plt>
mov    0x2cf4(%rip),%rax
mov    (%rax),%esi
mov    0x2d23(%rip),%rax
mov    (%rax),%edx
mov    $0x3,%edi
call   1040 <init_pair@plt>
mov    0x2cd0(%rip),%rax
mov    (%rax),%esi
mov    0x2d07(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%edi
call   1040 <init_pair@plt>
mov    0x2cd4(%rip),%rax
mov    (%rax),%esi
mov    0x2ceb(%rip),%rax
mov    (%rax),%edx
mov    $0x5,%edi
call   1040 <init_pair@plt>
mov    0x2cd0(%rip),%rax
mov    (%rax),%esi
mov    0x2ccf(%rip),%rax
mov    (%rax),%edx
mov    $0x6,%edi
call   1040 <init_pair@plt>
mov    0x2c8c(%rip),%rax
mov    (%rax),%esi
mov    0x2cb3(%rip),%rax
mov    (%rax),%edx
mov    $0x7,%edi
call   1040 <init_pair@plt>
mov    0x2c58(%rip),%rax
mov    (%rax),%edi
call   1090 <attron@plt>
mov    0x2c6a(%rip),%rax
mov    (%rax),%edi
call   1090 <attron@plt>
movb   $0x96,-0x19(%rbp)
movl   $0x0,-0x20(%rbp)
movw   $0x0,-0x22(%rbp)
mov    0x2c83(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
shl    $0x0,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xc7d(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
xor    %eax,%eax
mov    %eax,-0x48(%rbp)
mov    %al,-0x41(%rbp)
call   1070 <erase@plt>
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movswl -0x22(%rbp),%edi
mov    -0x20(%rbp),%esi
call   10f0 <printwave@plt>
mov    %eax,-0x20(%rbp)
mov    $0x7,%edi
call   10a0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1090 <attron@plt>
mov    -0x48(%rbp),%esi
cvttsd2si -0x38(%rbp),%eax
movzbl %al,%ecx
lea    0xdd7(%rip),%rdx
mov    %esi,%edi
call   1120 <mvprintw@plt>
mov    -0x48(%rbp),%esi
cvttsd2si -0x30(%rbp),%eax
movzbl %al,%ecx
lea    0xdca(%rip),%rdx
mov    $0x1,%edi
call   1120 <mvprintw@plt>
mov    -0x48(%rbp),%esi
movzbl -0x22(%rbp),%ecx
lea    0xdbc(%rip),%rdx
mov    $0x2,%edi
call   1120 <mvprintw@plt>
mov    -0x48(%rbp),%esi
movzbl -0x19(%rbp),%ecx
lea    0xdae(%rip),%rdx
mov    $0x3,%edi
call   1120 <mvprintw@plt>
mov    -0x41(%rbp),%al
call   10c0 <refresh@plt>
mov    -0x41(%rbp),%al
call   10d0 <getch@plt>
add    $0xffffffe0,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x63,%eax
ja     14f6 <main+0x2e6>
mov    -0x40(%rbp),%rax
lea    0xbc7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0xbae(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    14fb <main+0x2eb>
movsd  -0x30(%rbp),%xmm0
movsd  0xb92(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    14fb <main+0x2eb>
movsd  -0x38(%rbp),%xmm0
movsd  0xb6f(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    14fb <main+0x2eb>
movsd  0xb59(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    14fb <main+0x2eb>
movw   $0x0,-0x22(%rbp)
jmp    14fb <main+0x2eb>
movzbl -0x19(%rbp),%eax
add    $0x1,%eax
mov    %al,-0x19(%rbp)
jmp    14fb <main+0x2eb>
movzbl -0x19(%rbp),%eax
sub    $0x1,%eax
mov    %al,-0x19(%rbp)
jmp    14fb <main+0x2eb>
mov    $0x0,%al
call   10e0 <endwin@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret
jmp    14fb <main+0x2eb>
movzbl -0x19(%rbp),%eax
imul   $0x64,%eax,%edi
call   1130 <usleep@plt>
movswl -0x22(%rbp),%eax
add    $0x1,%eax
mov    %ax,-0x22(%rbp)
movswl -0x22(%rbp),%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x38(%rbp),%xmm0
mov    0x2ac2(%rip),%rax
cvtsi2sdl (%rax),%xmm1
ucomisd %xmm1,%xmm0
jb     153a <main+0x32a>
movw   $0x0,-0x22(%rbp)
jmp    1388 <main+0x178>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   1060 <initscr@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1080 <start_color@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   10b0 <nodelay@plt>
xor    %eax,%eax
call   1030 <cbreak@plt>
xor    %eax,%eax
call   1100 <noecho@plt>
xor    %edi,%edi
call   1110 <curs_set@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1050 <keypad@plt>
mov    0x2d1f(%rip),%rax
mov    (%rax),%esi
mov    0x2d66(%rip),%rbx
mov    (%rbx),%edx
mov    $0x1,%edi
call   1040 <init_pair@plt>
mov    0x2d43(%rip),%rax
mov    (%rax),%esi
mov    (%rbx),%edx
mov    $0x2,%edi
call   1040 <init_pair@plt>
mov    0x2d06(%rip),%rax
mov    (%rax),%esi
mov    (%rbx),%edx
mov    $0x3,%edi
call   1040 <init_pair@plt>
mov    0x2ce9(%rip),%rax
mov    (%rax),%esi
mov    (%rbx),%edx
mov    $0x4,%edi
call   1040 <init_pair@plt>
mov    0x2cf4(%rip),%rax
mov    (%rax),%esi
mov    (%rbx),%edx
mov    $0x5,%edi
call   1040 <init_pair@plt>
mov    0x2cf7(%rip),%rax
mov    (%rax),%esi
mov    (%rbx),%edx
mov    $0x6,%edi
call   1040 <init_pair@plt>
mov    0x2cba(%rip),%rax
mov    (%rax),%esi
mov    (%rbx),%edx
mov    $0x7,%edi
call   1040 <init_pair@plt>
mov    0x2c8d(%rip),%rax
mov    (%rax),%edi
call   1090 <attron@plt>
mov    0x2c9f(%rip),%rax
mov    (%rax),%edi
call   1090 <attron@plt>
mov    0x2cc9(%rip),%rax
mov    (%rax),%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
cvtsi2sd %ecx,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xcc4(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0x96,%r14b
lea    0xe8c(%rip),%r13
lea    0xcd5(%rip),%r15
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    13aa <main+0x19a>
movsd  0x10(%rsp),%xmm0
addsd  0xcb8(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movzbl %r14b,%eax
imul   $0x64,%eax,%edi
call   1130 <usleep@plt>
add    $0x1,%r12d
movswl %r12w,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
mov    0x2c52(%rip),%rax
xorps  %xmm1,%xmm1
cvtsi2sdl (%rax),%xmm1
ucomisd %xmm1,%xmm0
mov    $0x0,%eax
cmovae %eax,%r12d
xor    %eax,%eax
call   1070 <erase@plt>
movswl %r12w,%ebx
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %ebx,%edi
mov    %ebp,%esi
call   10f0 <printwave@plt>
mov    %eax,%ebp
mov    $0x7,%edi
call   10a0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1090 <attron@plt>
cvttsd2si 0x8(%rsp),%eax
movzbl %al,%ecx
xor    %edi,%edi
xor    %esi,%esi
lea    0xdc7(%rip),%rdx
call   1120 <mvprintw@plt>
cvttsd2si 0x10(%rsp),%eax
movzbl %al,%ecx
mov    $0x1,%edi
xor    %esi,%esi
lea    0xdb7(%rip),%rdx
call   1120 <mvprintw@plt>
movzbl %bl,%ecx
mov    $0x2,%edi
xor    %esi,%esi
lea    0xdab(%rip),%rdx
call   1120 <mvprintw@plt>
movzbl %r14b,%ecx
mov    $0x3,%edi
xor    %esi,%esi
mov    %r13,%rdx
call   1120 <mvprintw@plt>
xor    %eax,%eax
call   10c0 <refresh@plt>
xor    %eax,%eax
call   10d0 <getch@plt>
add    $0xffffffe0,%eax
cmp    $0x63,%eax
ja     136e <main+0x15e>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
movsd  0x8(%rsp),%xmm0
addsd  0xba4(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
jmp    136e <main+0x15e>
movsd  0x10(%rsp),%xmm0
addsd  0xb93(%rip),%xmm0
jmp    1368 <main+0x158>
movsd  0x8(%rsp),%xmm0
addsd  0xb70(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
jmp    136e <main+0x15e>
xor    %r12d,%r12d
jmp    136e <main+0x15e>
add    $0x1,%r14b
jmp    136e <main+0x15e>
add    $0xff,%r14b
jmp    136e <main+0x15e>
xor    %eax,%eax
call   10e0 <endwin@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@TRUE = global i32 0
@COLOR_RED = global i32 0
@COLOR_BLACK = global i32 0
@COLOR_GREEN = global i32 0
@COLOR_YELLOW = global i32 0
@COLOR_BLUE = global i32 0
@COLOR_MAGENTA = global i32 0
@COLOR_CYAN = global i32 0
@COLOR_WHITE = global i32 0
@A_BOLD = global i32 0
@A_STANDOUT = global i32 0
@LINES = global i32 0
@.str = [12 x i8] c"PERIOD %.2f\00"
@.str.1 = [10 x i8] c"AMP: %.2f\00"
@.str.2 = [10 x i8] c"PHASE: %d\00"
@.str.3 = [12 x i8] c"DELAY: x%hu\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8
%8 = alloca i32
%9 = alloca i16
%10 = alloca double
%11 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32* (...) @initscr()
store i32* %12, i32** %6
%13 = call i32 (...) @start_color()
%14 = load i32*, i32** %6
%15 = call i32 @nodelay(i32* %14, i32 1)
%16 = call i32 (...) @cbreak()
%17 = call i32 (...) @noecho()
%18 = call i32 @curs_set(i32 0)
%19 = load i32*, i32** %6
%20 = load i32, i32* @TRUE
%21 = call i32 @keypad(i32* %19, i32 %20)
%22 = load i32, i32* @COLOR_RED
%23 = load i32, i32* @COLOR_BLACK
%24 = call i32 @init_pair(i32 1, i32 %22, i32 %23)
%25 = load i32, i32* @COLOR_GREEN
%26 = load i32, i32* @COLOR_BLACK
%27 = call i32 @init_pair(i32 2, i32 %25, i32 %26)
%28 = load i32, i32* @COLOR_YELLOW
%29 = load i32, i32* @COLOR_BLACK
%30 = call i32 @init_pair(i32 3, i32 %28, i32 %29)
%31 = load i32, i32* @COLOR_BLUE
%32 = load i32, i32* @COLOR_BLACK
%33 = call i32 @init_pair(i32 4, i32 %31, i32 %32)
%34 = load i32, i32* @COLOR_MAGENTA
%35 = load i32, i32* @COLOR_BLACK
%36 = call i32 @init_pair(i32 5, i32 %34, i32 %35)
%37 = load i32, i32* @COLOR_CYAN
%38 = load i32, i32* @COLOR_BLACK
%39 = call i32 @init_pair(i32 6, i32 %37, i32 %38)
%40 = load i32, i32* @COLOR_WHITE
%41 = load i32, i32* @COLOR_BLACK
%42 = call i32 @init_pair(i32 7, i32 %40, i32 %41)
%43 = load i32, i32* @A_BOLD
%44 = call i32 @attron(i32 %43)
%45 = load i32, i32* @A_STANDOUT
%46 = call i32 @attron(i32 %45)
store i8 -106, i8* %7
store i32 0, i32* %8
store i16 0, i16* %9
%47 = load i32, i32* @LINES
%48 = sdiv i32 %47, 2
%49 = mul nsw i32 %48, 1
%50 = sitofp i32 %49 to double
store double %50, double* %10
store double 3.500000e-01, double* %11
br label %51
51: ; preds = %2, %117
%52 = call i32 (...) @erase()
%53 = load double, double* %10
%54 = load double, double* %11
%55 = load i16, i16* %9
%56 = load i32, i32* %8
%57 = call i32 @printwave(double %53, double %54, i16 signext %55, i32 %56)
store i32 %57, i32* %8
%58 = call i32 @COLOR_PAIR(i32 7)
%59 = call i32 @attron(i32 %58)
%60 = load double, double* %11
%61 = fptoui double %60 to i8
%62 = call i32 @mvprintw(i32 0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 zeroext %61)
%63 = load double, double* %10
%64 = fptoui double %63 to i8
%65 = call i32 @mvprintw(i32 1, i32 0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %64)
%66 = load i16, i16* %9
%67 = trunc i16 %66 to i8
%68 = call i32 @mvprintw(i32 2, i32 0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %67)
%69 = load i8, i8* %7
%70 = call i32 @mvprintw(i32 3, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8 zeroext %69)
%71 = call i32 (...) @refresh()
%72 = call i32 (...) @getch()
switch i32 %72, label %98 [
i32 128, label %73
i32 107, label %73
i32 131, label %76
i32 106, label %76
i32 130, label %79
i32 104, label %79
i32 129, label %82
i32 108, label %82
i32 32, label %85
i32 43, label %86
i32 45, label %91
i32 113, label %96
]
73: ; preds = %51, %51
%74 = load double, double* %10
%75 = fadd double %74, 1.000000e+00
store double %75, double* %10
br label %99
76: ; preds = %51, %51
%77 = load double, double* %10
%78 = fsub double %77, 1.000000e+00
store double %78, double* %10
br label %99
79: ; preds = %51, %51
%80 = load double, double* %11
%81 = fsub double %80, 5.000000e-02
store double %81, double* %11
br label %99
82: ; preds = %51, %51
%83 = load double, double* %11
%84 = fadd double %83, 5.000000e-02
store double %84, double* %11
br label %99
85: ; preds = %51
store i16 0, i16* %9
br label %99
86: ; preds = %51
%87 = load i8, i8* %7
%88 = zext i8 %87 to i32
%89 = add nsw i32 %88, 1
%90 = trunc i32 %89 to i8
store i8 %90, i8* %7
br label %99
91: ; preds = %51
%92 = load i8, i8* %7
%93 = zext i8 %92 to i32
%94 = sub nsw i32 %93, 1
%95 = trunc i32 %94 to i8
store i8 %95, i8* %7
br label %99
96: ; preds = %51
%97 = call i32 (...) @endwin()
ret i32 0
98: ; preds = %51
br label %99
99: ; preds = %98, %91, %86, %85, %82, %79, %76, %73
%100 = load i8, i8* %7
%101 = zext i8 %100 to i32
%102 = mul nsw i32 100, %101
%103 = call i32 @usleep(i32 %102)
%104 = load i16, i16* %9
%105 = sext i16 %104 to i32
%106 = add nsw i32 %105, 1
%107 = trunc i32 %106 to i16
store i16 %107, i16* %9
%108 = load i16, i16* %9
%109 = sext i16 %108 to i32
%110 = sitofp i32 %109 to double
%111 = load double, double* %11
%112 = fmul double %110, %111
%113 = load i32, i32* @LINES
%114 = sitofp i32 %113 to double
%115 = fcmp oge double %112, %114
br i1 %115, label %116, label %117
116: ; preds = %99
store i16 0, i16* %9
br label %117
117: ; preds = %116, %99
br label %51
}

LLVM IR (-O2):
@TRUE = global i32 0
@COLOR_RED = global i32 0
@COLOR_BLACK = global i32 0
@COLOR_GREEN = global i32 0
@COLOR_YELLOW = global i32 0
@COLOR_BLUE = global i32 0
@COLOR_MAGENTA = global i32 0
@COLOR_CYAN = global i32 0
@COLOR_WHITE = global i32 0
@A_BOLD = global i32 0
@A_STANDOUT = global i32 0
@LINES = global i32 0
@.str = [12 x i8] c"PERIOD %.2f\00"
@.str.1 = [10 x i8] c"AMP: %.2f\00"
@.str.2 = [10 x i8] c"PHASE: %d\00"
@.str.3 = [12 x i8] c"DELAY: x%hu\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* (...) @initscr()
%4 = tail call i32 (...) @start_color()
%5 = tail call i32 @nodelay(i32* %3, i32 1)
%6 = tail call i32 (...) @cbreak()
%7 = tail call i32 (...) @noecho()
%8 = tail call i32 @curs_set(i32 0)
%9 = load i32, i32* @TRUE
%10 = tail call i32 @keypad(i32* %3, i32 %9)
%11 = load i32, i32* @COLOR_RED
%12 = load i32, i32* @COLOR_BLACK
%13 = tail call i32 @init_pair(i32 1, i32 %11, i32 %12)
%14 = load i32, i32* @COLOR_GREEN
%15 = load i32, i32* @COLOR_BLACK
%16 = tail call i32 @init_pair(i32 2, i32 %14, i32 %15)
%17 = load i32, i32* @COLOR_YELLOW
%18 = load i32, i32* @COLOR_BLACK
%19 = tail call i32 @init_pair(i32 3, i32 %17, i32 %18)
%20 = load i32, i32* @COLOR_BLUE
%21 = load i32, i32* @COLOR_BLACK
%22 = tail call i32 @init_pair(i32 4, i32 %20, i32 %21)
%23 = load i32, i32* @COLOR_MAGENTA
%24 = load i32, i32* @COLOR_BLACK
%25 = tail call i32 @init_pair(i32 5, i32 %23, i32 %24)
%26 = load i32, i32* @COLOR_CYAN
%27 = load i32, i32* @COLOR_BLACK
%28 = tail call i32 @init_pair(i32 6, i32 %26, i32 %27)
%29 = load i32, i32* @COLOR_WHITE
%30 = load i32, i32* @COLOR_BLACK
%31 = tail call i32 @init_pair(i32 7, i32 %29, i32 %30)
%32 = load i32, i32* @A_BOLD
%33 = tail call i32 @attron(i32 %32)
%34 = load i32, i32* @A_STANDOUT
%35 = tail call i32 @attron(i32 %34)
%36 = load i32, i32* @LINES
%37 = sdiv i32 %36, 2
%38 = sitofp i32 %37 to double
br label %39
39: ; preds = %73, %2
%40 = phi i8 [ -106, %2 ], [ %74, %73 ]
%41 = phi i32 [ 0, %2 ], [ %46, %73 ]
%42 = phi i16 [ 0, %2 ], [ %87, %73 ]
%43 = phi double [ %38, %2 ], [ %76, %73 ]
%44 = phi double [ 3.500000e-01, %2 ], [ %77, %73 ]
%45 = tail call i32 (...) @erase()
%46 = tail call i32 @printwave(double %43, double %44, i16 signext %42, i32 %41)
%47 = tail call i32 @COLOR_PAIR(i32 7)
%48 = tail call i32 @attron(i32 %47)
%49 = fptoui double %44 to i8
%50 = tail call i32 @mvprintw(i32 0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 zeroext %49)
%51 = fptoui double %43 to i8
%52 = tail call i32 @mvprintw(i32 1, i32 0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %51)
%53 = trunc i16 %42 to i8
%54 = tail call i32 @mvprintw(i32 2, i32 0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %53)
%55 = tail call i32 @mvprintw(i32 3, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8 zeroext %40)
%56 = tail call i32 (...) @refresh()
%57 = tail call i32 (...) @getch()
switch i32 %57, label %73 [
i32 128, label %58
i32 107, label %58
i32 131, label %60
i32 106, label %60
i32 130, label %62
i32 104, label %62
i32 129, label %64
i32 108, label %64
i32 32, label %66
i32 43, label %67
i32 45, label %69
i32 113, label %71
]
58: ; preds = %39, %39
%59 = fadd double %43, 1.000000e+00
br label %73
60: ; preds = %39, %39
%61 = fadd double %43, -1.000000e+00
br label %73
62: ; preds = %39, %39
%63 = fadd double %44, -5.000000e-02
br label %73
64: ; preds = %39, %39
%65 = fadd double %44, 5.000000e-02
br label %73
66: ; preds = %39
br label %73
67: ; preds = %39
%68 = add i8 %40, 1
br label %73
69: ; preds = %39
%70 = add i8 %40, -1
br label %73
71: ; preds = %39
%72 = tail call i32 (...) @endwin()
ret i32 0
73: ; preds = %39, %69, %67, %66, %64, %62, %60, %58
%74 = phi i8 [ %40, %39 ], [ %70, %69 ], [ %68, %67 ], [ %40, %66 ], [ %40, %64 ], [ %40, %62 ], [ %40, %60 ], [ %40, %58 ]
%75 = phi i16 [ %42, %39 ], [ %42, %69 ], [ %42, %67 ], [ 0, %66 ], [ %42, %64 ], [ %42, %62 ], [ %42, %60 ], [ %42, %58 ]
%76 = phi double [ %43, %39 ], [ %43, %69 ], [ %43, %67 ], [ %43, %66 ], [ %43, %64 ], [ %43, %62 ], [ %61, %60 ], [ %59, %58 ]
%77 = phi double [ %44, %39 ], [ %44, %69 ], [ %44, %67 ], [ %44, %66 ], [ %65, %64 ], [ %63, %62 ], [ %44, %60 ], [ %44, %58 ]
%78 = zext i8 %74 to i32
%79 = mul nuw nsw i32 %78, 100
%80 = tail call i32 @usleep(i32 %79)
%81 = add i16 %75, 1
%82 = sitofp i16 %81 to double
%83 = fmul double %77, %82
%84 = load i32, i32* @LINES
%85 = sitofp i32 %84 to double
%86 = fcmp ult double %83, %85
%87 = select i1 %86, i16 %81, i16 0
br label %39
}