#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 *);
double sin(double);
main() {
  double x, n, k = 0, g = 0, s = 0, a = 0;
  printf("Enter N and x\n");
  printf("X=");
  scanf("%d", &x);
  printf("N=");
  scanf("%d", &n);
  while (k <= n) {
    if (k != 0) {
      a = k * x;
      g = (1 / (k * k)) * (sin(a) / (k * k + k + 1));
      s = s + g;
      k++;
    } else
      k++;
  }
  printf("%f", s);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe98(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7a(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1283 <main+0x153>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11da <main+0xaa>
jp     11da <main+0xaa>
jmp    126c <main+0x13c>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
movsd  0xe05(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm4
movsd  -0x20(%rbp),%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
movsd  0xdcb(%rip),%xmm3
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xda3(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    127e <main+0x14e>
movsd  0xd8c(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11a9 <main+0x79>
movsd  -0x30(%rbp),%xmm0
lea    0xd91(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
lea    0xef0(%rip),%rdi
call   1030 <puts@plt>
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecd(%rip),%rbx
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
movsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jae    11b8 <main+0x78>
lea    0xe94(%rip),%rdi
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret
xorpd  %xmm1,%xmm1
xorpd  %xmm3,%xmm3
jmp    11de <main+0x9e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
addsd  0xe48(%rip),%xmm3
ucomisd %xmm3,%xmm0
jb     119e <main+0x5e>
ucomisd 0xe42(%rip),%xmm3
jne    11ea <main+0xaa>
jnp    11d0 <main+0x90>
movsd  0x18(%rsp),%xmm0
mulsd  %xmm3,%xmm0
movsd  %xmm1,0x10(%rsp)
movapd %xmm3,0x20(%rsp)
call   1050 <sin@plt>
movapd 0x20(%rsp),%xmm3
movapd %xmm3,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm3,%xmm1
movapd %xmm3,%xmm2
unpcklpd %xmm1,%xmm2
movapd %xmm3,%xmm1
mulpd  %xmm3,%xmm1
addpd  0xdd1(%rip),%xmm2
movsd  %xmm1,%xmm2
movapd 0xdd5(%rip),%xmm1
unpcklpd %xmm0,%xmm1
divpd  %xmm2,%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
jmp    11d0 <main+0x90>

LLVM IR (-O0):
@.str = [15 x i8] c"Enter N and x\0A\00"
@.str.1 = [3 x i8] c"X=\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"N=\00"
@.str.4 = [3 x i8] c"%f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %4
store double 0.000000e+00, double* %5
store double 0.000000e+00, double* %6
store double 0.000000e+00, double* %7
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), double* %2)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), double* %3)
br label %13
13: ; preds = %45, %0
%14 = load double, double* %4
%15 = load double, double* %3
%16 = fcmp ole double %14, %15
br i1 %16, label %17, label %46
17: ; preds = %13
%18 = load double, double* %4
%19 = fcmp une double %18, 0.000000e+00
br i1 %19, label %20, label %42
20: ; preds = %17
%21 = load double, double* %4
%22 = load double, double* %2
%23 = fmul double %21, %22
store double %23, double* %7
%24 = load double, double* %4
%25 = load double, double* %4
%26 = fmul double %24, %25
%27 = fdiv double 1.000000e+00, %26
%28 = load double, double* %7
%29 = call double @sin(double %28)
%30 = load double, double* %4
%31 = load double, double* %4
%32 = load double, double* %4
%33 = call double @llvm.fmuladd.f64(double %30, double %31, double %32)
%34 = fadd double %33, 1.000000e+00
%35 = fdiv double %29, %34
%36 = fmul double %27, %35
store double %36, double* %5
%37 = load double, double* %6
%38 = load double, double* %5
%39 = fadd double %37, %38
store double %39, double* %6
%40 = load double, double* %4
%41 = fadd double %40, 1.000000e+00
store double %41, double* %4
br label %45
42: ; preds = %17
%43 = load double, double* %4
%44 = fadd double %43, 1.000000e+00
store double %44, double* %4
br label %45
45: ; preds = %42, %20
br label %13
46: ; preds = %13
%47 = load double, double* %6
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), double %47)
%49 = load i32, i32* %1
ret i32 %49
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"X=\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"N=\00"
@.str.4 = [3 x i8] c"%f\00"
@str = [14 x i8] c"Enter N and x\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = bitcast double* %1 to i8*
%4 = bitcast double* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), double* %1)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), double* %2)
%10 = load double, double* %2
%11 = fcmp ult double %10, 0.000000e+00
br i1 %11, label %40, label %12
12: ; preds = %0, %35
%13 = phi double [ %36, %35 ], [ %10, %0 ]
%14 = phi double [ %37, %35 ], [ 0.000000e+00, %0 ]
%15 = phi double [ %38, %35 ], [ 0.000000e+00, %0 ]
%16 = fcmp une double %15, 0.000000e+00
br i1 %16, label %17, label %35
17: ; preds = %12
%18 = load double, double* %1
%19 = fmul double %15, %18
%20 = call double @sin(double %19)
%21 = call double @llvm.fmuladd.f64(double %15, double %15, double %15)
%22 = insertelement <2 x double> poison, double %15, i64 0
%23 = insertelement <2 x double> %22, double %21, i64 1
%24 = insertelement <2 x double> <double poison, double 1.000000e+00>, double %15, i64 0
%25 = fmul <2 x double> %23, %24
%26 = fadd <2 x double> %23, %24
%27 = shufflevector <2 x double> %25, <2 x double> %26, <2 x i32> <i32 0, i32 3>
%28 = insertelement <2 x double> <double 1.000000e+00, double poison>, double %20, i64 1
%29 = fdiv <2 x double> %28, %27
%30 = shufflevector <2 x double> %29, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%31 = fmul <2 x double> %29, %30
%32 = extractelement <2 x double> %31, i64 0
%33 = fadd double %14, %32
%34 = load double, double* %2
br label %35
35: ; preds = %12, %17
%36 = phi double [ %34, %17 ], [ %13, %12 ]
%37 = phi double [ %33, %17 ], [ %14, %12 ]
%38 = fadd double %15, 1.000000e+00
%39 = fcmp ugt double %38, %36
br i1 %39, label %40, label %12
40: ; preds = %35, %0
%41 = phi double [ 0.000000e+00, %0 ], [ %37, %35 ]
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), double %41)
ret i32 0
}