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

/* Variables and functions */
int M_PI;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int sin(int);
void output_16_sin(FILE *out, int i) {
  fprintf(out, "\n    .byte");
  char c = ' ';
  for (int j = 0; j < 16; j++, i++) {
    float v = 127 * sin(i * 2.f * M_PI / 256.f);
    fprintf(out, "%c$%02x", c, (uint8_t)v);
    c = ',';
  }
}


x86 assembly (clang, -O0):
<output_16_sin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xece(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movb   $0x20,-0xd(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    11cd <output_16_sin+0xad>
cvtsi2ssl -0xc(%rbp),%xmm0
movss  0xea1(%rip),%xmm1
mulss  %xmm1,%xmm0
mov    0x2e7a(%rip),%rax
cvtsi2ssl (%rax),%xmm1
mulss  %xmm1,%xmm0
movss  0xe82(%rip),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1040 <sin@plt>
imul   $0x7f,%eax,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
movsbl -0xd(%rbp),%edx
cvttss2si -0x18(%rbp),%ecx
lea    0xe68(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movb   $0x2c,-0xd(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114c <output_16_sin+0x2c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_16_sin>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %rdi,%r13
lea    0xebe(%rip),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1050 <fwrite@plt>
cvtsi2ss %r14d,%xmm0
addss  %xmm0,%xmm0
mov    0x2e80(%rip),%r12
cvtsi2ssl (%r12),%xmm1
mulss  %xmm0,%xmm1
mulss  0xe86(%rip),%xmm1
cvttss2si %xmm1,%edi
call   1040 <sin@plt>
mov    %eax,%ecx
shl    $0x7,%ecx
sub    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
cvttss2si %xmm0,%ecx
lea    0xe73(%rip),%r15
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x20,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%r14,%rbx,1),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  %xmm0,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssl (%r12),%xmm1
mulss  %xmm0,%xmm1
mulss  0xe1c(%rip),%xmm1
cvttss2si %xmm1,%edi
call   1040 <sin@plt>
mov    %eax,%ecx
shl    $0x7,%ecx
sub    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
cvttss2si %xmm0,%ecx
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x2c,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%ebx
cmp    $0x10,%ebx
jne    11c0 <output_16_sin+0x90>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"\0A .byte\00"
@M_PI = global i32 0
@.str.1 = [8 x i8] c"%c$%02x\00"
define void @output_16_sin(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
%7 = alloca float
store i32* %0, i32** %3
store i32 %1, i32* %4
%8 = load i32*, i32** %3
%9 = call i32 (i32*, i8*, ...) @fprintf(i32* %8, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i8 32, i8* %5
store i32 0, i32* %6
br label %10
10: ; preds = %31, %2
%11 = load i32, i32* %6
%12 = icmp slt i32 %11, 16
br i1 %12, label %13, label %36
13: ; preds = %10
%14 = load i32, i32* %4
%15 = sitofp i32 %14 to float
%16 = fmul float %15, 2.000000e+00
%17 = load i32, i32* @M_PI
%18 = sitofp i32 %17 to float
%19 = fmul float %16, %18
%20 = fdiv float %19, 2.560000e+02
%21 = fptosi float %20 to i32
%22 = call i32 @sin(i32 %21)
%23 = mul nsw i32 127, %22
%24 = sitofp i32 %23 to float
store float %24, float* %7
%25 = load i32*, i32** %3
%26 = load i8, i8* %5
%27 = sext i8 %26 to i32
%28 = load float, float* %7
%29 = fptosi float %28 to i32
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %27, i32 %29)
store i8 44, i8* %5
br label %31
31: ; preds = %13
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %10
36: ; preds = %10
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"\0A .byte\00"
@M_PI = global i32 0
@.str.1 = [8 x i8] c"%c$%02x\00"
define void @output_16_sin(i32* nocapture %0, i32 %1) {
%3 = tail call i64 @fwrite(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 10, i64 1, i32* %0)
%4 = sitofp i32 %1 to float
%5 = fmul float %4, 2.000000e+00
%6 = load i32, i32* @M_PI
%7 = sitofp i32 %6 to float
%8 = fmul float %5, %7
%9 = fmul float %8, 3.906250e-03
%10 = fptosi float %9 to i32
%11 = tail call i32 @sin(i32 %10)
%12 = mul nsw i32 %11, 127
%13 = sitofp i32 %12 to float
%14 = fptosi float %13 to i32
%15 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 32, i32 %14)
br label %17
16: ; preds = %17
ret void
17: ; preds = %2, %17
%18 = phi i32 [ %1, %2 ], [ %20, %17 ]
%19 = phi i32 [ 1, %2 ], [ %33, %17 ]
%20 = add nsw i32 %18, 1
%21 = sitofp i32 %20 to float
%22 = fmul float %21, 2.000000e+00
%23 = load i32, i32* @M_PI
%24 = sitofp i32 %23 to float
%25 = fmul float %22, %24
%26 = fmul float %25, 3.906250e-03
%27 = fptosi float %26 to i32
%28 = tail call i32 @sin(i32 %27)
%29 = mul nsw i32 %28, 127
%30 = sitofp i32 %29 to float
%31 = fptosi float %30 to i32
%32 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 44, i32 %31)
%33 = add nuw nsw i32 %19, 1
%34 = icmp eq i32 %33, 16
br i1 %34, label %16, label %17
}