#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 cos(int /*<<< orphan*/);
int /*<<< orphan*/ degree_radians(int);
double fabs(float);
int /*<<< orphan*/ printf(char *, ...);
float sin(int /*<<< orphan*/);
void sin_cos_table() {
  int angles[4] = {30, 45, 60, 90};
  float sind, cosd;
  printf("| x° | sin(x) | cos(x) |\n");
  for (int i = 0; i < 4; i++) {
    sind = sin(degree_radians(angles[i]));
    cosd = cos(degree_radians(angles[i]));
    printf("| %2d |  %1.2f  |  %1.2f  |\n", angles[i], sind, fabs(cosd));
  }
}


x86 assembly (clang, -O0):
<sin_cos_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xea1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xe9e(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    1209 <sin_cos_table+0xb9>
movslq -0x1c(%rbp),%rax
mov    -0x10(%rbp,%rax,4),%edi
call   1040 <degree_radians@plt>
mov    %eax,%edi
call   1060 <sin@plt>
movss  %xmm0,-0x14(%rbp)
movslq -0x1c(%rbp),%rax
mov    -0x10(%rbp,%rax,4),%edi
call   1040 <degree_radians@plt>
mov    %eax,%edi
call   1070 <cos@plt>
movss  %xmm0,-0x18(%rbp)
movslq -0x1c(%rbp),%rax
mov    -0x10(%rbp,%rax,4),%eax
mov    %eax,-0x2c(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movss  -0x18(%rbp),%xmm0
call   1050 <fabs@plt>
mov    -0x2c(%rbp),%esi
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
lea    0xe37(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1183 <sin_cos_table+0x33>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sin_cos_table>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1e,%edi
call   1050 <degree_radians@plt>
mov    %eax,%edi
call   1070 <sin@plt>
movss  %xmm0,0x8(%rsp)
mov    $0x1e,%edi
call   1050 <degree_radians@plt>
mov    %eax,%edi
call   1080 <cos@plt>
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  %xmm1,0x8(%rsp)
call   1060 <fabs@plt>
movaps %xmm0,%xmm1
lea    0xe48(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1e,%esi
movsd  0x8(%rsp),%xmm0
mov    $0x2,%al
call   1040 <printf@plt>
mov    $0x2d,%edi
call   1050 <degree_radians@plt>
mov    %eax,%edi
call   1070 <sin@plt>
movss  %xmm0,0x8(%rsp)
mov    $0x2d,%edi
call   1050 <degree_radians@plt>
mov    %eax,%edi
call   1080 <cos@plt>
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  %xmm1,0x8(%rsp)
call   1060 <fabs@plt>
movaps %xmm0,%xmm1
mov    %rbx,%rdi
mov    $0x2d,%esi
movsd  0x8(%rsp),%xmm0
mov    $0x2,%al
call   1040 <printf@plt>
mov    $0x3c,%edi
call   1050 <degree_radians@plt>
mov    %eax,%edi
call   1070 <sin@plt>
movss  %xmm0,0x8(%rsp)
mov    $0x3c,%edi
call   1050 <degree_radians@plt>
mov    %eax,%edi
call   1080 <cos@plt>
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  %xmm1,0x8(%rsp)
call   1060 <fabs@plt>
movaps %xmm0,%xmm1
mov    %rbx,%rdi
mov    $0x3c,%esi
movsd  0x8(%rsp),%xmm0
mov    $0x2,%al
call   1040 <printf@plt>
mov    $0x5a,%edi
call   1050 <degree_radians@plt>
mov    %eax,%edi
call   1070 <sin@plt>
movss  %xmm0,0x8(%rsp)
mov    $0x5a,%edi
call   1050 <degree_radians@plt>
mov    %eax,%edi
call   1080 <cos@plt>
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  %xmm1,0x8(%rsp)
call   1060 <fabs@plt>
movaps %xmm0,%xmm1
mov    %rbx,%rdi
mov    $0x5a,%esi
movsd  0x8(%rsp),%xmm0
mov    $0x2,%al
add    $0x10,%rsp
pop    %rbx
jmp    1040 <printf@plt>

LLVM IR (-O0):
@__const.sin_cos_table.angles = [4 x i32] [i32 30, i32 45, i32 60, i32 90]
@.str = [27 x i8] c"| x\C2\B0 | sin(x) | cos(x) |\0A\00"
@.str.1 = [29 x i8] c"| %2d | %1.2f | %1.2f |\0A\00"
define void @sin_cos_table() {
%1 = alloca [4 x i32]
%2 = alloca float
%3 = alloca float
%4 = alloca i32
%5 = bitcast [4 x i32]* %1 to i8*
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %7
7: ; preds = %32, %0
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %35
10: ; preds = %7
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = call i32 @degree_radians(i32 %14)
%16 = call float @sin(i32 %15)
store float %16, float* %2
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = call i32 @degree_radians(i32 %20)
%22 = call float @cos(i32 %21)
store float %22, float* %3
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = load float, float* %2
%28 = fpext float %27 to double
%29 = load float, float* %3
%30 = call double @fabs(float %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %26, double %28, double %30)
br label %32
32: ; preds = %10
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %7
35: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str.1 = [29 x i8] c"| %2d | %1.2f | %1.2f |\0A\00"
@str = [26 x i8] c"| x\C2\B0 | sin(x) | cos(x) |\00"
define void @sin_cos_table() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @degree_radians(i32 30)
%3 = tail call float @sin(i32 %2)
%4 = tail call i32 @degree_radians(i32 30)
%5 = tail call float @cos(i32 %4)
%6 = fpext float %3 to double
%7 = tail call double @fabs(float %5)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 30, double %6, double %7)
%9 = tail call i32 @degree_radians(i32 45)
%10 = tail call float @sin(i32 %9)
%11 = tail call i32 @degree_radians(i32 45)
%12 = tail call float @cos(i32 %11)
%13 = fpext float %10 to double
%14 = tail call double @fabs(float %12)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 45, double %13, double %14)
%16 = tail call i32 @degree_radians(i32 60)
%17 = tail call float @sin(i32 %16)
%18 = tail call i32 @degree_radians(i32 60)
%19 = tail call float @cos(i32 %18)
%20 = fpext float %17 to double
%21 = tail call double @fabs(float %19)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 60, double %20, double %21)
%23 = tail call i32 @degree_radians(i32 90)
%24 = tail call float @sin(i32 %23)
%25 = tail call i32 @degree_radians(i32 90)
%26 = tail call float @cos(i32 %25)
%27 = fpext float %24 to double
%28 = tail call double @fabs(float %26)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 90, double %27, double %28)
ret void
}