#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 *);
main() {
  float sum = 1, A;
  int K = 1;
  printf("Введите A:");
  scanf("%f", &A);
  if (A > 0) {
    while (sum + 1.0 / (K + 1.0) < A) {
      K++;
      sum += 1.0 / K;
    }
    sum -= 1.0 / K;
    printf("K=%d, Сумма=%f", K, sum);
  } else
    printf("A должен быть больше 0");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xec9(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    122f <main+0x10f>
jmp    1177 <main+0x57>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
cvtsi2sdl -0x10(%rbp),%xmm2
movsd  0xe7b(%rip),%xmm0
addsd  %xmm0,%xmm2
movsd  0xe6f(%rip),%xmm0
divsd  %xmm2,%xmm0
addsd  %xmm0,%xmm1
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    11e9 <main+0xc9>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  0xe3e(%rip),%xmm1
divsd  %xmm0,%xmm1
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1177 <main+0x57>
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  0xe12(%rip),%xmm1
divsd  %xmm0,%xmm1
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0x10(%rbp),%esi
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdff(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    123d <main+0x11d>
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeec(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf01(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
movss  0x4(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11ad <main+0x8d>
ucomiss 0xebb(%rip),%xmm0
jbe    11bd <main+0x9d>
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
mov    $0x1,%esi
movsd  0xe95(%rip),%xmm2
movapd %xmm2,%xmm0
nop
add    $0x1,%esi
xorps  %xmm3,%xmm3
cvtsi2sd %esi,%xmm3
movapd %xmm2,%xmm4
divsd  %xmm3,%xmm4
addsd  %xmm0,%xmm4
xorps  %xmm0,%xmm0
cvtsd2ss %xmm4,%xmm0
cvtss2sd %xmm0,%xmm0
movapd %xmm3,%xmm4
addsd  %xmm2,%xmm4
movapd %xmm2,%xmm5
divsd  %xmm4,%xmm5
addsd  %xmm0,%xmm5
ucomisd %xmm5,%xmm1
ja     1170 <main+0x50>
jmp    11ce <main+0xae>
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11f7 <main+0xd7>
movsd  0xe3b(%rip),%xmm0
mov    $0x1,%esi
movapd %xmm0,%xmm3
movsd  0xe32(%rip),%xmm1
divsd  %xmm3,%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe36(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"\D0\92\D0\B2\D0\B5\D0\B4\D0\B8\D1\82\D0\B5 A:\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [20 x i8] c"K=%d, \D0\A1\D1\83\D0\BC\D0\BC\D0\B0=%f\00"
@.str.3 = [39 x i8] c"A \D0\B4\D0\BE\D0\BB\D0\B6\D0\B5\D0\BD \D0\B1\D1\8B\D1\82\D1\8C \D0\B1\D0\BE\D0\BB\D1\8C\D1\88\D0\B5 0\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca i32
store i32 0, i32* %1
store float 1.000000e+00, float* %2
store i32 1, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%7 = load float, float* %3
%8 = fcmp ogt float %7, 0.000000e+00
br i1 %8, label %9, label %43
9: ; preds = %0
br label %10
10: ; preds = %21, %9
%11 = load float, float* %2
%12 = fpext float %11 to double
%13 = load i32, i32* %4
%14 = sitofp i32 %13 to double
%15 = fadd double %14, 1.000000e+00
%16 = fdiv double 1.000000e+00, %15
%17 = fadd double %12, %16
%18 = load float, float* %3
%19 = fpext float %18 to double
%20 = fcmp olt double %17, %19
br i1 %20, label %21, label %31
21: ; preds = %10
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
%24 = load i32, i32* %4
%25 = sitofp i32 %24 to double
%26 = fdiv double 1.000000e+00, %25
%27 = load float, float* %2
%28 = fpext float %27 to double
%29 = fadd double %28, %26
%30 = fptrunc double %29 to float
store float %30, float* %2
br label %10
31: ; preds = %10
%32 = load i32, i32* %4
%33 = sitofp i32 %32 to double
%34 = fdiv double 1.000000e+00, %33
%35 = load float, float* %2
%36 = fpext float %35 to double
%37 = fsub double %36, %34
%38 = fptrunc double %37 to float
store float %38, float* %2
%39 = load i32, i32* %4
%40 = load float, float* %2
%41 = fpext float %40 to double
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %39, double %41)
br label %45
43: ; preds = %0
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
br label %45
45: ; preds = %43, %31
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 A:\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [20 x i8] c"K=%d, \D0\A1\D1\83\D0\BC\D0\BC\D0\B0=%f\00"
@.str.3 = [39 x i8] c"A \D0\B4\D0\BE\D0\BB\D0\B6\D0\B5\D0\BD \D0\B1\D1\8B\D1\82\D1\8C \D0\B1\D0\BE\D0\BB\D1\8C\D1\88\D0\B5 0\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 ogt float %5, 0.000000e+00
br i1 %6, label %7, label %32
7: ; preds = %0
%8 = fpext float %5 to double
%9 = fcmp ogt float %5, 1.500000e+00
br i1 %9, label %10, label %23
10: ; preds = %7, %10
%11 = phi double [ %18, %10 ], [ 1.000000e+00, %7 ]
%12 = phi i32 [ %13, %10 ], [ 1, %7 ]
%13 = add nuw nsw i32 %12, 1
%14 = sitofp i32 %13 to double
%15 = fdiv double 1.000000e+00, %14
%16 = fadd double %11, %15
%17 = fptrunc double %16 to float
%18 = fpext float %17 to double
%19 = fadd double %14, 1.000000e+00
%20 = fdiv double 1.000000e+00, %19
%21 = fadd double %20, %18
%22 = fcmp olt double %21, %8
br i1 %22, label %10, label %23
23: ; preds = %10, %7
%24 = phi i32 [ 1, %7 ], [ %13, %10 ]
%25 = phi double [ 1.000000e+00, %7 ], [ %18, %10 ]
%26 = phi double [ 1.000000e+00, %7 ], [ %14, %10 ]
%27 = fdiv double 1.000000e+00, %26
%28 = fsub double %25, %27
%29 = fptrunc double %28 to float
%30 = fpext float %29 to double
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %24, double %30)
br label %34
32: ; preds = %0
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %32, %23
ret i32 0
}