#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 int16_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int sin(int);
int main() {
  int16_t table[0x100];
  table[0x00] = 0;
  table[0x40] = 0x200 * 1.5;
  table[0x80] = 0;
  table[0xC0] = -0x200 * 1.5;
  for (int i = 1; i < 0x40; i++) {
    table[i] = (sin(i * 3.1415926 / 0x80) * 0x200 + 0.5) * 1.5;
    table[0x80 - i] = table[i];
    table[0x80 + i] = -table[i];
    table[0x100 - i] = -table[i];
  }
  printf("#include <stdint.h>\n\n");
  printf("const int16_t sin[0x100] = {\n\t");
  for (int i = 0; i < 0x100; i++) {
    printf("0x%04hx, ", table[i]);
    if ((i & 7) == 7)
      printf("\n\t");
  }
  printf("};\n\n");
  printf("const int16_t cos[0x100] = {\n\t");
  for (int i = 0x40; i < 0x140; i++) {
    printf("0x%04hx, ", table[i & 0xFF]);
    if ((i & 7) == 7)
      printf("\n\t");
  }
  printf("};\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x410(%rbp)
movl   $0x300,-0x310(%rbp)
movl   $0x0,-0x210(%rbp)
movl   $0xfffffd00,-0x110(%rbp)
fd ff ff
movl   $0x1,-0x414(%rbp)
cmpl   $0x40,-0x414(%rbp)
jge    1249 <main+0x129>
cvtsi2sdl -0x414(%rbp),%xmm0
ff
movsd  0xe97(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe83(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sin@plt>
shl    $0x9,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe5f(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe4b(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
movslq -0x414(%rbp),%rax
mov    %ecx,-0x410(%rbp,%rax,4)
movslq -0x414(%rbp),%rax
mov    -0x410(%rbp,%rax,4),%ecx
mov    $0x80,%eax
sub    -0x414(%rbp),%eax
cltq
mov    %ecx,-0x410(%rbp,%rax,4)
movslq -0x414(%rbp),%rax
xor    %ecx,%ecx
sub    -0x410(%rbp,%rax,4),%ecx
mov    -0x414(%rbp),%eax
add    $0x80,%eax
cltq
mov    %ecx,-0x410(%rbp,%rax,4)
movslq -0x414(%rbp),%rax
xor    %ecx,%ecx
sub    -0x410(%rbp,%rax,4),%ecx
mov    $0x100,%eax
sub    -0x414(%rbp),%eax
cltq
mov    %ecx,-0x410(%rbp,%rax,4)
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    1164 <main+0x44>
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x418(%rbp)
cmpl   $0x100,-0x418(%rbp)
jge    12d4 <main+0x1b4>
movslq -0x418(%rbp),%rax
mov    -0x410(%rbp,%rax,4),%esi
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x418(%rbp),%eax
and    $0x7,%eax
cmp    $0x7,%eax
jne    12bb <main+0x19b>
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c0 <main+0x1a0>
mov    -0x418(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x418(%rbp)
jmp    126f <main+0x14f>
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x40,-0x41c(%rbp)
cmpl   $0x140,-0x41c(%rbp)
jge    1365 <main+0x245>
mov    -0x41c(%rbp),%eax
and    $0xff,%eax
cltq
mov    -0x410(%rbp,%rax,4),%esi
lea    0xd30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x41c(%rbp),%eax
and    $0x7,%eax
cmp    $0x7,%eax
jne    134c <main+0x22c>
lea    0xd0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1351 <main+0x231>
mov    -0x41c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x41c(%rbp)
jmp    12fa <main+0x1da>
lea    0xd17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
movl   $0x0,(%rsp)
movl   $0x300,0x100(%rsp)
movl   $0x0,0x200(%rsp)
movl   $0xfffffd00,0x300(%rsp)
mov    $0x1,%ebx
mov    $0x7f,%r14d
xchg   %ax,%ax
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xe81(%rip),%xmm0
mulsd  0xe81(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sin@plt>
shl    $0x9,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0xe6e(%rip),%xmm0
mulsd  0xe6e(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,(%rsp,%rbx,4)
mov    %eax,(%rsp,%r14,4)
xor    %eax,%eax
sub    (%rsp,%rbx,4),%eax
mov    %eax,0x200(%rsp,%rbx,4)
mov    %eax,0x200(%rsp,%r14,4)
add    $0x1,%rbx
add    $0xffffffffffffffff,%r14
cmp    $0x40,%r14
jne    1170 <main+0x40>
lea    0xe8a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe36(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe47(%rip),%rbx
lea    0xe3d(%rip),%r14
xor    %ebp,%ebp
jmp    121d <main+0xed>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbp
cmp    $0x100,%rbp
je     123e <main+0x10e>
mov    (%rsp,%rbp,4),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%eax
not    %eax
test   $0x7,%al
jne    1210 <main+0xe0>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1210 <main+0xe0>
lea    0xe38(%rip),%rdi
call   1030 <puts@plt>
lea    0xdf8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x40,%ebp
lea    0xddb(%rip),%rbx
lea    0xdd1(%rip),%r14
jmp    127b <main+0x14b>
nopl   (%rax)
add    $0x1,%ebp
cmp    $0x140,%ebp
je     12a0 <main+0x170>
movzbl %bpl,%eax
mov    (%rsp,%rax,4),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%eax
not    %eax
test   $0x7,%al
jne    1270 <main+0x140>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1270 <main+0x140>
lea    0xdda(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"#include <stdint.h>\0A\0A\00"
@.str.1 = [31 x i8] c"const int16_t sin[0x100] = {\0A\09\00"
@.str.2 = [10 x i8] c"0x%04hx, \00"
@.str.3 = [3 x i8] c"\0A\09\00"
@.str.4 = [5 x i8] c"};\0A\0A\00"
@.str.5 = [31 x i8] c"const int16_t cos[0x100] = {\0A\09\00"
@.str.6 = [4 x i8] c"};\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 0
store i32 0, i32* %6
%7 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 64
store i32 768, i32* %7
%8 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 128
store i32 0, i32* %8
%9 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 192
store i32 -768, i32* %9
store i32 1, i32* %3
br label %10
10: ; preds = %54, %0
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 64
br i1 %12, label %13, label %57
13: ; preds = %10
%14 = load i32, i32* %3
%15 = sitofp i32 %14 to double
%16 = fmul double %15, 0x400921FB4D12D84A
%17 = fdiv double %16, 1.280000e+02
%18 = fptosi double %17 to i32
%19 = call i32 @sin(i32 %18)
%20 = mul nsw i32 %19, 512
%21 = sitofp i32 %20 to double
%22 = fadd double %21, 5.000000e-01
%23 = fmul double %22, 1.500000e+00
%24 = fptosi double %23 to i32
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 %26
store i32 %24, i32* %27
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = load i32, i32* %3
%33 = sub nsw i32 128, %32
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 %34
store i32 %31, i32* %35
%36 = load i32, i32* %3
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = sub nsw i32 0, %39
%41 = load i32, i32* %3
%42 = add nsw i32 128, %41
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 %43
store i32 %40, i32* %44
%45 = load i32, i32* %3
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = sub nsw i32 0, %48
%50 = load i32, i32* %3
%51 = sub nsw i32 256, %50
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 %52
store i32 %49, i32* %53
br label %54
54: ; preds = %13
%55 = load i32, i32* %3
%56 = add nsw i32 %55, 1
store i32 %56, i32* %3
br label %10
57: ; preds = %10
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %4
br label %60
60: ; preds = %75, %57
%61 = load i32, i32* %4
%62 = icmp slt i32 %61, 256
br i1 %62, label %63, label %78
63: ; preds = %60
%64 = load i32, i32* %4
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 %65
%67 = load i32, i32* %66
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %67)
%69 = load i32, i32* %4
%70 = and i32 %69, 7
%71 = icmp eq i32 %70, 7
br i1 %71, label %72, label %74
72: ; preds = %63
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %74
74: ; preds = %72, %63
br label %75
75: ; preds = %74
%76 = load i32, i32* %4
%77 = add nsw i32 %76, 1
store i32 %77, i32* %4
br label %60
78: ; preds = %60
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
store i32 64, i32* %5
br label %81
81: ; preds = %97, %78
%82 = load i32, i32* %5
%83 = icmp slt i32 %82, 320
br i1 %83, label %84, label %100
84: ; preds = %81
%85 = load i32, i32* %5
%86 = and i32 %85, 255
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 %87
%89 = load i32, i32* %88
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %89)
%91 = load i32, i32* %5
%92 = and i32 %91, 7
%93 = icmp eq i32 %92, 7
br i1 %93, label %94, label %96
94: ; preds = %84
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %96
96: ; preds = %94, %84
br label %97
97: ; preds = %96
%98 = load i32, i32* %5
%99 = add nsw i32 %98, 1
store i32 %99, i32* %5
br label %81
100: ; preds = %81
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%102 = load i32, i32* %1
ret i32 %102
}

LLVM IR (-O2):
@.str.1 = [31 x i8] c"const int16_t sin[0x100] = {\0A\09\00"
@.str.2 = [10 x i8] c"0x%04hx, \00"
@.str.3 = [3 x i8] c"\0A\09\00"
@.str.5 = [31 x i8] c"const int16_t cos[0x100] = {\0A\09\00"
@str = [21 x i8] c"#include <stdint.h>\0A\00"
@str.7 = [4 x i8] c"};\0A\00"
@str.8 = [3 x i8] c"};\00"
define i32 @main() {
%1 = alloca [256 x i32]
%2 = bitcast [256 x i32]* %1 to i8*
%3 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 0
store i32 0, i32* %3
%4 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 64
store i32 768, i32* %4
%5 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 128
store i32 0, i32* %5
%6 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 192
store i32 -768, i32* %6
br label %10
7: ; preds = %10
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %37
10: ; preds = %0, %10
%11 = phi i64 [ 1, %0 ], [ %32, %10 ]
%12 = trunc i64 %11 to i32
%13 = sitofp i32 %12 to double
%14 = fmul double %13, 0x400921FB4D12D84A
%15 = fmul double %14, 7.812500e-03
%16 = fptosi double %15 to i32
%17 = tail call i32 @sin(i32 %16)
%18 = shl nsw i32 %17, 9
%19 = sitofp i32 %18 to double
%20 = fadd double %19, 5.000000e-01
%21 = fmul double %20, 1.500000e+00
%22 = fptosi double %21 to i32
%23 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 %11
store i32 %22, i32* %23
%24 = sub nuw nsw i64 128, %11
%25 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 %24
store i32 %22, i32* %25
%26 = load i32, i32* %23
%27 = sub nsw i32 0, %26
%28 = add nuw nsw i64 %11, 128
%29 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 %28
store i32 %27, i32* %29
%30 = sub nuw nsw i64 256, %11
%31 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 %30
store i32 %27, i32* %31
%32 = add nuw nsw i64 %11, 1
%33 = icmp eq i64 %32, 64
br i1 %33, label %7, label %10
34: ; preds = %46
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.7, i64 0, i64 0))
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
br label %51
37: ; preds = %7, %46
%38 = phi i64 [ 0, %7 ], [ %47, %46 ]
%39 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %40)
%42 = and i64 %38, 7
%43 = icmp eq i64 %42, 7
br i1 %43, label %44, label %46
44: ; preds = %37
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %46
46: ; preds = %37, %44
%47 = add nuw nsw i64 %38, 1
%48 = icmp eq i64 %47, 256
br i1 %48, label %34, label %37
49: ; preds = %62
%50 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.8, i64 0, i64 0))
ret i32 0
51: ; preds = %34, %62
%52 = phi i32 [ 64, %34 ], [ %63, %62 ]
%53 = and i32 %52, 255
%54 = zext i32 %53 to i64
%55 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %56)
%58 = and i32 %52, 7
%59 = icmp eq i32 %58, 7
br i1 %59, label %60, label %62
60: ; preds = %51
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %62
62: ; preds = %51, %60
%63 = add nuw nsw i32 %52, 1
%64 = icmp eq i32 %63, 320
br i1 %64, label %49, label %51
}