main() {
  int a, b = 0;
  float x = 0, y = 0, sum = 0;
  printf("      b\n");
  printf("    -----\n");
  printf("    \\        1           Introduzca las variables\n");
  printf("     \\    -------\n");
  printf("     /     x + ay         para evaluar esta serie:\n");
  printf("    /\n");
  printf("    -----\n");
  printf("    a = 0\n");
  printf("\n");
  printf("b = ");
  scanf("%d", &b);
  printf("x = ");
  scanf("%f", &x);
  printf("y = ");
  scanf("%f", &y);
  for (a = 0; a <= b; a++) {
    if ((x + a * y) == 0)
      printf("*** El denominador de la división ha dado 0 ***"), exit(-1);
    sum += 1 / (x + a * y);
  }
  printf("El resultado es = %g", sum);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea0(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe80(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     12cb <main+0x19b>
movss  -0x10(%rbp),%xmm1
cvtsi2ssl -0x8(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1290 <main+0x160>
jp     1290 <main+0x160>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
movss  -0x10(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
movss  -0x14(%rbp),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  0xd51(%rip),%xmm0
divss  %xmm1,%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1243 <main+0x113>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe0f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xeea(%rip),%rdi
call   1040 <puts@plt>
lea    0xf63(%rip),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xed7(%rip),%rdi
call   1040 <puts@plt>
lea    0xefd(%rip),%rdi
call   1040 <puts@plt>
lea    0xf03(%rip),%rdi
call   1040 <puts@plt>
lea    0xf2a(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xf26(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe26(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe1b(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe0b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe02(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xdef(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x14(%rsp),%eax
test   %eax,%eax
js     1291 <main+0x141>
movss  0x10(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
add    $0x1,%eax
xorps  %xmm2,%xmm2
movss  0xda3(%rip),%xmm4
xorps  %xmm3,%xmm3
xorps  %xmm5,%xmm5
cvtsi2ss %ebp,%xmm5
mulss  %xmm1,%xmm5
addss  %xmm0,%xmm5
ucomiss %xmm2,%xmm5
jne    1276 <main+0x126>
jnp    12ab <main+0x15b>
movaps %xmm4,%xmm6
divss  %xmm5,%xmm6
addss  %xmm6,%xmm3
add    $0x1,%ebp
cmp    %ebp,%eax
jne    1260 <main+0x110>
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
jmp    1294 <main+0x144>
xorps  %xmm0,%xmm0
lea    0xdaf(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xd67(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c" b\0A\00"
@.str.1 = [11 x i8] c" -----\0A\00"
@.str.2 = [51 x i8] c" \\ 1 Introduzca las variables\0A\00"
@.str.3 = [19 x i8] c" \\ -------\0A\00"
@.str.4 = [52 x i8] c" / x + ay para evaluar esta serie:\0A\00"
@.str.5 = [7 x i8] c" /\0A\00"
@.str.6 = [11 x i8] c" a = 0\0A\00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [5 x i8] c"b = \00"
@.str.9 = [3 x i8] c"%d\00"
@.str.10 = [5 x i8] c"x = \00"
@.str.11 = [3 x i8] c"%f\00"
@.str.12 = [5 x i8] c"y = \00"
@.str.13 = [49 x i8] c"*** El denominador de la divisi\C3\B3n ha dado 0 ***\00"
@.str.14 = [21 x i8] c"El resultado es = %g\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
store i32 0, i32* %3
store float 0.000000e+00, float* %4
store float 0.000000e+00, float* %5
store float 0.000000e+00, float* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %3)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), float* %4)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), float* %5)
store i32 0, i32* %2
br label %22
22: ; preds = %44, %0
%23 = load i32, i32* %2
%24 = load i32, i32* %3
%25 = icmp sle i32 %23, %24
br i1 %25, label %26, label %47
26: ; preds = %22
%27 = load float, float* %4
%28 = load i32, i32* %2
%29 = sitofp i32 %28 to float
%30 = load float, float* %5
%31 = call float @llvm.fmuladd.f32(float %29, float %30, float %27)
%32 = fcmp oeq float %31, 0.000000e+00
br i1 %32, label %33, label %35
33: ; preds = %26
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.13, i64 0, i64 0))
unreachable
35: ; preds = %26
%36 = load float, float* %4
%37 = load i32, i32* %2
%38 = sitofp i32 %37 to float
%39 = load float, float* %5
%40 = call float @llvm.fmuladd.f32(float %38, float %39, float %36)
%41 = fdiv float 1.000000e+00, %40
%42 = load float, float* %6
%43 = fadd float %42, %41
store float %43, float* %6
br label %44
44: ; preds = %35
%45 = load i32, i32* %2
%46 = add nsw i32 %45, 1
store i32 %46, i32* %2
br label %22
47: ; preds = %22
%48 = load float, float* %6
%49 = fpext float %48 to double
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.14, i64 0, i64 0), double %49)
%51 = load i32, i32* %1
ret i32 %51
}

LLVM IR (-O2):
@.str.8 = [5 x i8] c"b = \00"
@.str.9 = [3 x i8] c"%d\00"
@.str.10 = [5 x i8] c"x = \00"
@.str.11 = [3 x i8] c"%f\00"
@.str.12 = [5 x i8] c"y = \00"
@.str.13 = [49 x i8] c"*** El denominador de la divisi\C3\B3n ha dado 0 ***\00"
@.str.14 = [21 x i8] c"El resultado es = %g\00"
@str = [8 x i8] c" b\00"
@str.16 = [50 x i8] c" \\ 1 Introduzca las variables\00"
@str.17 = [18 x i8] c" \\ -------\00"
@str.18 = [51 x i8] c" / x + ay para evaluar esta serie:\00"
@str.19 = [6 x i8] c" /\00"
@str.20 = [10 x i8] c" -----\00"
@str.21 = [10 x i8] c" a = 0\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%5 = bitcast float* %2 to i8*
store float 0.000000e+00, float* %2
%6 = bitcast float* %3 to i8*
store float 0.000000e+00, float* %3
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.20, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.16, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.17, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.18, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.19, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.20, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.21, i64 0, i64 0))
%15 = tail call i32 @putchar(i32 10)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %1)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), float* %2)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), float* %3)
%22 = load i32, i32* %1
%23 = icmp slt i32 %22, 0
br i1 %23, label %42, label %24
24: ; preds = %0
%25 = load float, float* %2
%26 = load float, float* %3
br label %27
27: ; preds = %24, %35
%28 = phi float [ 0.000000e+00, %24 ], [ %37, %35 ]
%29 = phi i32 [ 0, %24 ], [ %38, %35 ]
%30 = sitofp i32 %29 to float
%31 = call float @llvm.fmuladd.f32(float %30, float %26, float %25)
%32 = fcmp oeq float %31, 0.000000e+00
br i1 %32, label %33, label %35
33: ; preds = %27
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.13, i64 0, i64 0))
unreachable
35: ; preds = %27
%36 = fdiv float 1.000000e+00, %31
%37 = fadd float %28, %36
%38 = add nuw i32 %29, 1
%39 = icmp eq i32 %29, %22
br i1 %39, label %40, label %27
40: ; preds = %35
%41 = fpext float %37 to double
br label %42
42: ; preds = %40, %0
%43 = phi double [ 0.000000e+00, %0 ], [ %41, %40 ]
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.14, i64 0, i64 0), double %43)
ret i32 0
}