#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 /*<<< orphan*/ scanf(char *, ...);
double sin(float);
int main() {
  float fAngD, fAngR;
  float fTerm, fNum, fDen, fVal;
  int i, iNum;
  printf("Enter the Angle ....\n");
  scanf("%f", &fAngD);
  printf("Angle = %f\n", fAngD);
  printf("Enter the Number of terms...\n");
  scanf("%d", &iNum);
  printf("No of terms = %d\n", iNum);
  fAngR = (fAngD * 3.1416) / 180;
  fNum = fAngR;
  fDen = 1.0;
  fVal = 0.0;
  fTerm = fNum / fDen;
  for (i = 1; i <= iNum; i++) {
    fVal = fVal + fTerm;
    fNum = -fNum * fAngR * fAngR;
    fDen = fDen * (2 * i) * (2 * i + 1);
    fTerm = fNum / fDen;
  }
  printf(" Calculated value is :Sin( %f ) = %f\n", fAngD, fVal);
  printf("Built In function value is :Sin( %f ) = %f\n", fAngD, sin(fAngR));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xec2(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x24(%rbp),%esi
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe58(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe44(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xe1d(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
divss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     1288 <main+0x158>
movss  -0x1c(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  -0xc(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x18(%rbp),%xmm0
mov    -0x20(%rbp),%eax
shl    $0x1,%eax
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
mov    -0x20(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
divss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1206 <main+0xd6>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdcf(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movss  -0xc(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
lea    0xdc7(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xf5b(%rip),%rdi
call   1030 <puts@plt>
lea    0xed9(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xebf(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xf39(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb1(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x8(%rsp),%esi
lea    0xe9d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe42(%rip),%xmm1
mulsd  %xmm0,%xmm1
divsd  0xe3e(%rip),%xmm1
cvtsd2ss %xmm1,%xmm6
mov    0x8(%rsp),%eax
test   %eax,%eax
movss  %xmm6,0xc(%rsp)
jle    123d <main+0xfd>
movss  0xe2c(%rip),%xmm2
xorps  %xmm1,%xmm1
mov    $0x3,%ecx
movaps 0xe2d(%rip),%xmm3
movaps %xmm6,%xmm4
movaps %xmm6,%xmm5
nopl   0x0(%rax)
xorps  %xmm3,%xmm4
addss  %xmm5,%xmm1
mulss  %xmm6,%xmm4
mulss  %xmm6,%xmm4
lea    -0x1(%rcx),%edx
xorps  %xmm5,%xmm5
cvtsi2ss %edx,%xmm5
mulss  %xmm2,%xmm5
xorps  %xmm2,%xmm2
cvtsi2ss %ecx,%xmm2
mulss  %xmm5,%xmm2
movaps %xmm4,%xmm5
divss  %xmm2,%xmm5
add    $0x2,%ecx
add    $0xffffffff,%eax
jne    1200 <main+0xc0>
cvtss2sd %xmm1,%xmm1
jmp    1240 <main+0x100>
xorps  %xmm1,%xmm1
lea    0xe0d(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
lea    0xe07(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Enter the Angle ....\0A\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [12 x i8] c"Angle = %f\0A\00"
@.str.3 = [30 x i8] c"Enter the Number of terms...\0A\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [18 x i8] c"No of terms = %d\0A\00"
@.str.6 = [38 x i8] c" Calculated value is :Sin( %f ) = %f\0A\00"
@.str.7 = [44 x i8] c"Built In function value is :Sin( %f ) = %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%12 = load float, float* %2
%13 = fpext float %12 to double
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), double %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %9)
%17 = load i32, i32* %9
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %17)
%19 = load float, float* %2
%20 = fpext float %19 to double
%21 = fmul double %20, 3.141600e+00
%22 = fdiv double %21, 1.800000e+02
%23 = fptrunc double %22 to float
store float %23, float* %3
%24 = load float, float* %3
store float %24, float* %5
store float 1.000000e+00, float* %6
store float 0.000000e+00, float* %7
%25 = load float, float* %5
%26 = load float, float* %6
%27 = fdiv float %25, %26
store float %27, float* %4
store i32 1, i32* %8
br label %28
28: ; preds = %55, %0
%29 = load i32, i32* %8
%30 = load i32, i32* %9
%31 = icmp sle i32 %29, %30
br i1 %31, label %32, label %58
32: ; preds = %28
%33 = load float, float* %7
%34 = load float, float* %4
%35 = fadd float %33, %34
store float %35, float* %7
%36 = load float, float* %5
%37 = fneg float %36
%38 = load float, float* %3
%39 = fmul float %37, %38
%40 = load float, float* %3
%41 = fmul float %39, %40
store float %41, float* %5
%42 = load float, float* %6
%43 = load i32, i32* %8
%44 = mul nsw i32 2, %43
%45 = sitofp i32 %44 to float
%46 = fmul float %42, %45
%47 = load i32, i32* %8
%48 = mul nsw i32 2, %47
%49 = add nsw i32 %48, 1
%50 = sitofp i32 %49 to float
%51 = fmul float %46, %50
store float %51, float* %6
%52 = load float, float* %5
%53 = load float, float* %6
%54 = fdiv float %52, %53
store float %54, float* %4
br label %55
55: ; preds = %32
%56 = load i32, i32* %8
%57 = add nsw i32 %56, 1
store i32 %57, i32* %8
br label %28
58: ; preds = %28
%59 = load float, float* %2
%60 = fpext float %59 to double
%61 = load float, float* %7
%62 = fpext float %61 to double
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), double %60, double %62)
%64 = load float, float* %2
%65 = fpext float %64 to double
%66 = load float, float* %3
%67 = call double @sin(float %66)
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0), double %65, double %67)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [12 x i8] c"Angle = %f\0A\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [18 x i8] c"No of terms = %d\0A\00"
@.str.6 = [38 x i8] c" Calculated value is :Sin( %f ) = %f\0A\00"
@.str.7 = [44 x i8] c"Built In function value is :Sin( %f ) = %f\0A\00"
@str = [21 x i8] c"Enter the Angle ....\00"
@str.8 = [29 x i8] c"Enter the Number of terms...\00"
define i32 @main() {
%1 = alloca float
%2 = alloca i32
%3 = bitcast float* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%7 = load float, float* %1
%8 = fpext float %7 to double
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), double %8)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.8, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %12)
%14 = load float, float* %1
%15 = fpext float %14 to double
%16 = fmul double %15, 3.141600e+00
%17 = fdiv double %16, 1.800000e+02
%18 = fptrunc double %17 to float
%19 = load i32, i32* %2
%20 = icmp slt i32 %19, 1
br i1 %20, label %42, label %21
21: ; preds = %0, %21
%22 = phi i32 [ %38, %21 ], [ 1, %0 ]
%23 = phi float [ %27, %21 ], [ 0.000000e+00, %0 ]
%24 = phi float [ %36, %21 ], [ 1.000000e+00, %0 ]
%25 = phi float [ %30, %21 ], [ %18, %0 ]
%26 = phi float [ %37, %21 ], [ %18, %0 ]
%27 = fadd float %26, %23
%28 = fneg float %25
%29 = fmul float %18, %28
%30 = fmul float %29, %18
%31 = shl nuw nsw i32 %22, 1
%32 = sitofp i32 %31 to float
%33 = fmul float %24, %32
%34 = or i32 %31, 1
%35 = sitofp i32 %34 to float
%36 = fmul float %33, %35
%37 = fdiv float %30, %36
%38 = add nuw i32 %22, 1
%39 = icmp eq i32 %22, %19
br i1 %39, label %40, label %21
40: ; preds = %21
%41 = fpext float %27 to double
br label %42
42: ; preds = %40, %0
%43 = phi double [ 0.000000e+00, %0 ], [ %41, %40 ]
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), double %15, double %43)
%45 = load float, float* %1
%46 = fpext float %45 to double
%47 = call double @sin(float %18)
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0), double %46, double %47)
ret i32 0
}