#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
main() {
  int K = 1;
  float e, A1 = 0, A2 = 2;
  printf("Введите e:");
  scanf("%f", &e);
  A1 = 0;
  A2 = 2;
  K = 1;
  while (fabs(A2 - A1) >= e) {
    A1 = A2;
    A2 = 2 + 1 / A1;
    K++;
  }
  printf("K=%d\n", K);
  printf("A(K-1)=%f, A(K)=%f", A1, A2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xeaa(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xe77(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movl   $0x1,-0x8(%rbp)
movss  -0x14(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
call   1040 <fabs@plt>
ucomiss -0xc(%rbp),%xmm0
jb     11e4 <main+0xb4>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xe44(%rip),%xmm1
divss  -0x10(%rbp),%xmm1
movss  0xe33(%rip),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1195 <main+0x65>
mov    -0x8(%rbp),%esi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe12(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xef5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf0f(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
movss  0xc(%rsp),%xmm0
movss  0xeb7(%rip),%xmm1
ucomiss %xmm0,%xmm1
jae    1174 <main+0x54>
movsd  0xea2(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
mov    $0x1,%esi
jmp    11c3 <main+0xa3>
mov    $0x1,%esi
movss  0xe8b(%rip),%xmm2
movaps 0xe88(%rip),%xmm3
movaps %xmm1,%xmm4
nopl   0x0(%rax,%rax,1)
movaps %xmm4,%xmm6
movaps %xmm2,%xmm4
divss  %xmm6,%xmm4
addss  %xmm1,%xmm4
add    $0x1,%esi
movaps %xmm4,%xmm5
subss  %xmm6,%xmm5
andps  %xmm3,%xmm5
ucomiss %xmm0,%xmm5
jae    1190 <main+0x70>
xorps  %xmm0,%xmm0
cvtss2sd %xmm4,%xmm0
movsd  %xmm0,0x10(%rsp)
movss  %xmm6,0x8(%rsp)
lea    0xe68(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe56(%rip),%rdi
movsd  0x10(%rsp),%xmm1
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"\D0\92\D0\B2\D0\B5\D0\B4\D0\B8\D1\82\D0\B5 e:\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [6 x i8] c"K=%d\0A\00"
@.str.3 = [19 x i8] c"A(K-1)=%f, A(K)=%f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
store i32 1, i32* %2
store float 0.000000e+00, float* %4
store float 2.000000e+00, float* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
store float 0.000000e+00, float* %4
store float 2.000000e+00, float* %5
store i32 1, i32* %2
br label %8
8: ; preds = %15, %0
%9 = load float, float* %5
%10 = load float, float* %4
%11 = fsub float %9, %10
%12 = call float @fabs(float %11)
%13 = load float, float* %3
%14 = fcmp oge float %12, %13
br i1 %14, label %15, label %22
15: ; preds = %8
%16 = load float, float* %5
store float %16, float* %4
%17 = load float, float* %4
%18 = fdiv float 1.000000e+00, %17
%19 = fadd float 2.000000e+00, %18
store float %19, float* %5
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %8
22: ; preds = %8
%23 = load i32, i32* %2
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = load float, float* %4
%26 = fpext float %25 to double
%27 = load float, float* %5
%28 = fpext float %27 to double
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), double %26, double %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"\D0\92\D0\B2\D0\B5\D0\B4\D0\B8\D1\82\D0\B5 e:\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [6 x i8] c"K=%d\0A\00"
@.str.3 = [19 x i8] c"A(K-1)=%f, A(K)=%f\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%5 = load float, float* %1
%6 = fcmp ugt float %5, 2.000000e+00
br i1 %6, label %18, label %7
7: ; preds = %0, %7
%8 = phi float [ %11, %7 ], [ 2.000000e+00, %0 ]
%9 = phi i32 [ %12, %7 ], [ 1, %0 ]
%10 = fdiv float 1.000000e+00, %8
%11 = fadd float %10, 2.000000e+00
%12 = add nuw nsw i32 %9, 1
%13 = fsub float %11, %8
%14 = call float @llvm.fabs.f32(float %13)
%15 = fcmp ult float %14, %5
br i1 %15, label %16, label %7
16: ; preds = %7
%17 = fpext float %11 to double
br label %18
18: ; preds = %16, %0
%19 = phi i32 [ 1, %0 ], [ %12, %16 ]
%20 = phi float [ 0.000000e+00, %0 ], [ %8, %16 ]
%21 = phi double [ 2.000000e+00, %0 ], [ %17, %16 ]
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%23 = fpext float %20 to double
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), double %23, double %21)
ret i32 0
}