#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(void) {
  int n;
  float soma = 0, cont = 1;
  printf("Digite um numero inteiro:\n");
  scanf("%d", &n);
  while (n > 0) {
    soma = soma + (cont / n);
    n--;
    cont++;
  }
  printf("O valor da soma eh %.2f.\n", soma);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xec1(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    11a8 <main+0x88>
movss  -0xc(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
cvtsi2ssl -0x8(%rbp),%xmm2
divss  %xmm2,%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
movss  0xe67(%rip),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1162 <main+0x42>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe6a(%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    0xeed(%rip),%rdi
call   1030 <puts@plt>
lea    0xec4(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%ecx
test   %ecx,%ecx
jle    116f <main+0x3f>
test   $0x1,%cl
jne    1174 <main+0x44>
xorps  %xmm0,%xmm0
movss  0xe9a(%rip),%xmm1
mov    %ecx,%eax
cmp    $0x1,%ecx
jne    119b <main+0x6b>
jmp    11e7 <main+0xb7>
xorps  %xmm0,%xmm0
jmp    11f3 <main+0xc3>
cvtsi2ss %ecx,%xmm0
movss  0xe80(%rip),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
addss  %xmm1,%xmm0
lea    -0x1(%rcx),%eax
movss  0xe6e(%rip),%xmm1
cmp    $0x1,%ecx
je     11e7 <main+0xb7>
movss  0xe5d(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xorps  %xmm3,%xmm3
cvtsi2ss %eax,%xmm3
movaps %xmm1,%xmm4
divss  %xmm3,%xmm4
addss  %xmm0,%xmm4
addss  %xmm2,%xmm1
lea    -0x1(%rax),%ecx
xorps  %xmm3,%xmm3
cvtsi2ss %ecx,%xmm3
movaps %xmm1,%xmm0
divss  %xmm3,%xmm0
addss  %xmm4,%xmm0
addss  %xmm2,%xmm1
add    $0xfffffffe,%eax
cmp    $0x1,%ecx
ja     11b0 <main+0x80>
movl   $0x0,0x4(%rsp)
cvtss2sd %xmm0,%xmm0
lea    0xe11(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Digite um numero inteiro:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"O valor da soma eh %.2f.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %3
store float 1.000000e+00, float* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 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 = %10, %0
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %7
%11 = load float, float* %3
%12 = load float, float* %4
%13 = load i32, i32* %2
%14 = sitofp i32 %13 to float
%15 = fdiv float %12, %14
%16 = fadd float %11, %15
store float %16, float* %3
%17 = load i32, i32* %2
%18 = add nsw i32 %17, -1
store i32 %18, i32* %2
%19 = load float, float* %4
%20 = fadd float %19, 1.000000e+00
store float %20, float* %4
br label %7
21: ; preds = %7
%22 = load float, float* %3
%23 = fpext float %22 to double
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), double %23)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"O valor da soma eh %.2f.\0A\00"
@str = [26 x i8] c"Digite um numero inteiro:\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 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
br i1 %6, label %7, label %39
7: ; preds = %0
%8 = and i32 %5, 1
%9 = icmp eq i32 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %7
%11 = sitofp i32 %5 to float
%12 = fdiv float 1.000000e+00, %11
%13 = fadd float %12, 0.000000e+00
%14 = add nsw i32 %5, -1
br label %15
15: ; preds = %10, %7
%16 = phi float [ 1.000000e+00, %7 ], [ 2.000000e+00, %10 ]
%17 = phi float [ 0.000000e+00, %7 ], [ %13, %10 ]
%18 = phi i32 [ %5, %7 ], [ %14, %10 ]
%19 = phi float [ undef, %7 ], [ %13, %10 ]
%20 = icmp eq i32 %5, 1
br i1 %20, label %36, label %21
21: ; preds = %15, %21
%22 = phi float [ %34, %21 ], [ %16, %15 ]
%23 = phi float [ %32, %21 ], [ %17, %15 ]
%24 = phi i32 [ %33, %21 ], [ %18, %15 ]
%25 = sitofp i32 %24 to float
%26 = fdiv float %22, %25
%27 = fadd float %23, %26
%28 = add nsw i32 %24, -1
%29 = fadd float %22, 1.000000e+00
%30 = sitofp i32 %28 to float
%31 = fdiv float %29, %30
%32 = fadd float %27, %31
%33 = add nsw i32 %24, -2
%34 = fadd float %29, 1.000000e+00
%35 = icmp ugt i32 %28, 1
br i1 %35, label %21, label %36
36: ; preds = %21, %15
%37 = phi float [ %19, %15 ], [ %32, %21 ]
store i32 0, i32* %1
%38 = fpext float %37 to double
br label %39
39: ; preds = %36, %0
%40 = phi double [ %38, %36 ], [ 0.000000e+00, %0 ]
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), double %40)
ret i32 0
}