#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 *, float, ...);
int /*<<< orphan*/ scanf(char *, float *);
int main(int argc, const char *argv[]) {
  float n = 1, m = 1, i, elementos, soma, div;
  scanf("%f", &elementos);
  printf("S = %.0f/%.0f", n, m);
  div = n / m;
  soma = div;
  for (i = 1; i < elementos; i++) {
    n++;
    m += 2;
    div = n / m;
    soma += div;
    printf(" + %.0f/%.0f", n, m);
  }
  printf("\nSoma: %.2f\n", soma);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movss  0xec2(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xeb5(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
lea    0xeb1(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe96(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movss  -0x14(%rbp),%xmm0
divss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  0xe63(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm1
movss  -0x20(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    122a <main+0x10a>
movss  0xe43(%rip),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xe35(%rip),%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
divss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
addss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe0d(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movss  0xde5(%rip),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    11a2 <main+0x82>
movss  -0x24(%rbp),%xmm0
lea    0xdf0(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xf04(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
lea    0xef6(%rip),%rdi
movss  0xebb(%rip),%xmm0
movsd  0xebb(%rip),%xmm1
mov    $0x2,%al
call   1030 <printf@plt>
movss  0xea4(%rip),%xmm0
movss  0x4(%rsp),%xmm1
ucomiss %xmm0,%xmm1
jbe    11f2 <main+0xd2>
movaps 0xe9e(%rip),%xmm3
movss  0xe86(%rip),%xmm1
lea    0xec0(%rip),%rbx
movaps %xmm1,%xmm0
movaps %xmm1,%xmm2
nopw   0x0(%rax,%rax,1)
movss  %xmm2,0x8(%rsp)
addps  0xe83(%rip),%xmm3
movaps %xmm3,0x10(%rsp)
movaps %xmm3,%xmm2
shufps $0x55,%xmm3,%xmm2
movaps %xmm3,%xmm1
divss  %xmm2,%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,0xc(%rsp)
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
mov    %rbx,%rdi
movaps %xmm3,%xmm0
mov    $0x2,%al
call   1030 <printf@plt>
movss  0x8(%rsp),%xmm2
movaps 0x10(%rsp),%xmm3
movss  0xc(%rsp),%xmm0
addss  0xe19(%rip),%xmm2
movss  0x4(%rsp),%xmm1
ucomiss %xmm2,%xmm1
ja     1190 <main+0x70>
lea    0xe55(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%f\00"
@.str.1 = [14 x i8] c"S = %.0f/%.0f\00"
@.str.2 = [13 x i8] c" + %.0f/%.0f\00"
@.str.3 = [13 x i8] c"\0ASoma: %.2f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store float 1.000000e+00, float* %6
store float 1.000000e+00, float* %7
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %9)
%13 = load float, float* %6
%14 = load float, float* %7
%15 = fpext float %14 to double
%16 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), float %13, double %15)
%17 = load float, float* %6
%18 = load float, float* %7
%19 = fdiv float %17, %18
store float %19, float* %11
%20 = load float, float* %11
store float %20, float* %10
store float 1.000000e+00, float* %8
br label %21
21: ; preds = %40, %2
%22 = load float, float* %8
%23 = load float, float* %9
%24 = fcmp olt float %22, %23
br i1 %24, label %25, label %43
25: ; preds = %21
%26 = load float, float* %6
%27 = fadd float %26, 1.000000e+00
store float %27, float* %6
%28 = load float, float* %7
%29 = fadd float %28, 2.000000e+00
store float %29, float* %7
%30 = load float, float* %6
%31 = load float, float* %7
%32 = fdiv float %30, %31
store float %32, float* %11
%33 = load float, float* %11
%34 = load float, float* %10
%35 = fadd float %34, %33
store float %35, float* %10
%36 = load float, float* %6
%37 = load float, float* %7
%38 = fpext float %37 to double
%39 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), float %36, double %38)
br label %40
40: ; preds = %25
%41 = load float, float* %8
%42 = fadd float %41, 1.000000e+00
store float %42, float* %8
br label %21
43: ; preds = %21
%44 = load float, float* %10
%45 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), float %44)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%f\00"
@.str.1 = [14 x i8] c"S = %.0f/%.0f\00"
@.str.2 = [13 x i8] c" + %.0f/%.0f\00"
@.str.3 = [13 x i8] c"\0ASoma: %.2f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca float
%4 = bitcast float* %3 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %3)
%6 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), float 1.000000e+00, double 1.000000e+00)
%7 = load float, float* %3
%8 = fcmp ogt float %7, 1.000000e+00
br i1 %8, label %9, label %23
9: ; preds = %2, %9
%10 = phi float [ %17, %9 ], [ 1.000000e+00, %2 ]
%11 = phi float [ %20, %9 ], [ 1.000000e+00, %2 ]
%12 = phi <2 x float> [ %13, %9 ], [ <float 1.000000e+00, float 1.000000e+00>, %2 ]
%13 = fadd <2 x float> %12, <float 1.000000e+00, float 2.000000e+00>
%14 = extractelement <2 x float> %13, i64 0
%15 = extractelement <2 x float> %13, i64 1
%16 = fdiv float %14, %15
%17 = fadd float %10, %16
%18 = fpext float %15 to double
%19 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), float %14, double %18)
%20 = fadd float %11, 1.000000e+00
%21 = load float, float* %3
%22 = fcmp olt float %20, %21
br i1 %22, label %9, label %23
23: ; preds = %9, %2
%24 = phi float [ 1.000000e+00, %2 ], [ %17, %9 ]
%25 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), float %24)
ret i32 0
}