#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 num;
  float i = 2, n_harm = 1;
  printf("Ingrese un numero natural: ");
  scanf("%d", &num);
  while (i <= num) {
    n_harm = n_harm + 1 / i;
    ++i;
  }
  printf("El %d-esimo numero armonico es: %.3f", num, n_harm);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xecd(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xebc(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0xc(%rbp),%xmm1
cvtsi2ssl -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     11ac <main+0x8c>
movss  -0x10(%rbp),%xmm0
movss  0xe79(%rip),%xmm1
divss  -0xc(%rbp),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xe63(%rip),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    1167 <main+0x47>
mov    -0x8(%rbp),%esi
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe68(%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    0xef6(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
cmp    $0x2,%esi
jge    1153 <main+0x33>
movsd  0xeaf(%rip),%xmm0
jmp    118b <main+0x6b>
cvtsi2ss %esi,%xmm0
movss  0xea9(%rip),%xmm1
movss  0xea5(%rip),%xmm3
movaps %xmm3,%xmm2
nopw   0x0(%rax,%rax,1)
movaps %xmm3,%xmm4
divss  %xmm1,%xmm4
addss  %xmm4,%xmm2
addss  %xmm3,%xmm1
ucomiss %xmm1,%xmm0
jae    1170 <main+0x50>
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
lea    0xe9d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Ingrese un numero natural: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [37 x i8] c"El %d-esimo numero armonico es: %.3f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
store i32 0, i32* %1
store float 2.000000e+00, float* %3
store float 1.000000e+00, float* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 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), i32* %2)
br label %7
7: ; preds = %12, %0
%8 = load float, float* %3
%9 = load i32, i32* %2
%10 = sitofp i32 %9 to float
%11 = fcmp ole float %8, %10
br i1 %11, label %12, label %19
12: ; preds = %7
%13 = load float, float* %4
%14 = load float, float* %3
%15 = fdiv float 1.000000e+00, %14
%16 = fadd float %13, %15
store float %16, float* %4
%17 = load float, float* %3
%18 = fadd float %17, 1.000000e+00
store float %18, float* %3
br label %7
19: ; preds = %7
%20 = load i32, i32* %2
%21 = load float, float* %4
%22 = fpext float %21 to double
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %20, double %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"Ingrese un numero natural: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [37 x i8] c"El %d-esimo numero armonico es: %.3f\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 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 = sitofp i32 %5 to float
%7 = icmp slt i32 %5, 2
br i1 %7, label %17, label %8
8: ; preds = %0, %8
%9 = phi float [ %12, %8 ], [ 1.000000e+00, %0 ]
%10 = phi float [ %13, %8 ], [ 2.000000e+00, %0 ]
%11 = fdiv float 1.000000e+00, %10
%12 = fadd float %9, %11
%13 = fadd float %10, 1.000000e+00
%14 = fcmp ugt float %13, %6
br i1 %14, label %15, label %8
15: ; preds = %8
%16 = fpext float %12 to double
br label %17
17: ; preds = %15, %0
%18 = phi double [ 1.000000e+00, %0 ], [ %16, %15 ]
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %5, double %18)
ret i32 0
}