#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;
  printf("Vvedit x,a,e -> ");
  scanf("%f%f%f", &x, &a, &e);
  float previous = 0, suma = 0, current = 0;
  int first = 1, k = 0, f = 1;
  while (fabs(previous - current) >= e || first == 1) {
    previous = current;
    k++;
    current = (1 / pow(a + x, k)) / (pow(a, 2 * k) + f);
    suma += current;
    f *= k;
    first = 0;
  };
  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)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9d(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1060 <scanf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
movss  -0x14(%rbp),%xmm0
subss  -0x1c(%rbp),%xmm0
call   1050 <fabs@plt>
mov    $0x1,%al
ucomiss -0x10(%rbp),%xmm0
mov    %al,-0x29(%rbp)
jae    11da <main+0x8a>
cmpl   $0x1,-0x20(%rbp)
sete   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11ea <main+0x9a>
jmp    1265 <main+0x115>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movss  -0xc(%rbp),%xmm0
addss  -0x8(%rbp),%xmm0
mov    -0x24(%rbp),%edi
call   1070 <pow@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
mov    %eax,-0x30(%rbp)
movss  -0xc(%rbp),%xmm0
mov    -0x24(%rbp),%edi
shl    $0x1,%edi
call   1070 <pow@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    -0x28(%rbp),%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x24(%rbp),%eax
imul   -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x20(%rbp)
jmp    11b2 <main+0x62>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x24(%rbp),%esi
lea    0xda0(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xda9(%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    $0x30,%rsp
lea    0xebd(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x4(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1050 <scanf@plt>
xorps  %xmm0,%xmm0
mov    $0x1,%r12d
mov    $0x2,%r14d
xor    %ebx,%ebx
xorps  %xmm1,%xmm1
nopl   0x0(%rax)
movaps %xmm0,0x10(%rsp)
movaps %xmm1,0x20(%rsp)
add    $0x1,%ebx
movss  0x4(%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  0x4(%rsp),%xmm0
mov    %r14d,%edi
call   1060 <pow@plt>
movaps 0x20(%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    $0x30,%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 float
%6 = alloca float
%7 = alloca float
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%12 = 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* %5
store float 0.000000e+00, float* %6
store float 0.000000e+00, float* %7
store i32 1, i32* %8
store i32 0, i32* %9
store i32 1, i32* %10
br label %13
13: ; preds = %25, %0
%14 = load float, float* %5
%15 = load float, float* %7
%16 = fsub float %14, %15
%17 = call float @fabs(float %16)
%18 = load float, float* %4
%19 = fcmp oge float %17, %18
br i1 %19, label %23, label %20
20: ; preds = %13
%21 = load i32, i32* %8
%22 = icmp eq i32 %21, 1
br label %23
23: ; preds = %20, %13
%24 = phi i1 [ true, %13 ], [ %22, %20 ]
br i1 %24, label %25, label %49
25: ; preds = %23
%26 = load float, float* %7
store float %26, float* %5
%27 = load i32, i32* %9
%28 = add nsw i32 %27, 1
store i32 %28, i32* %9
%29 = load float, float* %3
%30 = load float, float* %2
%31 = fadd float %29, %30
%32 = load i32, i32* %9
%33 = call i32 @pow(float %31, i32 %32)
%34 = sdiv i32 1, %33
%35 = load float, float* %3
%36 = load i32, i32* %9
%37 = mul nsw i32 2, %36
%38 = call i32 @pow(float %35, i32 %37)
%39 = load i32, i32* %10
%40 = add nsw i32 %38, %39
%41 = sdiv i32 %34, %40
%42 = sitofp i32 %41 to float
store float %42, float* %7
%43 = load float, float* %7
%44 = load float, float* %6
%45 = fadd float %44, %43
store float %45, float* %6
%46 = load i32, i32* %9
%47 = load i32, i32* %10
%48 = mul nsw i32 %47, %46
store i32 %48, i32* %10
store i32 0, i32* %8
br label %13
49: ; preds = %23
%50 = load float, float* %6
%51 = fpext float %50 to double
%52 = load i32, i32* %9
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %51, i32 %52)
%54 = 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 = %0, %9
%10 = phi i32 [ 1, %0 ], [ %29, %9 ]
%11 = phi i32 [ 0, %0 ], [ %14, %9 ]
%12 = phi float [ 0.000000e+00, %0 ], [ %27, %9 ]
%13 = phi float [ 0.000000e+00, %0 ], [ %28, %9 ]
%14 = add nuw nsw i32 %11, 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, %10
%26 = sdiv i32 %21, %25
%27 = sitofp i32 %26 to float
%28 = fadd float %13, %27
%29 = mul nsw i32 %10, %14
%30 = fsub float %12, %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
}