#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 argc, const char *argv[]) {
  int tam;
  float termo, h, i;
  printf("Digite a quantidade de termos\n");
  scanf("%d", &tam);
  h = 0;
  for (i = 0; i < tam; i++) {
    termo = 1 / (i + 1);
    h = h + termo;
  }
  printf("O valor de h e: %f\n", h);
  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)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm1
cvtsi2ssl -0x14(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11bb <main+0x9b>
movss  0xe81(%rip),%xmm1
addss  -0x20(%rbp),%xmm1
movss  0xe74(%rip),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x1c(%rbp),%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xe54(%rip),%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    1164 <main+0x44>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe5b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
lea    0xec0(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    118d <main+0x5d>
cvtsi2ss %eax,%xmm0
xorps  %xmm1,%xmm1
movss  0xe9b(%rip),%xmm2
xorps  %xmm3,%xmm3
nopl   0x0(%rax,%rax,1)
addss  %xmm2,%xmm1
movaps %xmm2,%xmm4
divss  %xmm1,%xmm4
addss  %xmm4,%xmm3
ucomiss %xmm1,%xmm0
ja     1170 <main+0x40>
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
jmp    1190 <main+0x60>
xorps  %xmm0,%xmm0
lea    0xe70(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"O valor de h e: %f\0A\00"
@str = [30 x i8] c"Digite a quantidade de termos\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 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* %3)
%7 = load i32, i32* %3
%8 = sitofp i32 %7 to float
%9 = icmp sgt i32 %7, 0
br i1 %9, label %10, label %19
10: ; preds = %2, %10
%11 = phi float [ %13, %10 ], [ 0.000000e+00, %2 ]
%12 = phi float [ %15, %10 ], [ 0.000000e+00, %2 ]
%13 = fadd float %11, 1.000000e+00
%14 = fdiv float 1.000000e+00, %13
%15 = fadd float %12, %14
%16 = fcmp olt float %13, %8
br i1 %16, label %10, label %17
17: ; preds = %10
%18 = fpext float %15 to double
br label %19
19: ; preds = %17, %2
%20 = phi double [ 0.000000e+00, %2 ], [ %18, %17 ]
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %20)
ret i32 0
}