#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 */
scalar_t__ f(double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
void main() {
  double inc, x = 0, res = 0, cont;
  printf("Introduzca un valor para x: ");
  scanf("%lf", &x);
  if (x >= 0) {
    inc = x / 10000;
    for (cont = 0; cont < x; cont += inc)
      res += f(cont);
  } else
    res = 0;
  printf("El resultado es:  %lf\n", res * inc);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec8(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11dc <main+0xac>
movsd  -0x10(%rbp),%xmm0
movsd  0xe7b(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11d7 <main+0xa7>
movsd  -0x20(%rbp),%xmm0
call   1030 <f@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1196 <main+0x66>
jmp    11e4 <main+0xb4>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
lea    0xe34(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
movq   $0x0,0x10(%rsp)
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed3(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1050 <scanf@plt>
movsd  0x10(%rsp),%xmm1
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
jb     11e1 <main+0xb1>
movapd %xmm1,%xmm0
divsd  0xe88(%rip),%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
jbe    11e1 <main+0xb1>
xorpd  %xmm1,%xmm1
xorpd  %xmm2,%xmm2
movsd  %xmm0,0x18(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm2,0x20(%rsp)
movapd %xmm1,%xmm0
call   1030 <f@plt>
movsd  0x20(%rsp),%xmm2
movsd  0x18(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
addsd  %xmm1,%xmm2
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm1
ucomisd 0x8(%rsp),%xmm1
movsd  0x8(%rsp),%xmm1
ja     1190 <main+0x60>
mulsd  %xmm2,%xmm0
lea    0xe3d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Introduzca un valor para x: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [23 x i8] c"El resultado es: %lf\0A\00"
define void @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
store double 0.000000e+00, double* %2
store double 0.000000e+00, double* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%7 = load double, double* %2
%8 = fcmp oge double %7, 0.000000e+00
br i1 %8, label %9, label %27
9: ; preds = %0
%10 = load double, double* %2
%11 = fdiv double %10, 1.000000e+04
store double %11, double* %1
store double 0.000000e+00, double* %4
br label %12
12: ; preds = %22, %9
%13 = load double, double* %4
%14 = load double, double* %2
%15 = fcmp olt double %13, %14
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = load double, double* %4
%18 = call i64 @f(double %17)
%19 = sitofp i64 %18 to double
%20 = load double, double* %3
%21 = fadd double %20, %19
store double %21, double* %3
br label %22
22: ; preds = %16
%23 = load double, double* %1
%24 = load double, double* %4
%25 = fadd double %24, %23
store double %25, double* %4
br label %12
26: ; preds = %12
br label %28
27: ; preds = %0
store double 0.000000e+00, double* %3
br label %28
28: ; preds = %27, %26
%29 = load double, double* %3
%30 = load double, double* %1
%31 = fmul double %29, %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %31)
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"Introduzca un valor para x: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [23 x i8] c"El resultado es: %lf\0A\00"
define void @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
store double 0.000000e+00, double* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%5 = load double, double* %1
%6 = fcmp ult double %5, 0.000000e+00
br i1 %6, label %19, label %7
7: ; preds = %0
%8 = fdiv double %5, 1.000000e+04
%9 = fcmp ogt double %5, 0.000000e+00
br i1 %9, label %10, label %19
10: ; preds = %7, %10
%11 = phi double [ %16, %10 ], [ 0.000000e+00, %7 ]
%12 = phi double [ %15, %10 ], [ 0.000000e+00, %7 ]
%13 = call i64 @f(double %11)
%14 = sitofp i64 %13 to double
%15 = fadd double %12, %14
%16 = fadd double %8, %11
%17 = load double, double* %1
%18 = fcmp olt double %16, %17
br i1 %18, label %10, label %19
19: ; preds = %10, %7, %0
%20 = phi double [ undef, %0 ], [ %8, %7 ], [ %8, %10 ]
%21 = phi double [ 0.000000e+00, %0 ], [ 0.000000e+00, %7 ], [ %15, %10 ]
%22 = fmul double %20, %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %22)
ret void
}