#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) {
  int startLine = 0x2c;
  int screenHeight = 256;
  int endLine = startLine + screenHeight;
  int startHpos = 6 + 8;
  int i, c, line;
  float frequencyr = 0.3, frequencyg = 0.3, frequencyb = 0.3;
  float phase1 = 0, phase2 = 2, phase3 = 4;
  float offset = 0;
  float center = 0x7;
  float width = 0x7;
  int hstep = 16;
  for (line = startLine; line < endLine; ++line) {
    for (i = 0, c = startHpos; c < 0xdf; c += hstep, i++) {
      unsigned char r =
          (sin(frequencyr * i + phase1 + offset) * width + center) + 0.5;
      unsigned char g =
          (sin(frequencyg * i + phase2 + offset) * width + center) + 0.5;
      unsigned char b =
          (sin(frequencyb * i + phase3 + offset) * width + center) + 0.5;
      if (line == 0 && i == 0) {
      } else {
        if (line <= 255) {
          printf("\tdc.w $%x,$fffe\n\tdc.w COLOR00,$%x%x%x\n",
                 line << 8 | c | 1, r, g, b);
          if (line == 255 && c + hstep >= 0xdf) {
            printf(".verticalPositionWrapped:\n");
          }
        } else {
          printf("\tdc.w $%x,$fffe\n\tdc.w COLOR00,$%x%x%x\n",
                 (line - 256) << 8 | c | 1, r, g, b);
        }
      }
    }
  }
  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)
movl   $0x2c,-0x14(%rbp)
movl   $0x100,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0xe,-0x20(%rbp)
movss  0xeb0(%rip),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  0xea3(%rip),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  0xe96(%rip),%xmm0
movss  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  0xe7d(%rip),%xmm0
movss  %xmm0,-0x40(%rbp)
movss  0xe6c(%rip),%xmm0
movss  %xmm0,-0x44(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x48(%rbp)
movss  0xe53(%rip),%xmm0
movss  %xmm0,-0x4c(%rbp)
movss  0xe46(%rip),%xmm0
movss  %xmm0,-0x50(%rbp)
movl   $0x10,-0x54(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    13ba <main+0x29a>
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0xdf,-0x28(%rbp)
jge    13a7 <main+0x287>
movss  -0x30(%rbp),%xmm0
cvtsi2ssl -0x24(%rbp),%xmm2
movss  -0x3c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x48(%rbp),%xmm1
addss  %xmm1,%xmm0
call   1040 <sin@plt>
movss  -0x50(%rbp),%xmm2
movss  -0x4c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xddb(%rip),%xmm1
movsd  %xmm1,-0x60(%rbp)
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %al,-0x55(%rbp)
movss  -0x34(%rbp),%xmm0
cvtsi2ssl -0x24(%rbp),%xmm2
movss  -0x40(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x48(%rbp),%xmm1
addss  %xmm1,%xmm0
call   1040 <sin@plt>
movsd  -0x60(%rbp),%xmm1
movss  -0x50(%rbp),%xmm3
movss  -0x4c(%rbp),%xmm2
mulss  %xmm3,%xmm0
addss  %xmm2,%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %al,-0x56(%rbp)
movss  -0x38(%rbp),%xmm0
cvtsi2ssl -0x24(%rbp),%xmm2
movss  -0x44(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x48(%rbp),%xmm1
addss  %xmm1,%xmm0
call   1040 <sin@plt>
movsd  -0x60(%rbp),%xmm1
movss  -0x50(%rbp),%xmm3
movss  -0x4c(%rbp),%xmm2
mulss  %xmm3,%xmm0
addss  %xmm2,%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %al,-0x57(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    12f4 <main+0x1d4>
cmpl   $0x0,-0x24(%rbp)
jne    12f4 <main+0x1d4>
jmp    138b <main+0x26b>
cmpl   $0xff,-0x2c(%rbp)
jg     1359 <main+0x239>
mov    -0x2c(%rbp),%esi
shl    $0x8,%esi
or     -0x28(%rbp),%esi
or     $0x1,%esi
movzbl -0x55(%rbp),%edx
movzbl -0x56(%rbp),%ecx
movzbl -0x57(%rbp),%r8d
lea    0xcf7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0xff,-0x2c(%rbp)
jne    1354 <main+0x234>
mov    -0x28(%rbp),%eax
add    -0x54(%rbp),%eax
cmp    $0xdf,%eax
jl     1354 <main+0x234>
lea    0xcf2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1386 <main+0x266>
mov    -0x2c(%rbp),%esi
sub    $0x100,%esi
shl    $0x8,%esi
or     -0x28(%rbp),%esi
or     $0x1,%esi
movzbl -0x55(%rbp),%edx
movzbl -0x56(%rbp),%ecx
movzbl -0x57(%rbp),%r8d
lea    0xc99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    138b <main+0x26b>
jmp    1390 <main+0x270>
mov    -0x54(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11e5 <main+0xc5>
jmp    13ac <main+0x28c>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11cc <main+0xac>
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
sub    $0x18,%rsp
mov    $0x2c,%ebp
lea    0xed6(%rip),%r15
jmp    115f <main+0x2f>
nopl   0x0(%rax)
add    $0x1,%ebp
cmp    $0x12c,%ebp
je     12b8 <main+0x188>
mov    %ebp,%r13d
shl    $0x8,%r13d
lea    -0x10000(%r13),%r12d
mov    $0xe,%ebx
xor    %r14d,%r14d
jmp    11a7 <main+0x77>
nopw   0x0(%rax,%rax,1)
or     %r12d,%esi
or     $0x1,%esi
movzbl %al,%edx
movzbl %cl,%ecx
movzbl %dil,%r8d
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x10,%ebx
add    $0x1,%r14d
cmp    $0xe,%r14d
je     1150 <main+0x20>
xorps  %xmm0,%xmm0
cvtsi2ss %r14d,%xmm0
mulss  0xe49(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
xorps  %xmm1,%xmm1
addss  %xmm1,%xmm0
addss  %xmm1,%xmm0
call   1050 <sin@plt>
movss  %xmm0,0x14(%rsp)
movss  0xc(%rsp),%xmm0
addss  0xe23(%rip),%xmm0
addss  0xe27(%rip),%xmm0
call   1050 <sin@plt>
movss  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
addss  0xe06(%rip),%xmm0
addss  0xe06(%rip),%xmm0
call   1050 <sin@plt>
movss  0xdf5(%rip),%xmm2
movss  0x14(%rsp),%xmm1
mulss  %xmm2,%xmm1
addss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xde7(%rip),%xmm3
addsd  %xmm3,%xmm1
cvttsd2si %xmm1,%eax
movss  0x10(%rsp),%xmm1
mulss  %xmm2,%xmm1
addss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm3,%xmm1
cvttsd2si %xmm1,%ecx
mulss  %xmm2,%xmm0
addss  %xmm2,%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm3,%xmm0
cvttsd2si %xmm0,%edi
mov    %ebx,%esi
cmp    $0xff,%ebp
ja     1180 <main+0x50>
or     %r13d,%esi
or     $0x1,%esi
movzbl %al,%edx
movzbl %cl,%ecx
movzbl %dil,%r8d
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xff,%ebp
jne    119a <main+0x6a>
cmp    $0xcf,%ebx
jb     119a <main+0x6a>
lea    0xd99(%rip),%rdi
call   1030 <puts@plt>
jmp    119a <main+0x6a>
xor    %eax,%eax
add    $0x18,%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"
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
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca float
%20 = alloca float
%21 = alloca float
%22 = alloca i32
%23 = alloca i8
%24 = alloca i8
%25 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 44, i32* %6
store i32 256, i32* %7
%26 = load i32, i32* %6
%27 = load i32, i32* %7
%28 = add nsw i32 %26, %27
store i32 %28, i32* %8
store i32 14, i32* %9
store float 0x3FD3333340000000, float* %13
store float 0x3FD3333340000000, float* %14
store float 0x3FD3333340000000, float* %15
store float 0.000000e+00, float* %16
store float 2.000000e+00, float* %17
store float 4.000000e+00, float* %18
store float 0.000000e+00, float* %19
store float 7.000000e+00, float* %20
store float 7.000000e+00, float* %21
store i32 16, i32* %22
%29 = load i32, i32* %6
store i32 %29, i32* %12
br label %30
30: ; preds = %137, %2
%31 = load i32, i32* %12
%32 = load i32, i32* %8
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %140
34: ; preds = %30
store i32 0, i32* %10
%35 = load i32, i32* %9
store i32 %35, i32* %11
br label %36
36: ; preds = %130, %34
%37 = load i32, i32* %11
%38 = icmp slt i32 %37, 223
br i1 %38, label %39, label %136
39: ; preds = %36
%40 = load float, float* %13
%41 = load i32, i32* %10
%42 = sitofp i32 %41 to float
%43 = load float, float* %16
%44 = call float @llvm.fmuladd.f32(float %40, float %42, float %43)
%45 = load float, float* %19
%46 = fadd float %44, %45
%47 = call float @sin(float %46)
%48 = load float, float* %21
%49 = load float, float* %20
%50 = call float @llvm.fmuladd.f32(float %47, float %48, float %49)
%51 = fpext float %50 to double
%52 = fadd double %51, 5.000000e-01
%53 = fptoui double %52 to i8
store i8 %53, i8* %23
%54 = load float, float* %14
%55 = load i32, i32* %10
%56 = sitofp i32 %55 to float
%57 = load float, float* %17
%58 = call float @llvm.fmuladd.f32(float %54, float %56, float %57)
%59 = load float, float* %19
%60 = fadd float %58, %59
%61 = call float @sin(float %60)
%62 = load float, float* %21
%63 = load float, float* %20
%64 = call float @llvm.fmuladd.f32(float %61, float %62, float %63)
%65 = fpext float %64 to double
%66 = fadd double %65, 5.000000e-01
%67 = fptoui double %66 to i8
store i8 %67, i8* %24
%68 = load float, float* %15
%69 = load i32, i32* %10
%70 = sitofp i32 %69 to float
%71 = load float, float* %18
%72 = call float @llvm.fmuladd.f32(float %68, float %70, float %71)
%73 = load float, float* %19
%74 = fadd float %72, %73
%75 = call float @sin(float %74)
%76 = load float, float* %21
%77 = load float, float* %20
%78 = call float @llvm.fmuladd.f32(float %75, float %76, float %77)
%79 = fpext float %78 to double
%80 = fadd double %79, 5.000000e-01
%81 = fptoui double %80 to i8
store i8 %81, i8* %25
%82 = load i32, i32* %12
%83 = icmp eq i32 %82, 0
br i1 %83, label %84, label %88
84: ; preds = %39
%85 = load i32, i32* %10
%86 = icmp eq i32 %85, 0
br i1 %86, label %87, label %88
87: ; preds = %84
br label %129
88: ; preds = %84, %39
%89 = load i32, i32* %12
%90 = icmp sle i32 %89, 255
br i1 %90, label %91, label %114
91: ; preds = %88
%92 = load i32, i32* %12
%93 = shl i32 %92, 8
%94 = load i32, i32* %11
%95 = or i32 %93, %94
%96 = or i32 %95, 1
%97 = load i8, i8* %23
%98 = zext i8 %97 to i32
%99 = load i8, i8* %24
%100 = zext i8 %99 to i32
%101 = load i8, i8* %25
%102 = zext i8 %101 to i32
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %96, i32 %98, i32 %100, i32 %102)
%104 = load i32, i32* %12
%105 = icmp eq i32 %104, 255
br i1 %105, label %106, label %113
106: ; preds = %91
%107 = load i32, i32* %11
%108 = load i32, i32* %22
%109 = add nsw i32 %107, %108
%110 = icmp sge i32 %109, 223
br i1 %110, label %111, label %113
111: ; preds = %106
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %113
113: ; preds = %111, %106, %91
br label %128
114: ; preds = %88
%115 = load i32, i32* %12
%116 = sub nsw i32 %115, 256
%117 = shl i32 %116, 8
%118 = load i32, i32* %11
%119 = or i32 %117, %118
%120 = or i32 %119, 1
%121 = load i8, i8* %23
%122 = zext i8 %121 to i32
%123 = load i8, i8* %24
%124 = zext i8 %123 to i32
%125 = load i8, i8* %25
%126 = zext i8 %125 to i32
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %120, i32 %122, i32 %124, i32 %126)
br label %128
128: ; preds = %114, %113
br label %129
129: ; preds = %128, %87
br label %130
130: ; preds = %129
%131 = load i32, i32* %22
%132 = load i32, i32* %11
%133 = add nsw i32 %132, %131
store i32 %133, i32* %11
%134 = load i32, i32* %10
%135 = add nsw i32 %134, 1
store i32 %135, i32* %10
br label %36
136: ; preds = %36
br label %137
137: ; preds = %136
%138 = load i32, i32* %12
%139 = add nsw i32 %138, 1
store i32 %139, i32* %12
br label %30
140: ; preds = %30
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 = [26 x i8] c".verticalPositionWrapped:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %56
%4 = phi i32 [ 44, %2 ], [ %57, %56 ]
%5 = icmp ult i32 %4, 256
%6 = shl i32 %4, 8
%7 = add nsw i32 %6, -65536
%8 = icmp eq i32 %4, 255
br label %9
9: ; preds = %3, %52
%10 = phi i32 [ 0, %3 ], [ %54, %52 ]
%11 = phi i32 [ 14, %3 ], [ %53, %52 ]
%12 = sitofp i32 %10 to float
%13 = tail call float @llvm.fmuladd.f32(float %12, float 0x3FD3333340000000, float 0.000000e+00)
%14 = fadd float %13, 0.000000e+00
%15 = tail call float @sin(float %14)
%16 = tail call float @llvm.fmuladd.f32(float %15, float 7.000000e+00, float 7.000000e+00)
%17 = fpext float %16 to double
%18 = fadd double %17, 5.000000e-01
%19 = fptoui double %18 to i8
%20 = tail call float @llvm.fmuladd.f32(float %12, float 0x3FD3333340000000, float 2.000000e+00)
%21 = fadd float %20, 0.000000e+00
%22 = tail call float @sin(float %21)
%23 = tail call float @llvm.fmuladd.f32(float %22, float 7.000000e+00, float 7.000000e+00)
%24 = fpext float %23 to double
%25 = fadd double %24, 5.000000e-01
%26 = fptoui double %25 to i8
%27 = tail call float @llvm.fmuladd.f32(float %12, float 0x3FD3333340000000, float 4.000000e+00)
%28 = fadd float %27, 0.000000e+00
%29 = tail call float @sin(float %28)
%30 = tail call float @llvm.fmuladd.f32(float %29, float 7.000000e+00, float 7.000000e+00)
%31 = fpext float %30 to double
%32 = fadd double %31, 5.000000e-01
%33 = fptoui double %32 to i8
br i1 %5, label %34, label %45
34: ; preds = %9
%35 = or i32 %11, %6
%36 = or i32 %35, 1
%37 = zext i8 %19 to i32
%38 = zext i8 %26 to i32
%39 = zext i8 %33 to i32
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %36, i32 %37, i32 %38, i32 %39)
%41 = icmp ugt i32 %11, 206
%42 = select i1 %8, i1 %41, i1 false
br i1 %42, label %43, label %52
43: ; preds = %34
%44 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %52
45: ; preds = %9
%46 = or i32 %11, %7
%47 = or i32 %46, 1
%48 = zext i8 %19 to i32
%49 = zext i8 %26 to i32
%50 = zext i8 %33 to i32
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %47, i32 %48, i32 %49, i32 %50)
br label %52
52: ; preds = %45, %43, %34
%53 = add nuw nsw i32 %11, 16
%54 = add nuw nsw i32 %10, 1
%55 = icmp eq i32 %54, 14
br i1 %55, label %56, label %9
56: ; preds = %52
%57 = add nuw nsw i32 %4, 1
%58 = icmp eq i32 %57, 300
br i1 %58, label %59, label %3
59: ; preds = %56
ret i32 0
}