#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 *, float *, float *);
main() {
  float s, n, k, x;
  s = 0.6;
  printf("input X and N\n");
  scanf("%f%f", &x, &n);
  if (x < 1 && x > -1)
    for (k = 1; k <= n; k++)
      s += (k * k * x * x - k * x + 2.0) / (k * x);
  printf("S= %f\n", s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xecd(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
movss  0xe9a(%rip),%xmm0
ucomiss -0x14(%rbp),%xmm0
jbe    122d <main+0x10d>
movss  -0x14(%rbp),%xmm0
movss  0xe8b(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    122d <main+0x10d>
movss  0xe72(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     1228 <main+0x108>
movss  -0x10(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
movss  -0x10(%rbp),%xmm1
mulss  -0x14(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe2b(%rip),%xmm0
addsd  %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  %xmm0,%xmm1
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xde7(%rip),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1193 <main+0x73>
jmp    122d <main+0x10d>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdef(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
lea    0xedc(%rip),%rdi
mov    %rsp,%rsi
lea    0x4(%rsp),%rdx
call   1050 <scanf@plt>
movss  (%rsp),%xmm1
movss  0xea2(%rip),%xmm2
ucomiss %xmm1,%xmm2
movsd  0xea7(%rip),%xmm0
jbe    11e6 <main+0xb6>
ucomiss 0xe92(%rip),%xmm1
jbe    11e6 <main+0xb6>
movss  0x4(%rsp),%xmm3
ucomiss 0xe7f(%rip),%xmm3
jb     11e6 <main+0xb6>
movss  0xe7d(%rip),%xmm4
movsd  0xe85(%rip),%xmm0
movaps %xmm2,%xmm5
cs nopw 0x0(%rax,%rax,1)
movaps %xmm5,%xmm6
mulss  %xmm5,%xmm6
mulss  %xmm1,%xmm6
movaps %xmm1,%xmm7
mulss  %xmm5,%xmm7
mulss  %xmm1,%xmm6
subss  %xmm7,%xmm6
cvtss2sd %xmm6,%xmm6
addsd  %xmm0,%xmm6
cvtss2sd %xmm7,%xmm7
divsd  %xmm7,%xmm6
cvtss2sd %xmm4,%xmm4
addsd  %xmm6,%xmm4
cvtsd2ss %xmm4,%xmm4
addss  %xmm2,%xmm5
ucomiss %xmm5,%xmm3
jae    11a0 <main+0x70>
xorps  %xmm0,%xmm0
cvtss2sd %xmm4,%xmm0
lea    0xe38(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%f%f\00"
@.str.2 = [7 x i8] c"S= %f\0A\00"
@str = [14 x i8] c"input X and N\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = bitcast float* %1 to i8*
%4 = bitcast float* %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 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), float* %2, float* %1)
%7 = load float, float* %2
%8 = fcmp olt float %7, 1.000000e+00
%9 = fcmp ogt float %7, -1.000000e+00
%10 = and i1 %8, %9
br i1 %10, label %11, label %33
11: ; preds = %0
%12 = load float, float* %1
%13 = fcmp ult float %12, 1.000000e+00
br i1 %13, label %33, label %14
14: ; preds = %11, %14
%15 = phi float [ %29, %14 ], [ 1.000000e+00, %11 ]
%16 = phi float [ %28, %14 ], [ 0x3FE3333340000000, %11 ]
%17 = fmul float %15, %15
%18 = fmul float %7, %17
%19 = fmul float %7, %15
%20 = fneg float %19
%21 = call float @llvm.fmuladd.f32(float %18, float %7, float %20)
%22 = fpext float %21 to double
%23 = fadd double %22, 2.000000e+00
%24 = fpext float %19 to double
%25 = fdiv double %23, %24
%26 = fpext float %16 to double
%27 = fadd double %25, %26
%28 = fptrunc double %27 to float
%29 = fadd float %15, 1.000000e+00
%30 = fcmp ugt float %29, %12
br i1 %30, label %31, label %14
31: ; preds = %14
%32 = fpext float %28 to double
br label %33
33: ; preds = %31, %11, %0
%34 = phi double [ 0x3FE3333340000000, %0 ], [ 0x3FE3333340000000, %11 ], [ %32, %31 ]
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %34)
ret i32 0
}