#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 *, int *);
int main() {
  int n;
  float t;
  printf("Enter the value of N: ");
  scanf("%d", &n);
  while (n >= 1)
    t += 1 / (float)(n--);
  printf("Sum of the series is: %f\n", t);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jl     1181 <main+0x61>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cvtsi2ss %eax,%xmm1
movss  0xe92(%rip),%xmm0
divss  %xmm1,%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    114d <main+0x2d>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe8d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%ecx
lea    -0x1(%rcx),%eax
test   $0x1,%cl
cmove  %ecx,%eax
cmp    $0x1,%ecx
jne    115c <main+0x3c>
movsd  0xea6(%rip),%xmm0
jmp    11a6 <main+0x86>
movss  0xea4(%rip),%xmm1
movss  0xea0(%rip),%xmm0
nopl   0x0(%rax)
xorps  %xmm2,%xmm2
cvtsi2ss %eax,%xmm2
movaps %xmm0,%xmm3
divss  %xmm2,%xmm3
addss  %xmm1,%xmm3
lea    -0x1(%rax),%ecx
xorps  %xmm2,%xmm2
cvtsi2ss %ecx,%xmm2
movaps %xmm0,%xmm1
divss  %xmm2,%xmm1
addss  %xmm3,%xmm1
add    $0xfffffffe,%eax
cmp    $0x1,%ecx
ja     1170 <main+0x50>
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movl   $0x0,0x4(%rsp)
lea    0xe75(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Enter the value of N: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"Sum of the series is: %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %6
6: ; preds = %9, %0
%7 = load i32, i32* %2
%8 = icmp sge i32 %7, 1
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i32, i32* %2
%11 = add nsw i32 %10, -1
store i32 %11, i32* %2
%12 = sitofp i32 %10 to float
%13 = fdiv float 1.000000e+00, %12
%14 = load float, float* %3
%15 = fadd float %14, %13
store float %15, float* %3
br label %6
16: ; preds = %6
%17 = load float, float* %3
%18 = fpext float %17 to double
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), double %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Enter the value of N: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"Sum of the series is: %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 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), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
%7 = and i32 %5, 1
%8 = icmp eq i32 %7, 0
%9 = add nsw i32 %5, -1
%10 = select i1 %8, i32 %5, i32 %9
%11 = icmp eq i32 %5, 1
br i1 %11, label %26, label %12
12: ; preds = %0, %12
%13 = phi float [ %22, %12 ], [ 0x7FF8000000000000, %0 ]
%14 = phi i32 [ %19, %12 ], [ %10, %0 ]
%15 = add nsw i32 %14, -1
%16 = sitofp i32 %14 to float
%17 = fdiv float 1.000000e+00, %16
%18 = fadd float %13, %17
%19 = add nsw i32 %14, -2
%20 = sitofp i32 %15 to float
%21 = fdiv float 1.000000e+00, %20
%22 = fadd float %18, %21
%23 = icmp ugt i32 %15, 1
br i1 %23, label %12, label %24
24: ; preds = %12
%25 = fpext float %22 to double
br label %26
26: ; preds = %0, %24
%27 = phi double [ 0x7FF8000000000000, %0 ], [ %25, %24 ]
store i32 0, i32* %1
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), double %27)
ret i32 0
}