#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 fabs(float);
int pow(float, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *, float *, float *);
int /*<<< orphan*/ system(char *);
int main() {
  float x, a, e;
  int k = 0, f = 1;
  printf("Vvedit x,a,e -> ");
  scanf("%f%f%f", &x, &a, &e);
  float previous = 0, suma = 0, current = 0;
  do {
    previous = current;
    k++;
    current = (1 / pow(a + x, k)) / (pow(a, 2 * k) + f);
    suma += current;
    f *= k;
  } while (fabs(previous - current) >= e);
  printf("Suma: %f, dodankiv: %d", suma, k);
  system("PAUSE");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8f(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1060 <scanf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
addss  -0x8(%rbp),%xmm0
mov    -0x14(%rbp),%edi
call   1070 <pow@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
movss  -0xc(%rbp),%xmm0
mov    -0x14(%rbp),%edi
shl    $0x1,%edi
call   1070 <pow@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    -0x18(%rbp),%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
movss  -0x1c(%rbp),%xmm0
subss  -0x24(%rbp),%xmm0
call   1050 <fabs@plt>
ucomiss -0x10(%rbp),%xmm0
jae    11ab <main+0x5b>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x14(%rbp),%esi
lea    0xdd2(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xddb(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xebd(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
lea    0xc(%rsp),%rsi
mov    %rsp,%rdx
lea    0x8(%rsp),%rcx
call   1050 <scanf@plt>
xorps  %xmm1,%xmm1
mov    $0x1,%r12d
mov    $0x2,%r14d
xor    %ebx,%ebx
xorps  %xmm0,%xmm0
nopw   0x0(%rax,%rax,1)
movaps %xmm0,0x10(%rsp)
movss  %xmm1,0x4(%rsp)
add    $0x1,%ebx
movss  (%rsp),%xmm0
addss  0xc(%rsp),%xmm0
mov    %ebx,%edi
call   1060 <pow@plt>
mov    %eax,%ebp
lea    0x1(%rbp),%eax
cmp    $0x3,%eax
cmovae %r15d,%ebp
movss  (%rsp),%xmm0
mov    %r14d,%edi
call   1060 <pow@plt>
movss  0x4(%rsp),%xmm1
mov    %eax,%ecx
add    %r12d,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  %xmm0,%xmm1
imul   %ebx,%r12d
movaps 0x10(%rsp),%xmm2
subss  %xmm0,%xmm2
andps  0xe08(%rip),%xmm2
add    $0x2,%r14d
ucomiss 0x8(%rsp),%xmm2
jae    1190 <main+0x50>
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xe17(%rip),%rdi
mov    %ebx,%esi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe1e(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Vvedit x,a,e -> \00"
@.str.1 = [7 x i8] c"%f%f%f\00"
@.str.2 = [23 x i8] c"Suma: %f, dodankiv: %d\00"
@.str.3 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
%8 = alloca float
%9 = alloca float
store i32 0, i32* %1
store i32 0, i32* %5
store i32 1, i32* %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), float* %2, float* %3, float* %4)
store float 0.000000e+00, float* %7
store float 0.000000e+00, float* %8
store float 0.000000e+00, float* %9
br label %12
12: ; preds = %36, %0
%13 = load float, float* %9
store float %13, float* %7
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 1
store i32 %15, i32* %5
%16 = load float, float* %3
%17 = load float, float* %2
%18 = fadd float %16, %17
%19 = load i32, i32* %5
%20 = call i32 @pow(float %18, i32 %19)
%21 = sdiv i32 1, %20
%22 = load float, float* %3
%23 = load i32, i32* %5
%24 = mul nsw i32 2, %23
%25 = call i32 @pow(float %22, i32 %24)
%26 = load i32, i32* %6
%27 = add nsw i32 %25, %26
%28 = sdiv i32 %21, %27
%29 = sitofp i32 %28 to float
store float %29, float* %9
%30 = load float, float* %9
%31 = load float, float* %8
%32 = fadd float %31, %30
store float %32, float* %8
%33 = load i32, i32* %5
%34 = load i32, i32* %6
%35 = mul nsw i32 %34, %33
store i32 %35, i32* %6
br label %36
36: ; preds = %12
%37 = load float, float* %7
%38 = load float, float* %9
%39 = fsub float %37, %38
%40 = call float @fabs(float %39)
%41 = load float, float* %4
%42 = fcmp oge float %40, %41
br i1 %42, label %12, label %43
43: ; preds = %36
%44 = load float, float* %8
%45 = fpext float %44 to double
%46 = load i32, i32* %5
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %45, i32 %46)
%48 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Vvedit x,a,e -> \00"
@.str.1 = [7 x i8] c"%f%f%f\00"
@.str.2 = [23 x i8] c"Suma: %f, dodankiv: %d\00"
@.str.3 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), float* %1, float* %2, float* %3)
br label %9
9: ; preds = %9, %0
%10 = phi i32 [ 0, %0 ], [ %14, %9 ]
%11 = phi i32 [ 1, %0 ], [ %29, %9 ]
%12 = phi float [ 0.000000e+00, %0 ], [ %28, %9 ]
%13 = phi float [ 0.000000e+00, %0 ], [ %27, %9 ]
%14 = add nuw nsw i32 %10, 1
%15 = load float, float* %2
%16 = load float, float* %1
%17 = fadd float %15, %16
%18 = call i32 @pow(float %17, i32 %14)
%19 = add i32 %18, 1
%20 = icmp ult i32 %19, 3
%21 = select i1 %20, i32 %18, i32 0
%22 = load float, float* %2
%23 = shl nuw nsw i32 %14, 1
%24 = call i32 @pow(float %22, i32 %23)
%25 = add nsw i32 %24, %11
%26 = sdiv i32 %21, %25
%27 = sitofp i32 %26 to float
%28 = fadd float %12, %27
%29 = mul nsw i32 %11, %14
%30 = fsub float %13, %27
%31 = call float @llvm.fabs.f32(float %30)
%32 = load float, float* %3
%33 = fcmp ult float %31, %32
br i1 %33, label %34, label %9
34: ; preds = %9
%35 = fpext float %28 to double
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %35, i32 %14)
%37 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}