#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*/ printf(char *, ...);
float sin(float);
int main(int argc, char **argv) {
  float frequencyr = 0.3, frequencyg = 0.3, frequencyb = 0.3;
  float basePhase = 0;
  float phase1 = basePhase + 0, phase2 = basePhase + 1, phase3 = basePhase + 2;
  float center = 0x7;
  float width = 0x7;
  int startLine = 0x2c;
  int screenHeight = 256;
  int endLine = startLine + screenHeight;
  int startHpos = 6;
  int i, line;
  for (i = 0, line = startLine; line < endLine; ++i, ++line) {
    unsigned char r = (sin(frequencyr * i + phase1) * width + center) + 0.5;
    unsigned char g = (sin(frequencyg * i + phase2) * width + center) + 0.5;
    unsigned char b = (sin(frequencyb * i + phase3) * width + center) + 0.5;
    if (line <= 255) {
      printf("\tdc.w $%x,$fffe\n\tdc.w COLOR00,$%x%x%x\n",
             line << 8 | startHpos | 1, r, g, b);
      if (line == 255) {
        printf(".verticalPositionWrapped:\n");
        printf("\tdc.w $%xdf,$fffe\n", line);
      }
    } else {
      printf("\tdc.w $%x,$fffe\n\tdc.w COLOR00,$%x%x%x\n",
             (line - 256) << 8 | startHpos | 1, r, g, b);
    }
  }
  printf("\tdc.w $%x,$fffe\n\tdc.w COLOR00,$%x%x%x\n",
         (line - 256) << 8 | startHpos | 1, 0, 0, 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movss  0xece(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xec1(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xeb4(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  0xe8e(%rip),%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  0xe78(%rip),%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  0xe62(%rip),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  0xe55(%rip),%xmm0
movss  %xmm0,-0x34(%rbp)
movl   $0x2c,-0x38(%rbp)
movl   $0x100,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x40(%rbp)
movl   $0x6,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x40(%rbp),%eax
jge    1363 <main+0x243>
movss  -0x14(%rbp),%xmm0
cvtsi2ssl -0x48(%rbp),%xmm2
movss  -0x24(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1040 <sin@plt>
movss  -0x34(%rbp),%xmm2
movss  -0x30(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdef(%rip),%xmm1
movsd  %xmm1,-0x58(%rbp)
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %al,-0x4d(%rbp)
movss  -0x18(%rbp),%xmm0
cvtsi2ssl -0x48(%rbp),%xmm2
movss  -0x28(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1040 <sin@plt>
movsd  -0x58(%rbp),%xmm1
movss  -0x34(%rbp),%xmm3
movss  -0x30(%rbp),%xmm2
mulss  %xmm3,%xmm0
addss  %xmm2,%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %al,-0x4e(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtsi2ssl -0x48(%rbp),%xmm2
movss  -0x2c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1040 <sin@plt>
movsd  -0x58(%rbp),%xmm1
movss  -0x34(%rbp),%xmm3
movss  -0x30(%rbp),%xmm2
mulss  %xmm3,%xmm0
addss  %xmm2,%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %al,-0x4f(%rbp)
cmpl   $0xff,-0x4c(%rbp)
jg     131a <main+0x1fa>
mov    -0x4c(%rbp),%esi
shl    $0x8,%esi
or     -0x44(%rbp),%esi
or     $0x1,%esi
movzbl -0x4d(%rbp),%edx
movzbl -0x4e(%rbp),%ecx
movzbl -0x4f(%rbp),%r8d
lea    0xd36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0xff,-0x4c(%rbp)
jne    1315 <main+0x1f5>
lea    0xd42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4c(%rbp),%esi
lea    0xd4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1347 <main+0x227>
mov    -0x4c(%rbp),%esi
sub    $0x100,%esi
shl    $0x8,%esi
or     -0x44(%rbp),%esi
or     $0x1,%esi
movzbl -0x4d(%rbp),%edx
movzbl -0x4e(%rbp),%ecx
movzbl -0x4f(%rbp),%r8d
lea    0xcd8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    134c <main+0x22c>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11db <main+0xbb>
mov    -0x4c(%rbp),%esi
sub    $0x100,%esi
shl    $0x8,%esi
or     -0x44(%rbp),%esi
or     $0x1,%esi
lea    0xc9c(%rip),%rdi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x2c07,%r13d
lea    0xed8(%rip),%r14
xor    %ebx,%ebx
jmp    1183 <main+0x53>
nopl   0x0(%rax)
lea    -0x10000(%r13),%esi
movzbl %r15b,%edx
movzbl %r12b,%ecx
movzbl %al,%r8d
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
add    $0x100,%r13d
cmp    $0x100,%ebx
je     1289 <main+0x159>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
lea    0x2c(%rbx),%ebp
mulss  0xe6b(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
addss  0xe6d(%rip),%xmm0
call   1050 <sin@plt>
movss  0xe54(%rip),%xmm1
mulss  %xmm1,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe54(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%r15d
movss  0x4(%rsp),%xmm0
addss  0xe2d(%rip),%xmm0
call   1050 <sin@plt>
movss  0xe1c(%rip),%xmm1
mulss  %xmm1,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0xe1c(%rip),%xmm0
cvttsd2si %xmm0,%r12d
movss  0x4(%rsp),%xmm0
addss  0xdfd(%rip),%xmm0
call   1050 <sin@plt>
movss  0xde8(%rip),%xmm1
mulss  %xmm1,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0xde8(%rip),%xmm0
cvttsd2si %xmm0,%eax
cmp    $0xff,%ebp
ja     1150 <main+0x20>
movzbl %r15b,%edx
movzbl %r12b,%ecx
movzbl %al,%r8d
mov    %r14,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xd3,%ebx
jne    116d <main+0x3d>
lea    0xdee(%rip),%rdi
call   1030 <puts@plt>
lea    0xdcf(%rip),%rdi
mov    $0xff,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    116d <main+0x3d>
lea    0xd90(%rip),%rdi
mov    $0x2c07,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"\09dc.w $%x,$fffe\0A\09dc.w COLOR00,$%x%x%x\0A\00"
@.str.1 = [27 x i8] c".verticalPositionWrapped:\0A\00"
@.str.2 = [19 x i8] c"\09dc.w $%xdf,$fffe\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i8
%22 = alloca i8
%23 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store float 0x3FD3333340000000, float* %6
store float 0x3FD3333340000000, float* %7
store float 0x3FD3333340000000, float* %8
store float 0.000000e+00, float* %9
%24 = load float, float* %9
%25 = fadd float %24, 0.000000e+00
store float %25, float* %10
%26 = load float, float* %9
%27 = fadd float %26, 1.000000e+00
store float %27, float* %11
%28 = load float, float* %9
%29 = fadd float %28, 2.000000e+00
store float %29, float* %12
store float 7.000000e+00, float* %13
store float 7.000000e+00, float* %14
store i32 44, i32* %15
store i32 256, i32* %16
%30 = load i32, i32* %15
%31 = load i32, i32* %16
%32 = add nsw i32 %30, %31
store i32 %32, i32* %17
store i32 6, i32* %18
store i32 0, i32* %19
%33 = load i32, i32* %15
store i32 %33, i32* %20
br label %34
34: ; preds = %112, %2
%35 = load i32, i32* %20
%36 = load i32, i32* %17
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %117
38: ; preds = %34
%39 = load float, float* %6
%40 = load i32, i32* %19
%41 = sitofp i32 %40 to float
%42 = load float, float* %10
%43 = call float @llvm.fmuladd.f32(float %39, float %41, float %42)
%44 = call float @sin(float %43)
%45 = load float, float* %14
%46 = load float, float* %13
%47 = call float @llvm.fmuladd.f32(float %44, float %45, float %46)
%48 = fpext float %47 to double
%49 = fadd double %48, 5.000000e-01
%50 = fptoui double %49 to i8
store i8 %50, i8* %21
%51 = load float, float* %7
%52 = load i32, i32* %19
%53 = sitofp i32 %52 to float
%54 = load float, float* %11
%55 = call float @llvm.fmuladd.f32(float %51, float %53, float %54)
%56 = call float @sin(float %55)
%57 = load float, float* %14
%58 = load float, float* %13
%59 = call float @llvm.fmuladd.f32(float %56, float %57, float %58)
%60 = fpext float %59 to double
%61 = fadd double %60, 5.000000e-01
%62 = fptoui double %61 to i8
store i8 %62, i8* %22
%63 = load float, float* %8
%64 = load i32, i32* %19
%65 = sitofp i32 %64 to float
%66 = load float, float* %12
%67 = call float @llvm.fmuladd.f32(float %63, float %65, float %66)
%68 = call float @sin(float %67)
%69 = load float, float* %14
%70 = load float, float* %13
%71 = call float @llvm.fmuladd.f32(float %68, float %69, float %70)
%72 = fpext float %71 to double
%73 = fadd double %72, 5.000000e-01
%74 = fptoui double %73 to i8
store i8 %74, i8* %23
%75 = load i32, i32* %20
%76 = icmp sle i32 %75, 255
br i1 %76, label %77, label %97
77: ; preds = %38
%78 = load i32, i32* %20
%79 = shl i32 %78, 8
%80 = load i32, i32* %18
%81 = or i32 %79, %80
%82 = or i32 %81, 1
%83 = load i8, i8* %21
%84 = zext i8 %83 to i32
%85 = load i8, i8* %22
%86 = zext i8 %85 to i32
%87 = load i8, i8* %23
%88 = zext i8 %87 to i32
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %82, i32 %84, i32 %86, i32 %88)
%90 = load i32, i32* %20
%91 = icmp eq i32 %90, 255
br i1 %91, label %92, label %96
92: ; preds = %77
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%94 = load i32, i32* %20
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %94)
br label %96
96: ; preds = %92, %77
br label %111
97: ; preds = %38
%98 = load i32, i32* %20
%99 = sub nsw i32 %98, 256
%100 = shl i32 %99, 8
%101 = load i32, i32* %18
%102 = or i32 %100, %101
%103 = or i32 %102, 1
%104 = load i8, i8* %21
%105 = zext i8 %104 to i32
%106 = load i8, i8* %22
%107 = zext i8 %106 to i32
%108 = load i8, i8* %23
%109 = zext i8 %108 to i32
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %103, i32 %105, i32 %107, i32 %109)
br label %111
111: ; preds = %97, %96
br label %112
112: ; preds = %111
%113 = load i32, i32* %19
%114 = add nsw i32 %113, 1
store i32 %114, i32* %19
%115 = load i32, i32* %20
%116 = add nsw i32 %115, 1
store i32 %116, i32* %20
br label %34
117: ; preds = %34
%118 = load i32, i32* %20
%119 = sub nsw i32 %118, 256
%120 = shl i32 %119, 8
%121 = load i32, i32* %18
%122 = or i32 %120, %121
%123 = or i32 %122, 1
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %123, i32 0, i32 0, i32 0)
ret i32 0
}

LLVM IR (-O2):
@.str = [39 x i8] c"\09dc.w $%x,$fffe\0A\09dc.w COLOR00,$%x%x%x\0A\00"
@.str.2 = [19 x i8] c"\09dc.w $%xdf,$fffe\0A\00"
@str = [26 x i8] c".verticalPositionWrapped:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %43
%4 = phi i32 [ 0, %2 ], [ %44, %43 ]
%5 = phi i32 [ 44, %2 ], [ %45, %43 ]
%6 = sitofp i32 %4 to float
%7 = tail call float @llvm.fmuladd.f32(float %6, float 0x3FD3333340000000, float 0.000000e+00)
%8 = tail call float @sin(float %7)
%9 = tail call float @llvm.fmuladd.f32(float %8, float 7.000000e+00, float 7.000000e+00)
%10 = fpext float %9 to double
%11 = fadd double %10, 5.000000e-01
%12 = fptoui double %11 to i8
%13 = tail call float @llvm.fmuladd.f32(float %6, float 0x3FD3333340000000, float 1.000000e+00)
%14 = tail call float @sin(float %13)
%15 = tail call float @llvm.fmuladd.f32(float %14, float 7.000000e+00, float 7.000000e+00)
%16 = fpext float %15 to double
%17 = fadd double %16, 5.000000e-01
%18 = fptoui double %17 to i8
%19 = tail call float @llvm.fmuladd.f32(float %6, float 0x3FD3333340000000, float 2.000000e+00)
%20 = tail call float @sin(float %19)
%21 = tail call float @llvm.fmuladd.f32(float %20, float 7.000000e+00, float 7.000000e+00)
%22 = fpext float %21 to double
%23 = fadd double %22, 5.000000e-01
%24 = fptoui double %23 to i8
%25 = icmp ult i32 %5, 256
%26 = shl nuw nsw i32 %5, 8
br i1 %25, label %27, label %37
27: ; preds = %3
%28 = or i32 %26, 7
%29 = zext i8 %12 to i32
%30 = zext i8 %18 to i32
%31 = zext i8 %24 to i32
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %28, i32 %29, i32 %30, i32 %31)
%33 = icmp eq i32 %5, 255
br i1 %33, label %34, label %43
34: ; preds = %27
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 255)
br label %43
37: ; preds = %3
%38 = add nsw i32 %26, -65529
%39 = zext i8 %12 to i32
%40 = zext i8 %18 to i32
%41 = zext i8 %24 to i32
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %38, i32 %39, i32 %40, i32 %41)
br label %43
43: ; preds = %27, %34, %37
%44 = add nuw nsw i32 %4, 1
%45 = add nuw nsw i32 %5, 1
%46 = icmp eq i32 %44, 256
br i1 %46, label %47, label %3
47: ; preds = %43
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 11271, i32 0, i32 0, i32 0)
ret i32 0
}