#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 */
float atan(float);
int /*<<< orphan*/ printf(char *, ...);
float sin(float);
int main() {
  int i;
  printf("const unsigned char sintab[65] = {");
  for (i = 0; i < 65; i++) {
    float fv = i * 3.14159 / 128.0;
    float f = sin(fv);
    int iv = f * 255.5;
    if (i % 16 == 0)
      printf("\n\t");
    printf("0x%02x, ", iv);
  }
  printf("};\n\n");
  printf("const unsigned char atancorrect[129] = {");
  for (i = 0; i < 129; i++) {
    float fv = i / 128.0;
    float f = atan(fv);
    f = f / 3.15159 * 4 * 256;
    int iv = f;
    if (i % 16 == 0)
      printf("\n\t");
    printf("0x%02x, ", iv);
  }
  printf("};\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeea(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x41,-0x8(%rbp)
jge    11f0 <main+0xc0>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xebd(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xea1(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
call   1040 <sin@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe7c(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11d1 <main+0xa1>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1154 <main+0x24>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x81,-0x8(%rbp)
jge    12c8 <main+0x198>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xdeb(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
call   1050 <atan@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdb6(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xda2(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd8e(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
cvttss2si -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    12a9 <main+0x179>
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1213 <main+0xe3>
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xee9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xorpd  %xmm0,%xmm0
lea    0xefa(%rip),%r14
lea    0xef6(%rip),%rbx
xor    %ebp,%ebp
jmp    1194 <main+0x54>
nopl   0x0(%rax)
cvttsd2si %xmm0,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xe8c(%rip),%xmm0
add    $0x1,%ebp
cmp    $0x41,%ebp
je     11db <main+0x9b>
movsd  %xmm0,0x8(%rsp)
mulsd  0xe5e(%rip),%xmm0
mulsd  0xe5e(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1050 <sin@plt>
cvtss2sd %xmm0,%xmm0
mulsd  0xe51(%rip),%xmm0
test   $0xf,%bpl
jne    1170 <main+0x30>
mov    %r14,%rdi
xor    %eax,%eax
movsd  %xmm0,(%rsp)
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
jmp    1170 <main+0x30>
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
lea    0xe79(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xorpd  %xmm0,%xmm0
lea    0xe5b(%rip),%r14
lea    0xe57(%rip),%rbx
xor    %ebp,%ebp
jmp    123b <main+0xfb>
nopl   0x0(%rax,%rax,1)
cvtsd2ss %xmm0,%xmm0
cvttss2si %xmm0,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xde8(%rip),%xmm0
add    $0x1,%ebp
cmp    $0x81,%ebp
je     128a <main+0x14a>
movsd  %xmm0,0x8(%rsp)
mulsd  0xdbf(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1060 <atan@plt>
cvtss2sd %xmm0,%xmm0
divsd  0xdc2(%rip),%xmm0
mulsd  0xdc2(%rip),%xmm0
mulsd  0xdc2(%rip),%xmm0
test   $0xf,%bpl
jne    1210 <main+0xd0>
mov    %r14,%rdi
xor    %eax,%eax
movsd  %xmm0,(%rsp)
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
jmp    1210 <main+0xd0>
lea    0xe03(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"const unsigned char sintab[65] = {\00"
@.str.1 = [3 x i8] c"\0A\09\00"
@.str.2 = [9 x i8] c"0x%02x, \00"
@.str.3 = [5 x i8] c"};\0A\0A\00"
@.str.4 = [41 x i8] c"const unsigned char atancorrect[129] = {\00"
@.str.5 = [4 x i8] c"};\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca i32
%6 = alloca float
%7 = alloca float
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %10
10: ; preds = %33, %0
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 65
br i1 %12, label %13, label %36
13: ; preds = %10
%14 = load i32, i32* %2
%15 = sitofp i32 %14 to double
%16 = fmul double %15, 3.141590e+00
%17 = fdiv double %16, 1.280000e+02
%18 = fptrunc double %17 to float
store float %18, float* %3
%19 = load float, float* %3
%20 = call float @sin(float %19)
store float %20, float* %4
%21 = load float, float* %4
%22 = fpext float %21 to double
%23 = fmul double %22, 2.555000e+02
%24 = fptosi double %23 to i32
store i32 %24, i32* %5
%25 = load i32, i32* %2
%26 = srem i32 %25, 16
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %13
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %28, %13
%31 = load i32, i32* %5
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %30
%34 = load i32, i32* %2
%35 = add nsw i32 %34, 1
store i32 %35, i32* %2
br label %10
36: ; preds = %10
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %2
br label %39
39: ; preds = %65, %36
%40 = load i32, i32* %2
%41 = icmp slt i32 %40, 129
br i1 %41, label %42, label %68
42: ; preds = %39
%43 = load i32, i32* %2
%44 = sitofp i32 %43 to double
%45 = fdiv double %44, 1.280000e+02
%46 = fptrunc double %45 to float
store float %46, float* %6
%47 = load float, float* %6
%48 = call float @atan(float %47)
store float %48, float* %7
%49 = load float, float* %7
%50 = fpext float %49 to double
%51 = fdiv double %50, 3.151590e+00
%52 = fmul double %51, 4.000000e+00
%53 = fmul double %52, 2.560000e+02
%54 = fptrunc double %53 to float
store float %54, float* %7
%55 = load float, float* %7
%56 = fptosi float %55 to i32
store i32 %56, i32* %8
%57 = load i32, i32* %2
%58 = srem i32 %57, 16
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %42
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %62
62: ; preds = %60, %42
%63 = load i32, i32* %8
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %63)
br label %65
65: ; preds = %62
%66 = load i32, i32* %2
%67 = add nsw i32 %66, 1
store i32 %67, i32* %2
br label %39
68: ; preds = %39
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"const unsigned char sintab[65] = {\00"
@.str.1 = [3 x i8] c"\0A\09\00"
@.str.2 = [9 x i8] c"0x%02x, \00"
@.str.4 = [41 x i8] c"const unsigned char atancorrect[129] = {\00"
@str = [4 x i8] c"};\0A\00"
@str.6 = [3 x i8] c"};\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %2
2: ; preds = %0, %16
%3 = phi i32 [ 0, %0 ], [ %18, %16 ]
%4 = sitofp i32 %3 to double
%5 = fmul double %4, 3.141590e+00
%6 = fmul double %5, 7.812500e-03
%7 = fptrunc double %6 to float
%8 = tail call float @sin(float %7)
%9 = fpext float %8 to double
%10 = fmul double %9, 2.555000e+02
%11 = fptosi double %10 to i32
%12 = and i32 %3, 15
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %2
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%18 = add nuw nsw i32 %3, 1
%19 = icmp eq i32 %18, 65
br i1 %19, label %20, label %2
20: ; preds = %16
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
br label %23
23: ; preds = %20, %39
%24 = phi i32 [ 0, %20 ], [ %41, %39 ]
%25 = sitofp i32 %24 to double
%26 = fmul double %25, 7.812500e-03
%27 = fptrunc double %26 to float
%28 = tail call float @atan(float %27)
%29 = fpext float %28 to double
%30 = fdiv double %29, 3.151590e+00
%31 = fmul double %30, 4.000000e+00
%32 = fmul double %31, 2.560000e+02
%33 = fptrunc double %32 to float
%34 = fptosi float %33 to i32
%35 = and i32 %24, 15
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %23
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %39
39: ; preds = %37, %23
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%41 = add nuw nsw i32 %24, 1
%42 = icmp eq i32 %41, 129
br i1 %42, label %43, label %23
43: ; preds = %39
%44 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.6, i64 0, i64 0))
ret i32 0
}