#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);
double rnd(long *);
long time(int /*<<< orphan*/ *);
int DentroEsfera(const int total) {
  long random = time(NULL);
  int i, dentro = 0;
  double x, y, z;
  for (i = 1; i <= total; i++) {
    printf("Realizando cálculos... %d\r", i);
    x = rnd(&random);
    y = rnd(&random);
    z = rnd(&random);
    if (x * x + y * y + z * z <= 1)
      dentro = dentro + 1;
  }
  return dentro;
}


x86 assembly (clang, -O0):
<DentroEsfera>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11f7 <DentroEsfera+0xc7>
mov    -0x14(%rbp),%esi
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
lea    -0x10(%rbp),%rdi
call   1040 <rnd@plt>
movsd  %xmm0,-0x20(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <rnd@plt>
movsd  %xmm0,-0x28(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <rnd@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe2f(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     11e4 <DentroEsfera+0xb4>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e9 <DentroEsfera+0xb9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1156 <DentroEsfera+0x26>
mov    -0x18(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DentroEsfera>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %edi,%r14d
xor    %r12d,%r12d
xor    %edi,%edi
call   1050 <time@plt>
mov    %rax,0x18(%rsp)
test   %r14d,%r14d
jle    11e1 <DentroEsfera+0xb1>
neg    %r14d
xor    %r12d,%r12d
mov    $0x1,%ebx
lea    0xe9e(%rip),%r15
lea    0x18(%rsp),%r13
nop
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %r13,%rdi
call   1040 <rnd@plt>
movsd  %xmm0,0x10(%rsp)
mov    %r13,%rdi
call   1040 <rnd@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r13,%rdi
call   1040 <rnd@plt>
movsd  0x8(%rsp),%xmm2
mulsd  %xmm2,%xmm2
movsd  0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe3a(%rip),%xmm1
ucomisd %xmm0,%xmm1
sbb    $0xffffffff,%r12d
lea    (%r14,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1170 <DentroEsfera+0x40>
mov    %r12d,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Realizando c\C3\A1lculos... %d\0D\00"
define i32 @DentroEsfera(i32 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
store i32 %0, i32* %2
%9 = call i64 @time(i32* null)
store i64 %9, i64* %3
store i32 0, i32* %5
store i32 1, i32* %4
br label %10
10: ; preds = %34, %1
%11 = load i32, i32* %4
%12 = load i32, i32* %2
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %37
14: ; preds = %10
%15 = load i32, i32* %4
%16 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = call double @rnd(i64* %3)
store double %17, double* %6
%18 = call double @rnd(i64* %3)
store double %18, double* %7
%19 = call double @rnd(i64* %3)
store double %19, double* %8
%20 = load double, double* %6
%21 = load double, double* %6
%22 = load double, double* %7
%23 = load double, double* %7
%24 = fmul double %22, %23
%25 = call double @llvm.fmuladd.f64(double %20, double %21, double %24)
%26 = load double, double* %8
%27 = load double, double* %8
%28 = call double @llvm.fmuladd.f64(double %26, double %27, double %25)
%29 = fcmp ole double %28, 1.000000e+00
br i1 %29, label %30, label %33
30: ; preds = %14
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %33
33: ; preds = %30, %14
br label %34
34: ; preds = %33
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %10
37: ; preds = %10
%38 = load i32, i32* %5
ret i32 %38
}

LLVM IR (-O2):
@.str = [28 x i8] c"Realizando c\C3\A1lculos... %d\0D\00"
define i32 @DentroEsfera(i32 %0) {
%2 = alloca i64
%3 = bitcast i64* %2 to i8*
%4 = tail call i64 @time(i32* null)
store i64 %4, i64* %2
%5 = icmp slt i32 %0, 1
br i1 %5, label %21, label %6
6: ; preds = %1, %6
%7 = phi i32 [ %19, %6 ], [ 1, %1 ]
%8 = phi i32 [ %18, %6 ], [ 0, %1 ]
%9 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %7)
%10 = call double @rnd(i64* %2)
%11 = call double @rnd(i64* %2)
%12 = call double @rnd(i64* %2)
%13 = fmul double %11, %11
%14 = call double @llvm.fmuladd.f64(double %10, double %10, double %13)
%15 = call double @llvm.fmuladd.f64(double %12, double %12, double %14)
%16 = fcmp ole double %15, 1.000000e+00
%17 = zext i1 %16 to i32
%18 = add nuw nsw i32 %8, %17
%19 = add nuw i32 %7, 1
%20 = icmp eq i32 %7, %0
br i1 %20, label %21, label %6
21: ; preds = %6, %1
%22 = phi i32 [ 0, %1 ], [ %18, %6 ]
ret i32 %22
}