#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, double, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
double unif(double, double);
int main(int argc, char *argv[]) {
  int i = 0;
  int N;
  double sim_x;
  double sim_y;
  double sim_z;
  double sim;
  double a_x, a_y, a_z;
  double b_x, b_y, b_z;
  printf("\nCalculamos el integral de x+y+z con MC \n\n");
  printf("Entrar la primer limita del integral para x: a_x=");
  scanf("%lf", &a_x);
  printf("Entrar la segunda limita del integral para x: b_x= ");
  scanf("%lf", &b_x);
  printf("Entrar la primer limita del integral para y: a_y=");
  scanf("%lf", &a_y);
  printf("Entrar la segunda limita del integral para y: b_y= ");
  scanf("%lf", &b_y);
  printf("Entrar la primer limita del integral para z: a_z=");
  scanf("%lf", &a_z);
  printf("Entrar la segunda limita del integral para z: b_z= ");
  scanf("%lf", &b_z);
  printf("Entar el numero de simulacion : N=");
  scanf("%d", &N);
  srand(time(NULL));
  for (i = 0; i < N; i++) {
    sim_x = unif(a_x, b_x);
    sim_y = unif(a_y, b_y);
    sim_z = unif(a_z, b_z);
    sim += f(sim_x, sim_y, sim_z);
    ;
  }
  printf("Integral de x+y+z:%1.4f\n",
         (b_x - a_x) * (b_y - a_y) * (b_z - a_z) * (1 / (double)N) * sim);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec5(%rip),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea5(%rip),%rdi
lea    -0x58(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe85(%rip),%rdi
lea    -0x48(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe65(%rip),%rdi
lea    -0x60(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    0xef1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe45(%rip),%rdi
lea    -0x50(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    0xf03(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe25(%rip),%rdi
lea    -0x68(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    0xf17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf2c(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    12fb <main+0x19b>
movsd  -0x40(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
call   1060 <unif@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
call   1060 <unif@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
call   1060 <unif@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
call   1030 <f@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1282 <main+0x122>
movsd  -0x58(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
subsd  -0x48(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x68(%rbp),%xmm1
subsd  -0x50(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x18(%rbp),%xmm2
movsd  0xcd2(%rip),%xmm1
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x38(%rbp),%xmm0
lea    0xe4d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x58,%rsp
lea    0xfff(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7e(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea0(%rip),%r14
lea    0x38(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
lea    0xe8e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x20(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x30(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
lea    0xeba(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x18(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
lea    0xed1(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x28(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
lea    0xee6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
lea    0xefd(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf12(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    12f6 <main+0x186>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm3,0x50(%rsp)
movsd  0x38(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1070 <unif@plt>
movsd  %xmm0,0x48(%rsp)
movsd  0x30(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
call   1070 <unif@plt>
movsd  %xmm0,0x40(%rsp)
movsd  0x28(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1070 <unif@plt>
movaps %xmm0,%xmm2
movsd  0x48(%rsp),%xmm0
movsd  0x40(%rsp),%xmm1
call   1040 <f@plt>
movsd  0x50(%rsp),%xmm3
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  %xmm0,%xmm3
add    $0x1,%ebx
mov    0xc(%rsp),%eax
cmp    %eax,%ebx
jl     1280 <main+0x110>
movsd  0x20(%rsp),%xmm0
subsd  0x38(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
subsd  0x30(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
subsd  0x28(%rsp),%xmm2
mulsd  %xmm0,%xmm1
mulsd  %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0xccf(%rip),%xmm0
divsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm3,%xmm0
lea    0xe20(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [43 x i8] c"\0ACalculamos el integral de x+y+z con MC \0A\0A\00"
@.str.1 = [50 x i8] c"Entrar la primer limita del integral para x: a_x=\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [52 x i8] c"Entrar la segunda limita del integral para x: b_x= \00"
@.str.4 = [50 x i8] c"Entrar la primer limita del integral para y: a_y=\00"
@.str.5 = [52 x i8] c"Entrar la segunda limita del integral para y: b_y= \00"
@.str.6 = [50 x i8] c"Entrar la primer limita del integral para z: a_z=\00"
@.str.7 = [52 x i8] c"Entrar la segunda limita del integral para z: b_z= \00"
@.str.8 = [35 x i8] c"Entar el numero de simulacion : N=\00"
@.str.9 = [3 x i8] c"%d\00"
@.str.10 = [25 x i8] c"Integral de x+y+z:%1.4f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %12)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %15)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %13)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0))
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %16)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0))
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %14)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0))
%30 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %17)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0))
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %7)
%33 = call i32 @time(i32* null)
%34 = call i32 @srand(i32 %33)
store i32 0, i32* %6
br label %35
35: ; preds = %56, %2
%36 = load i32, i32* %6
%37 = load i32, i32* %7
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %59
39: ; preds = %35
%40 = load double, double* %12
%41 = load double, double* %15
%42 = call double @unif(double %40, double %41)
store double %42, double* %8
%43 = load double, double* %13
%44 = load double, double* %16
%45 = call double @unif(double %43, double %44)
store double %45, double* %9
%46 = load double, double* %14
%47 = load double, double* %17
%48 = call double @unif(double %46, double %47)
store double %48, double* %10
%49 = load double, double* %8
%50 = load double, double* %9
%51 = load double, double* %10
%52 = call i64 @f(double %49, double %50, double %51)
%53 = sitofp i64 %52 to double
%54 = load double, double* %11
%55 = fadd double %54, %53
store double %55, double* %11
br label %56
56: ; preds = %39
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
store i32 %58, i32* %6
br label %35
59: ; preds = %35
%60 = load double, double* %15
%61 = load double, double* %12
%62 = fsub double %60, %61
%63 = load double, double* %16
%64 = load double, double* %13
%65 = fsub double %63, %64
%66 = fmul double %62, %65
%67 = load double, double* %17
%68 = load double, double* %14
%69 = fsub double %67, %68
%70 = fmul double %66, %69
%71 = load i32, i32* %7
%72 = sitofp i32 %71 to double
%73 = fdiv double 1.000000e+00, %72
%74 = fmul double %70, %73
%75 = load double, double* %11
%76 = fmul double %74, %75
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), double %76)
%78 = load i32, i32* %3
ret i32 %78
}

LLVM IR (-O2):
@.str.1 = [50 x i8] c"Entrar la primer limita del integral para x: a_x=\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [52 x i8] c"Entrar la segunda limita del integral para x: b_x= \00"
@.str.4 = [50 x i8] c"Entrar la primer limita del integral para y: a_y=\00"
@.str.5 = [52 x i8] c"Entrar la segunda limita del integral para y: b_y= \00"
@.str.6 = [50 x i8] c"Entrar la primer limita del integral para z: a_z=\00"
@.str.7 = [52 x i8] c"Entrar la segunda limita del integral para z: b_z= \00"
@.str.8 = [35 x i8] c"Entar el numero de simulacion : N=\00"
@.str.9 = [3 x i8] c"%d\00"
@.str.10 = [25 x i8] c"Integral de x+y+z:%1.4f\0A\00"
@str = [42 x i8] c"\0ACalculamos el integral de x+y+z con MC \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = bitcast i32* %3 to i8*
%11 = bitcast double* %4 to i8*
%12 = bitcast double* %5 to i8*
%13 = bitcast double* %6 to i8*
%14 = bitcast double* %7 to i8*
%15 = bitcast double* %8 to i8*
%16 = bitcast double* %9 to i8*
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %4)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %7)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %5)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0))
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %8)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0))
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %6)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0))
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %9)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0))
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %3)
%32 = call i32 @time(i32* null)
%33 = call i32 @srand(i32 %32)
%34 = load i32, i32* %3
%35 = icmp sgt i32 %34, 0
br i1 %35, label %36, label %54
36: ; preds = %2, %36
%37 = phi double [ %50, %36 ], [ undef, %2 ]
%38 = phi i32 [ %51, %36 ], [ 0, %2 ]
%39 = load double, double* %4
%40 = load double, double* %7
%41 = call double @unif(double %39, double %40)
%42 = load double, double* %5
%43 = load double, double* %8
%44 = call double @unif(double %42, double %43)
%45 = load double, double* %6
%46 = load double, double* %9
%47 = call double @unif(double %45, double %46)
%48 = call i64 @f(double %41, double %44, double %47)
%49 = sitofp i64 %48 to double
%50 = fadd double %37, %49
%51 = add nuw nsw i32 %38, 1
%52 = load i32, i32* %3
%53 = icmp slt i32 %51, %52
br i1 %53, label %36, label %54
54: ; preds = %36, %2
%55 = phi double [ undef, %2 ], [ %50, %36 ]
%56 = phi i32 [ %34, %2 ], [ %52, %36 ]
%57 = load double, double* %7
%58 = load double, double* %4
%59 = fsub double %57, %58
%60 = load double, double* %8
%61 = load double, double* %5
%62 = fsub double %60, %61
%63 = fmul double %59, %62
%64 = load double, double* %9
%65 = load double, double* %6
%66 = fsub double %64, %65
%67 = fmul double %63, %66
%68 = sitofp i32 %56 to double
%69 = fdiv double 1.000000e+00, %68
%70 = fmul double %69, %67
%71 = fmul double %55, %70
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), double %71)
ret i32 0
}