#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() {
  float s = 0, t;
  int i, x;
  do {
    printf("entre com o X: ");
    scanf("%d", &x);
  } while (x >= -20 && x <= -1);
  for (i = 1; i <= 20; i++) {
    t = 1 / (x + i);
    printf("%dº termo = %f \n", i, t);
    s = s + (1.0 / (float)(x + i));
  }
  printf("soma = %f\n", s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
xor    %eax,%eax
cmpl   $0xffffffec,-0x14(%rbp)
mov    %al,-0x15(%rbp)
jl     116e <main+0x4e>
cmpl   $0xffffffff,-0x14(%rbp)
setle  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1137 <main+0x17>
movl   $0x1,-0x10(%rbp)
cmpl   $0x14,-0x10(%rbp)
jg     11f9 <main+0xd9>
mov    -0x14(%rbp),%ecx
add    -0x10(%rbp),%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x10(%rbp),%esi
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe67(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x14(%rbp),%eax
add    -0x10(%rbp),%eax
cvtsi2ss %eax,%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xe26(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1180 <main+0x60>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe24(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xed5(%rip),%r14
lea    0xede(%rip),%r15
lea    0x4(%rsp),%rbx
nop
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0xffffffeb,%eax
ja     1140 <main+0x20>
xorps  %xmm0,%xmm0
mov    $0x1,%ebx
mov    $0x14,%r15d
mov    $0x2,%ebp
xor    %r12d,%r12d
lea    0xea0(%rip),%r14
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
lea    (%rax,%rbx,1),%ecx
add    %ebp,%eax
cmp    $0x3,%eax
cmovae %r12d,%ecx
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x4(%rsp),%eax
lea    (%rbx,%rax,1),%ecx
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe3d(%rip),%xmm1
divsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
add    $0x1,%ebx
cvtss2sd %xmm0,%xmm0
add    $0x1,%ebp
add    $0xffffffff,%r15d
jne    1180 <main+0x60>
lea    0xe42(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"entre com o X: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"%d\C2\BA termo = %f \0A\00"
@.str.3 = [11 x i8] c"soma = %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store float 0.000000e+00, float* %2
br label %6
6: ; preds = %15, %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
br label %9
9: ; preds = %6
%10 = load i32, i32* %5
%11 = icmp sge i32 %10, -20
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* %5
%14 = icmp sle i32 %13, -1
br label %15
15: ; preds = %12, %9
%16 = phi i1 [ false, %9 ], [ %14, %12 ]
br i1 %16, label %6, label %17
17: ; preds = %15
store i32 1, i32* %4
br label %18
18: ; preds = %41, %17
%19 = load i32, i32* %4
%20 = icmp sle i32 %19, 20
br i1 %20, label %21, label %44
21: ; preds = %18
%22 = load i32, i32* %5
%23 = load i32, i32* %4
%24 = add nsw i32 %22, %23
%25 = sdiv i32 1, %24
%26 = sitofp i32 %25 to float
store float %26, float* %3
%27 = load i32, i32* %4
%28 = load float, float* %3
%29 = fpext float %28 to double
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %27, double %29)
%31 = load float, float* %2
%32 = fpext float %31 to double
%33 = load i32, i32* %5
%34 = load i32, i32* %4
%35 = add nsw i32 %33, %34
%36 = sitofp i32 %35 to float
%37 = fpext float %36 to double
%38 = fdiv double 1.000000e+00, %37
%39 = fadd double %32, %38
%40 = fptrunc double %39 to float
store float %40, float* %2
br label %41
41: ; preds = %21
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
store i32 %43, i32* %4
br label %18
44: ; preds = %18
%45 = load float, float* %2
%46 = fpext float %45 to double
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), double %46)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"entre com o X: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"%d\C2\BA termo = %f \0A\00"
@.str.3 = [11 x i8] c"soma = %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 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* %1)
%6 = load i32, i32* %1
%7 = icmp ugt i32 %6, -21
br i1 %7, label %3, label %8
8: ; preds = %3, %8
%9 = phi i32 [ %19, %8 ], [ %6, %3 ]
%10 = phi i32 [ %26, %8 ], [ 1, %3 ]
%11 = phi double [ %27, %8 ], [ 0.000000e+00, %3 ]
%12 = add nsw i32 %9, %10
%13 = add i32 %12, 1
%14 = icmp ult i32 %13, 3
%15 = select i1 %14, i32 %12, i32 0
%16 = sitofp i32 %15 to float
%17 = fpext float %16 to double
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %10, double %17)
%19 = load i32, i32* %1
%20 = add nsw i32 %19, %10
%21 = sitofp i32 %20 to float
%22 = fpext float %21 to double
%23 = fdiv double 1.000000e+00, %22
%24 = fadd double %11, %23
%25 = fptrunc double %24 to float
%26 = add nuw nsw i32 %10, 1
%27 = fpext float %25 to double
%28 = icmp eq i32 %26, 21
br i1 %28, label %29, label %8
29: ; preds = %8
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), double %27)
ret i32 0
}