#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*/ getch();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int numero;
  double soma, divisor;
  soma = 0.0;
  printf("Quer saber mais sobre a serie Harmonica?\nDigite um numero e te "
         "daremos o valor da soma da sequencia\n\nLembrando que a Sequencia "
         "Harmonica e dada por 1/1 + 1/2 + 1/3 + ... + 1/N\nSendo N o numero "
         "fornecido por voce!\n\n");
  scanf("%d", &numero);
  while (numero <= 0) {
    printf("Digite um numero valido (maior que 0)!");
    scanf("%d", &numero);
  }
  for (divisor = 1; divisor <= numero; divisor++) {
    soma = soma + (1 / divisor);
  }
  printf("A soma e %f", soma);
  getch();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf83(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jg     1192 <main+0x62>
lea    0xf6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf5b(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1165 <main+0x35>
movsd  0xe66(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm1
cvtsi2sdl -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     11e5 <main+0xb5>
movsd  -0x10(%rbp),%xmm0
movsd  0xe40(%rip),%xmm1
divsd  -0x18(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe2a(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    119f <main+0x6f>
movsd  -0x10(%rbp),%xmm0
lea    0xf18(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getch@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeee(%rip),%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jg     11ad <main+0x6d>
lea    0xe96(%rip),%r14
lea    0xe8c(%rip),%r15
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1190 <main+0x50>
cvtsi2sd %eax,%xmm1
xorpd  %xmm0,%xmm0
movsd  0xe43(%rip),%xmm2
movapd %xmm2,%xmm3
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movapd %xmm2,%xmm4
divsd  %xmm3,%xmm4
addsd  %xmm4,%xmm0
addsd  %xmm2,%xmm3
ucomisd %xmm3,%xmm1
jae    11d0 <main+0x90>
lea    0xe45(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getch@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [215 x i8] c"Quer saber mais sobre a serie Harmonica?\0ADigite um numero e te daremos o valor da soma da sequencia\0A\0ALembrando que a Sequencia Harmonica e dada por 1/1 + 1/2 + 1/3 + ... + 1/N\0ASendo N o numero fornecido por voce!\0A\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [39 x i8] c"Digite um numero valido (maior que 0)!\00"
@.str.3 = [12 x i8] c"A soma e %f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([215 x i8], [215 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 sle i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %7
13: ; preds = %7
store double 1.000000e+00, double* %4
br label %14
14: ; preds = %24, %13
%15 = load double, double* %4
%16 = load i32, i32* %2
%17 = sitofp i32 %16 to double
%18 = fcmp ole double %15, %17
br i1 %18, label %19, label %27
19: ; preds = %14
%20 = load double, double* %3
%21 = load double, double* %4
%22 = fdiv double 1.000000e+00, %21
%23 = fadd double %20, %22
store double %23, double* %3
br label %24
24: ; preds = %19
%25 = load double, double* %4
%26 = fadd double %25, 1.000000e+00
store double %26, double* %4
br label %14
27: ; preds = %14
%28 = load double, double* %3
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %28)
%30 = call i32 (...) @getch()
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [39 x i8] c"Digite um numero valido (maior que 0)!\00"
@.str.3 = [12 x i8] c"A soma e %f\00"
@str = [214 x i8] c"Quer saber mais sobre a serie Harmonica?\0ADigite um numero e te daremos o valor da soma da sequencia\0A\0ALembrando que a Sequencia Harmonica e dada por 1/1 + 1/2 + 1/3 + ... + 1/N\0ASendo N o numero fornecido por voce!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([214 x i8], [214 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 slt i32 %5, 1
br i1 %6, label %10, label %7
7: ; preds = %10, %0
%8 = phi i32 [ %5, %0 ], [ %13, %10 ]
%9 = sitofp i32 %8 to double
br label %15
10: ; preds = %0, %10
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%13 = load i32, i32* %1
%14 = icmp slt i32 %13, 1
br i1 %14, label %10, label %7
15: ; preds = %7, %15
%16 = phi double [ %20, %15 ], [ 1.000000e+00, %7 ]
%17 = phi double [ %19, %15 ], [ 0.000000e+00, %7 ]
%18 = fdiv double 1.000000e+00, %16
%19 = fadd double %17, %18
%20 = fadd double %16, 1.000000e+00
%21 = fcmp ugt double %20, %9
br i1 %21, label %22, label %15
22: ; preds = %15
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %19)
%24 = call i32 (...) @getch()
ret i32 0
}