#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__ RAND_MAX;
double pow(double, double);
scalar_t__ rand();
void sequential(int n, int *circle_count) {
  int i;
  *circle_count = 0;
  for (i = 0; i < n; i++) {
    double x, y;
    x = (double)rand() / ((double)RAND_MAX + 1.0e0);
    y = (double)rand() / ((double)RAND_MAX + 1.0e0);
    if ((pow(x, 2.0) + pow(y, 2.0)) < 1.0)
      (*circle_count)++;
  }
  return;
}


x86 assembly (clang, -O0):
<sequential>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1208 <sequential+0xe8>
mov    $0x0,%al
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e89(%rip),%rax
cvtsi2sdq (%rax),%xmm1
movsd  0xe94(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e5c(%rip),%rax
cvtsi2sdq (%rax),%xmm1
movsd  0xe67(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe55(%rip),%xmm1
call   1030 <pow@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe3e(%rip),%xmm1
call   1030 <pow@plt>
movsd  -0x30(%rbp),%xmm1
addsd  %xmm0,%xmm1
movsd  0xe20(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11f5 <sequential+0xd5>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    11fa <sequential+0xda>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1140 <sequential+0x20>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sequential>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,(%rsi)
test   %edi,%edi
jle    11b7 <sequential+0xa7>
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x2eb6(%rip),%rbx
jmp    1145 <sequential+0x35>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0xffffffff,%ebp
je     11b7 <sequential+0xa7>
xor    %eax,%eax
call   1030 <rand@plt>
xorps  %xmm2,%xmm2
cvtsi2sd %rax,%xmm2
xorps  %xmm0,%xmm0
cvtsi2sdq (%rbx),%xmm0
movsd  0xe9c(%rip),%xmm1
addsd  %xmm1,%xmm0
divsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
xor    %eax,%eax
call   1030 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq (%rbx),%xmm1
movsd  0xe6f(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
jbe    1140 <sequential+0x30>
addl   $0x1,(%r14)
jmp    1140 <sequential+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global i64 0
define void @sequential(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca double
%7 = alloca double
store i32 %0, i32* %3
store i32* %1, i32** %4
%8 = load i32*, i32** %4
store i32 0, i32* %8
store i32 0, i32* %5
br label %9
9: ; preds = %37, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %3
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %40
13: ; preds = %9
%14 = call i64 (...) @rand()
%15 = sitofp i64 %14 to double
%16 = load i64, i64* @RAND_MAX
%17 = sitofp i64 %16 to double
%18 = fadd double %17, 1.000000e+00
%19 = fdiv double %15, %18
store double %19, double* %6
%20 = call i64 (...) @rand()
%21 = sitofp i64 %20 to double
%22 = load i64, i64* @RAND_MAX
%23 = sitofp i64 %22 to double
%24 = fadd double %23, 1.000000e+00
%25 = fdiv double %21, %24
store double %25, double* %7
%26 = load double, double* %6
%27 = call double @pow(double %26, double 2.000000e+00)
%28 = load double, double* %7
%29 = call double @pow(double %28, double 2.000000e+00)
%30 = fadd double %27, %29
%31 = fcmp olt double %30, 1.000000e+00
br i1 %31, label %32, label %36
32: ; preds = %13
%33 = load i32*, i32** %4
%34 = load i32, i32* %33
%35 = add nsw i32 %34, 1
store i32 %35, i32* %33
br label %36
36: ; preds = %32, %13
br label %37
37: ; preds = %36
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %9
40: ; preds = %9
ret void
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
define void @sequential(i32 %0, i32* nocapture %1) {
store i32 0, i32* %1
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %28
4: ; preds = %2, %25
%5 = phi i32 [ %26, %25 ], [ 0, %2 ]
%6 = tail call i64 (...) @rand()
%7 = sitofp i64 %6 to double
%8 = load i64, i64* @RAND_MAX
%9 = sitofp i64 %8 to double
%10 = fadd double %9, 1.000000e+00
%11 = fdiv double %7, %10
%12 = tail call i64 (...) @rand()
%13 = sitofp i64 %12 to double
%14 = load i64, i64* @RAND_MAX
%15 = sitofp i64 %14 to double
%16 = fadd double %15, 1.000000e+00
%17 = fdiv double %13, %16
%18 = fmul double %11, %11
%19 = fmul double %17, %17
%20 = fadd double %18, %19
%21 = fcmp olt double %20, 1.000000e+00
br i1 %21, label %22, label %25
22: ; preds = %4
%23 = load i32, i32* %1
%24 = add nsw i32 %23, 1
store i32 %24, i32* %1
br label %25
25: ; preds = %22, %4
%26 = add nuw nsw i32 %5, 1
%27 = icmp eq i32 %26, %0
br i1 %27, label %28, label %4
28: ; preds = %25, %2
ret void
}