#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 myexp(int, int);
int /*<<< orphan*/ printf(char *, int, double);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int pot;
  int i;
  double tmp;
  double nv;
  double ov;
  scanf("%d", &pot);
  if (pot <= 1) {
    pot = 2;
  }
  ov = 0.0;
  nv = 0.0001;
  i = 1;
  while (nv - ov >= 0.0001) {
    tmp = 1 / myexp(i, pot);
    ov = nv;
    nv = nv + tmp;
    i = i + 1;
  }
  printf("%d\n%f\n", i, nv);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jg     1160 <main+0x30>
movl   $0x2,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe90(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x1,-0xc(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  0xe72(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11dd <main+0xad>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <myexp@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117c <main+0x4c>
mov    -0xc(%rbp),%esi
movsd  -0x20(%rbp),%xmm0
lea    0xe1f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
lea    0xed3(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
cmp    $0x1,%esi
jg     115d <main+0x2d>
movl   $0x2,0xc(%rsp)
mov    $0x2,%esi
mov    $0x1,%edi
call   1030 <myexp@plt>
lea    0x1(%rax),%ecx
xor    %ebp,%ebp
cmp    $0x3,%ecx
cmovae %ebp,%eax
cvtsi2sd %eax,%xmm2
movsd  0xe82(%rip),%xmm1
addsd  %xmm1,%xmm2
movsd  0xe7e(%rip),%xmm0
addsd  %xmm2,%xmm0
mov    $0x2,%ebx
ucomisd %xmm1,%xmm0
jae    119f <main+0x6f>
movapd %xmm2,%xmm0
jmp    11f4 <main+0xc4>
mov    $0x2,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm2,0x10(%rsp)
mov    0xc(%rsp),%esi
mov    %ebx,%edi
call   1030 <myexp@plt>
lea    0x1(%rax),%ecx
cmp    $0x3,%ecx
cmovae %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x10(%rsp),%xmm2
addsd  %xmm2,%xmm0
add    $0x1,%ebx
movapd %xmm0,%xmm1
subsd  %xmm2,%xmm1
ucomisd 0xe12(%rip),%xmm1
movapd %xmm0,%xmm2
jae    11b0 <main+0x80>
lea    0xe18(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [7 x i8] c"%d\0A%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 2
br i1 %5, label %6, label %7
6: ; preds = %0
store i32 2, i32* %1
br label %7
7: ; preds = %6, %0
%8 = phi i32 [ 2, %6 ], [ %4, %0 ]
%9 = call i32 @myexp(i32 1, i32 %8)
%10 = add i32 %9, 1
%11 = icmp ult i32 %10, 3
%12 = select i1 %11, i32 %9, i32 0
%13 = sitofp i32 %12 to double
%14 = fadd double %13, 1.000000e-04
%15 = fadd double %14, -1.000000e-04
%16 = fcmp ult double %15, 1.000000e-04
br i1 %16, label %30, label %17
17: ; preds = %7, %17
%18 = phi i32 [ %27, %17 ], [ 2, %7 ]
%19 = phi double [ %26, %17 ], [ %14, %7 ]
%20 = load i32, i32* %1
%21 = call i32 @myexp(i32 %18, i32 %20)
%22 = add i32 %21, 1
%23 = icmp ult i32 %22, 3
%24 = select i1 %23, i32 %21, i32 0
%25 = sitofp i32 %24 to double
%26 = fadd double %19, %25
%27 = add nuw nsw i32 %18, 1
%28 = fsub double %26, %19
%29 = fcmp ult double %28, 1.000000e-04
br i1 %29, label %30, label %17
30: ; preds = %17, %7
%31 = phi double [ %14, %7 ], [ %26, %17 ]
%32 = phi i32 [ 2, %7 ], [ %27, %17 ]
%33 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %32, double %31)
ret i32 0
}