#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 */
double M_PI;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
double sin(double);
int main(int argc, char *argv[]) {
  int i;
  (void)printf("static const int8_t PROGMEM sinetab[256] = {\n  ");
  for (i = 0; i < 256; i++) {
    (void)printf("%4d", (int)(sin((double)i / 128.0 * M_PI) * 127.5 - 0.5));
    if (i < 255)
      (void)printf(((i & 7) == 7) ? ",\n  " : ",");
  }
  (void)puts("\n};");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    11f5 <main+0xc5>
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xe9b(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    0x2e68(%rip),%rax
mulsd  (%rax),%xmm0
call   1050 <sin@plt>
movsd  0xe6f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe6b(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0xff,-0x14(%rbp)
jge    11e2 <main+0xb2>
mov    -0x14(%rbp),%ecx
and    $0x7,%ecx
lea    0xe84(%rip),%rdi
lea    0xe78(%rip),%rax
cmp    $0x7,%ecx
cmove  %rax,%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e7 <main+0xb7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115b <main+0x2b>
lea    0xe57(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xed9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e9b(%rip),%r14
xorpd  %xmm0,%xmm0
mulsd  (%r14),%xmm0
call   1050 <sin@plt>
mulsd  0xe9d(%rip),%xmm0
addsd  0xe9d(%rip),%xmm0
cvttsd2si %xmm0,%esi
lea    0xed2(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec5(%rip),%r12
lea    0xec3(%rip),%rbx
xor    %ebp,%ebp
mov    %ebp,%eax
not    %eax
test   $0x7,%al
mov    %rbx,%rdi
cmove  %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0xe5a(%rip),%xmm0
mulsd  (%r14),%xmm0
call   1050 <sin@plt>
mulsd  0xe38(%rip),%xmm0
addsd  0xe38(%rip),%xmm0
cvttsd2si %xmm0,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xff,%ebp
jne    1190 <main+0x60>
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"static const int8_t PROGMEM sinetab[256] = {\0A \00"
@.str.1 = [4 x i8] c"%4d\00"
@M_PI = global double 0.000000e+00
@.str.2 = [5 x i8] c",\0A \00"
@.str.3 = [2 x i8] c",\00"
@.str.4 = [4 x i8] c"\0A};\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %8
8: ; preds = %31, %2
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 256
br i1 %10, label %11, label %34
11: ; preds = %8
%12 = load i32, i32* %6
%13 = sitofp i32 %12 to double
%14 = fdiv double %13, 1.280000e+02
%15 = load double, double* @M_PI
%16 = fmul double %14, %15
%17 = call double @sin(double %16)
%18 = call double @llvm.fmuladd.f64(double %17, double 1.275000e+02, double -5.000000e-01)
%19 = fptosi double %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %6
%22 = icmp slt i32 %21, 255
br i1 %22, label %23, label %30
23: ; preds = %11
%24 = load i32, i32* %6
%25 = and i32 %24, 7
%26 = icmp eq i32 %25, 7
%27 = zext i1 %26 to i64
%28 = select i1 %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%29 = call i32 (i8*, ...) @printf(i8* %28)
br label %30
30: ; preds = %23, %11
br label %31
31: ; preds = %30
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %8
34: ; preds = %8
%35 = call i32 @puts(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [48 x i8] c"static const int8_t PROGMEM sinetab[256] = {\0A \00"
@.str.1 = [4 x i8] c"%4d\00"
@M_PI = global double 0.000000e+00
@.str.2 = [5 x i8] c",\0A \00"
@.str.3 = [2 x i8] c",\00"
@.str.4 = [4 x i8] c"\0A};\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%4 = load double, double* @M_PI
%5 = fmul double %4, 0.000000e+00
%6 = tail call double @sin(double %5)
%7 = tail call double @llvm.fmuladd.f64(double %6, double 1.275000e+02, double -5.000000e-01)
%8 = fptosi double %7 to i32
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %2, %10
%11 = phi i32 [ 0, %2 ], [ %16, %10 ]
%12 = and i32 %11, 7
%13 = icmp eq i32 %12, 7
%14 = select i1 %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %14)
%16 = add nuw nsw i32 %11, 1
%17 = sitofp i32 %16 to double
%18 = fmul double %17, 7.812500e-03
%19 = load double, double* @M_PI
%20 = fmul double %18, %19
%21 = tail call double @sin(double %20)
%22 = tail call double @llvm.fmuladd.f64(double %21, double 1.275000e+02, double -5.000000e-01)
%23 = fptosi double %22 to i32
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = icmp eq i32 %16, 255
br i1 %25, label %26, label %10
26: ; preds = %10
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}