#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 */
int /*<<< orphan*/ printf(char *, ...);
int sin(int);
void sin_tab(int max_x, int max_y) {
  int x;
  printf("unsigned char T_SIN[256] = {");
  for (x = 0; x <= max_x; x++) {
    printf("0x%x",
           (unsigned char)(sin(x * 90.0 * 3.14 / (180.0 * 255.0)) * max_y));
    if (x < max_x) {
      printf(", ");
    }
  }
  printf("};\n");
}


x86 assembly (clang, -O0):
<sin_tab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11c3 <sin_tab+0xa3>
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xeb4(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xea0(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe8c(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sin@plt>
imul   -0x8(%rbp),%eax
movzbl %al,%esi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b0 <sin_tab+0x90>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b5 <sin_tab+0x95>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1143 <sin_tab+0x23>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sin_tab>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r12d
mov    %edi,%r13d
lea    0xed0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r13d,%r13d
js     11c1 <sin_tab+0x91>
lea    0x1(%r13),%ebp
lea    0xed6(%rip),%r14
lea    0xed4(%rip),%r15
xor    %ebx,%ebx
jmp    1177 <sin_tab+0x47>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    %ebx,%ebp
je     11c1 <sin_tab+0x91>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xe7a(%rip),%xmm0
mulsd  0xe7a(%rip),%xmm0
divsd  0xe7a(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sin@plt>
imul   %r12d,%eax
movzbl %al,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r13d,%ebx
jge    1170 <sin_tab+0x40>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1170 <sin_tab+0x40>
lea    0xe75(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"unsigned char T_SIN[256] = {\00"
@.str.1 = [5 x i8] c"0x%x\00"
@.str.2 = [3 x i8] c", \00"
@.str.3 = [4 x i8] c"};\0A\00"
define void @sin_tab(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %7
7: ; preds = %30, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %3
%10 = icmp sle i32 %8, %9
br i1 %10, label %11, label %33
11: ; preds = %7
%12 = load i32, i32* %5
%13 = sitofp i32 %12 to double
%14 = fmul double %13, 9.000000e+01
%15 = fmul double %14, 3.140000e+00
%16 = fdiv double %15, 4.590000e+04
%17 = fptosi double %16 to i32
%18 = call i32 @sin(i32 %17)
%19 = load i32, i32* %4
%20 = mul nsw i32 %18, %19
%21 = trunc i32 %20 to i8
%22 = zext i8 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %5
%25 = load i32, i32* %3
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %29
27: ; preds = %11
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %27, %11
br label %30
30: ; preds = %29
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %7
33: ; preds = %7
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"unsigned char T_SIN[256] = {\00"
@.str.1 = [5 x i8] c"0x%x\00"
@.str.2 = [3 x i8] c", \00"
@str = [3 x i8] c"};\00"
define void @sin_tab(i32 %0, i32 %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%4 = icmp slt i32 %0, 0
br i1 %4, label %22, label %5
5: ; preds = %2, %19
%6 = phi i32 [ %20, %19 ], [ 0, %2 ]
%7 = sitofp i32 %6 to double
%8 = fmul double %7, 9.000000e+01
%9 = fmul double %8, 3.140000e+00
%10 = fdiv double %9, 4.590000e+04
%11 = fptosi double %10 to i32
%12 = tail call i32 @sin(i32 %11)
%13 = mul nsw i32 %12, %1
%14 = and i32 %13, 255
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = icmp slt i32 %6, %0
br i1 %16, label %17, label %19
17: ; preds = %5
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %5, %17
%20 = add nuw i32 %6, 1
%21 = icmp eq i32 %6, %0
br i1 %21, label %22, label %5
22: ; preds = %19, %2
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret void
}