#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 M_PI;
double cos(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ round(int);
int sin(int);
int main() {
  int i;
  printf("sine36\n");
  for (i = 0; i < 256; i++) {
    printf("\t\t.byt\t$%02x\n",
           (int)round(17.5 + 17.5 * cos(i * M_PI * 2 * 1 / 256) +
                      0 * sin(i * M_PI * 2 * 2 / 256)));
  }
  printf("sine256\n");
  for (i = 0; i < 256; i++) {
    printf("\t\t.byt\t$%02x\n",
           ((int)round(256 + 127 * sin(i * M_PI * 2 * 2 / 256))) & 255);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x100,-0x8(%rbp)
jge    1201 <main+0xc1>
mov    -0x8(%rbp),%eax
mov    0x2e6d(%rip),%rcx
imul   (%rcx),%eax
shl    $0x1,%eax
shl    $0x0,%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1050 <cos@plt>
movsd  0xe65(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e36(%rip),%rcx
imul   (%rcx),%eax
shl    $0x1,%eax
shl    $0x1,%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <sin@plt>
movsd  -0x10(%rbp),%xmm0
imul   $0x0,%eax,%eax
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1060 <round@plt>
mov    %eax,%esi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1164 <main+0x24>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x100,-0x8(%rbp)
jge    1277 <main+0x137>
mov    -0x8(%rbp),%eax
mov    0x2dbb(%rip),%rcx
imul   (%rcx),%eax
shl    $0x1,%eax
shl    $0x1,%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <sin@plt>
imul   $0x7f,%eax,%edi
add    $0x100,%edi
call   1060 <round@plt>
mov    %eax,%esi
and    $0xff,%esi
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1216 <main+0xd6>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e7d(%rip),%rbx
lea    0xe9e(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rbx),%eax
imul   %ebp,%eax
lea    0x7f(%rax),%edi
test   %eax,%eax
cmovns %eax,%edi
sar    $0x7,%edi
call   1060 <cos@plt>
movapd %xmm0,%xmm1
movsd  0xe5f(%rip),%xmm0
mulsd  %xmm0,%xmm1
addsd  %xmm0,%xmm1
addsd  0xe57(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
mov    (%rbx),%eax
imul   %ebp,%eax
lea    0x3f(%rax),%edi
test   %eax,%eax
cmovns %eax,%edi
sar    $0x6,%edi
call   1050 <sin@plt>
cvttsd2si 0x8(%rsp),%edi
call   1070 <round@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
jne    1180 <main+0x30>
lea    0xe30(%rip),%rdi
call   1030 <puts@plt>
lea    0xe0f(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rbx),%eax
imul   %ebp,%eax
lea    0x3f(%rax),%edi
test   %eax,%eax
cmovns %eax,%edi
sar    $0x6,%edi
call   1050 <sin@plt>
mov    %eax,%edi
shl    $0x7,%edi
sub    %eax,%edi
add    $0x100,%edi
call   1070 <round@plt>
movzbl %al,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
jne    1210 <main+0xc0>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"sine36\0A\00"
@.str.1 = [14 x i8] c"\09\09.byt\09$%02x\0A\00"
@M_PI = global i32 0
@.str.2 = [9 x i8] c"sine256\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %4
4: ; preds = %30, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 256
br i1 %6, label %7, label %33
7: ; preds = %4
%8 = load i32, i32* %2
%9 = load i32, i32* @M_PI
%10 = mul nsw i32 %8, %9
%11 = mul nsw i32 %10, 2
%12 = mul nsw i32 %11, 1
%13 = sdiv i32 %12, 256
%14 = call double @cos(i32 %13)
%15 = call double @llvm.fmuladd.f64(double 1.750000e+01, double %14, double 1.750000e+01)
%16 = load i32, i32* %2
%17 = load i32, i32* @M_PI
%18 = mul nsw i32 %16, %17
%19 = mul nsw i32 %18, 2
%20 = mul nsw i32 %19, 2
%21 = sdiv i32 %20, 256
%22 = call i32 @sin(i32 %21)
%23 = mul nsw i32 0, %22
%24 = sitofp i32 %23 to double
%25 = fadd double %15, %24
%26 = fptosi double %25 to i32
%27 = call i64 @round(i32 %26)
%28 = trunc i64 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %7
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
br label %4
33: ; preds = %4
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %35
35: ; preds = %52, %33
%36 = load i32, i32* %2
%37 = icmp slt i32 %36, 256
br i1 %37, label %38, label %55
38: ; preds = %35
%39 = load i32, i32* %2
%40 = load i32, i32* @M_PI
%41 = mul nsw i32 %39, %40
%42 = mul nsw i32 %41, 2
%43 = mul nsw i32 %42, 2
%44 = sdiv i32 %43, 256
%45 = call i32 @sin(i32 %44)
%46 = mul nsw i32 127, %45
%47 = add nsw i32 256, %46
%48 = call i64 @round(i32 %47)
%49 = trunc i64 %48 to i32
%50 = and i32 %49, 255
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %50)
br label %52
52: ; preds = %38
%53 = load i32, i32* %2
%54 = add nsw i32 %53, 1
store i32 %54, i32* %2
br label %35
55: ; preds = %35
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c"\09\09.byt\09$%02x\0A\00"
@M_PI = global i32 0
@str = [7 x i8] c"sine36\00"
@str.3 = [8 x i8] c"sine256\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %18, %2 ]
%4 = load i32, i32* @M_PI
%5 = mul nsw i32 %4, %3
%6 = sdiv i32 %5, 128
%7 = tail call double @cos(i32 %6)
%8 = tail call double @llvm.fmuladd.f64(double %7, double 1.750000e+01, double 1.750000e+01)
%9 = load i32, i32* @M_PI
%10 = mul nsw i32 %9, %3
%11 = sdiv i32 %10, 64
%12 = tail call i32 @sin(i32 %11)
%13 = fadd double %8, 0.000000e+00
%14 = fptosi double %13 to i32
%15 = tail call i64 @round(i32 %14)
%16 = trunc i64 %15 to i32
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = add nuw nsw i32 %3, 1
%19 = icmp eq i32 %18, 256
br i1 %19, label %20, label %2
20: ; preds = %2
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.3, i64 0, i64 0))
br label %22
22: ; preds = %20, %22
%23 = phi i32 [ 0, %20 ], [ %34, %22 ]
%24 = load i32, i32* @M_PI
%25 = mul nsw i32 %24, %23
%26 = sdiv i32 %25, 64
%27 = tail call i32 @sin(i32 %26)
%28 = mul nsw i32 %27, 127
%29 = add nsw i32 %28, 256
%30 = tail call i64 @round(i32 %29)
%31 = trunc i64 %30 to i32
%32 = and i32 %31, 255
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = add nuw nsw i32 %23, 1
%35 = icmp eq i32 %34, 256
br i1 %35, label %36, label %22
36: ; preds = %22
ret i32 0
}