#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);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, const char *argv[]) {
  int k, i;
  double s = 0;
  scanf("%d", &k);
  for (i = 1; s <= k; i++) {
    s += 1.0 / i;
  }
  printf("%d\n", --i);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm1
cvtsi2sdl -0x14(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1192 <main+0x72>
cvtsi2sdl -0x18(%rbp),%xmm1
movsd  0xe8a(%rip),%xmm0
divsd  %xmm1,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1155 <main+0x35>
mov    -0x18(%rbp),%esi
add    $0xffffffff,%esi
mov    %esi,-0x18(%rbp)
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee0(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
js     116e <main+0x4e>
cvtsi2sd %eax,%xmm0
xorpd  %xmm1,%xmm1
xor    %esi,%esi
movsd  0xeb4(%rip),%xmm2
nopl   0x0(%rax)
add    $0x1,%esi
xorps  %xmm3,%xmm3
cvtsi2sd %esi,%xmm3
movapd %xmm2,%xmm4
divsd  %xmm3,%xmm4
addsd  %xmm4,%xmm1
ucomisd %xmm1,%xmm0
jae    1150 <main+0x30>
jmp    1170 <main+0x50>
xor    %esi,%esi
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = load i32, i32* %3
%7 = sitofp i32 %6 to double
%8 = icmp slt i32 %6, 0
br i1 %8, label %17, label %9
9: ; preds = %2, %9
%10 = phi double [ %14, %9 ], [ 0.000000e+00, %2 ]
%11 = phi i32 [ %15, %9 ], [ 1, %2 ]
%12 = sitofp i32 %11 to double
%13 = fdiv double 1.000000e+00, %12
%14 = fadd double %10, %13
%15 = add nuw nsw i32 %11, 1
%16 = fcmp ugt double %14, %7
br i1 %16, label %17, label %9
17: ; preds = %9, %2
%18 = phi i32 [ 0, %2 ], [ %11, %9 ]
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
ret i32 0
}