#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 unsigned int uint32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
double deg_to_rad(double);
int /*<<< orphan*/ emit_text(int /*<<< orphan*/ *, char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double const);
scalar_t__ sin(double const);
void generate_sin_lut(FILE *f, const char *field) {
  uint32_t i;
  emit_text(f, "static const double ");
  emit_text(f, field);
  emit_text(f, "[] __attribute__ ((aligned (64)))  = {\n\t");
  for (i = 0U; i < 360U; ++i) {
    const double rad = deg_to_rad((double)i);
    const double sine = (double)sin(rad);
    fprintf(f, "%lf,", sine);
    if (i && (!(i & 7))) {
      emit_text(f, "\n\t");
    }
  }
  emit_text(f, "\n\t};\n");
}


x86 assembly (clang, -O0):
<generate_sin_lut>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1060 <emit_text@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <emit_text@plt>
mov    -0x8(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1060 <emit_text@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x168,-0x14(%rbp)
jae    1208 <generate_sin_lut+0xc8>
mov    -0x14(%rbp),%eax
cvtsi2sd %rax,%xmm0
call   1030 <deg_to_rad@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1050 <sin@plt>
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
lea    0xe77(%rip),%rsi
call   1040 <fprintf@plt>
cmpl   $0x0,-0x14(%rbp)
je     11f5 <generate_sin_lut+0xb5>
mov    -0x14(%rbp),%eax
and    $0x7,%eax
cmp    $0x0,%eax
jne    11f5 <generate_sin_lut+0xb5>
mov    -0x8(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1060 <emit_text@plt>
jmp    11fa <generate_sin_lut+0xba>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1184 <generate_sin_lut+0x44>
mov    -0x8(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   1060 <emit_text@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_sin_lut>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xeb4(%rip),%rsi
call   1060 <emit_text@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <emit_text@plt>
lea    0xeb2(%rip),%rsi
mov    %rbx,%rdi
call   1060 <emit_text@plt>
xor    %ebp,%ebp
xorpd  %xmm0,%xmm0
lea    0xec6(%rip),%r14
lea    0xebc(%rip),%r15
jmp    11a8 <generate_sin_lut+0x68>
nopl   0x0(%rax)
movsd  (%rsp),%xmm0
addsd  0xe63(%rip),%xmm0
add    $0x1,%ebp
cmp    $0x168,%ebp
je     11e2 <generate_sin_lut+0xa2>
movsd  %xmm0,(%rsp)
call   1030 <deg_to_rad@plt>
call   1050 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <fprintf@plt>
test   %ebp,%ebp
je     1190 <generate_sin_lut+0x50>
mov    %ebp,%eax
and    $0x7,%eax
jne    1190 <generate_sin_lut+0x50>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <emit_text@plt>
jmp    1190 <generate_sin_lut+0x50>
lea    0xe62(%rip),%rsi
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <emit_text@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"static const double \00"
@.str.1 = [41 x i8] c"[] __attribute__ ((aligned (64))) = {\0A\09\00"
@.str.2 = [5 x i8] c"%lf,\00"
@.str.3 = [3 x i8] c"\0A\09\00"
@.str.4 = [6 x i8] c"\0A\09};\0A\00"
define void @generate_sin_lut(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca double
%7 = alloca double
store i32* %0, i32** %3
store i8* %1, i8** %4
%8 = load i32*, i32** %3
%9 = call i32 @emit_text(i32* %8, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%10 = load i32*, i32** %3
%11 = load i8*, i8** %4
%12 = call i32 @emit_text(i32* %10, i8* %11)
%13 = load i32*, i32** %3
%14 = call i32 @emit_text(i32* %13, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %5
br label %15
15: ; preds = %38, %2
%16 = load i32, i32* %5
%17 = icmp ult i32 %16, 360
br i1 %17, label %18, label %41
18: ; preds = %15
%19 = load i32, i32* %5
%20 = uitofp i32 %19 to double
%21 = call double @deg_to_rad(double %20)
store double %21, double* %6
%22 = load double, double* %6
%23 = call i64 @sin(double %22)
%24 = sitofp i64 %23 to double
store double %24, double* %7
%25 = load i32*, i32** %3
%26 = load double, double* %7
%27 = call i32 @fprintf(i32* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %26)
%28 = load i32, i32* %5
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %37
30: ; preds = %18
%31 = load i32, i32* %5
%32 = and i32 %31, 7
%33 = icmp ne i32 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %30
%35 = load i32*, i32** %3
%36 = call i32 @emit_text(i32* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %37
37: ; preds = %34, %30, %18
br label %38
38: ; preds = %37
%39 = load i32, i32* %5
%40 = add i32 %39, 1
store i32 %40, i32* %5
br label %15
41: ; preds = %15
%42 = load i32*, i32** %3
%43 = call i32 @emit_text(i32* %42, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"static const double \00"
@.str.1 = [41 x i8] c"[] __attribute__ ((aligned (64))) = {\0A\09\00"
@.str.2 = [5 x i8] c"%lf,\00"
@.str.3 = [3 x i8] c"\0A\09\00"
@.str.4 = [6 x i8] c"\0A\09};\0A\00"
define void @generate_sin_lut(i32* %0, i8* %1) {
%3 = tail call i32 @emit_text(i32* %0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @emit_text(i32* %0, i8* %1)
%5 = tail call i32 @emit_text(i32* %0, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %2, %19
%7 = phi i32 [ 0, %2 ], [ %20, %19 ]
%8 = uitofp i32 %7 to double
%9 = tail call double @deg_to_rad(double %8)
%10 = tail call i64 @sin(double %9)
%11 = sitofp i64 %10 to double
%12 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %11)
%13 = icmp ne i32 %7, 0
%14 = and i32 %7, 7
%15 = icmp eq i32 %14, 0
%16 = and i1 %13, %15
br i1 %16, label %17, label %19
17: ; preds = %6
%18 = tail call i32 @emit_text(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %19
19: ; preds = %17, %6
%20 = add nuw nsw i32 %7, 1
%21 = icmp eq i32 %20, 360
br i1 %21, label %22, label %6
22: ; preds = %19
%23 = tail call i32 @emit_text(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
ret void
}