#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*/ myadd(float *, float *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  float ztot, yran, ymult, ymod, x, y, z, pi, prod;
  long int low, ixran, itot, j, iprod;
  printf("Starting PI...\n");
  ztot = 0.0;
  low = 1;
  ixran = 1907;
  yran = 5813.0;
  ymult = 1307.0;
  ymod = 5471.0;
  itot = 40000000;
  for (j = 1; j <= itot; j++) {
    iprod = 27611 * ixran;
    ixran = iprod - 74383 * (long int)(iprod / 74383);
    x = (float)ixran / 74383.0;
    prod = ymult * yran;
    yran = (prod - ymod * (long int)(prod / ymod));
    y = yran / ymod;
    z = x * x + y * y;
    myadd(&ztot, &z);
    if (z <= 1.0) {
      low = low + 1;
    }
  }
  printf(" x = %9.6f    y = %12.2f  low = %8d j = %7d\n", x, y, (int)low,
         (int)j);
  pi = 4.0 * (float)low / (float)itot;
  printf("Pi = %9.6f ztot = %12.2f itot = %8d\n", pi, ztot * 0.0, (int)itot);
  return 0;
}


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)
lea    0xeeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movq   $0x1,-0x40(%rbp)
movq   $0x773,-0x48(%rbp)
movss  0xea4(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xe93(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xe82(%rip),%xmm0
movss  %xmm0,-0x20(%rbp)
movq   $0x2625a00,-0x50(%rbp)
02
movq   $0x1,-0x58(%rbp)
mov    -0x58(%rbp),%rax
cmp    -0x50(%rbp),%rax
jg     12b8 <main+0x198>
imul   $0x6bdb,-0x48(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x60(%rbp),%rax
mov    $0x1228f,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x68(%rbp),%rax
imul   $0x1228f,%rcx,%rcx
sub    %rcx,%rax
mov    %rax,-0x48(%rbp)
cvtsi2ssq -0x48(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe36(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x1c(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm1
movss  -0x20(%rbp),%xmm0
movss  -0x34(%rbp),%xmm2
divss  -0x20(%rbp),%xmm2
cvttss2si %xmm2,%rax
cvtsi2ss %rax,%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
divss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x24(%rbp),%xmm0
movss  -0x24(%rbp),%xmm2
movss  -0x28(%rbp),%xmm1
mulss  -0x28(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
lea    -0x14(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
call   1040 <myadd@plt>
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xd8c(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     12a2 <main+0x182>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    12a7 <main+0x187>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    1193 <main+0x73>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x28(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mov    -0x40(%rbp),%rax
mov    %eax,%esi
mov    -0x58(%rbp),%rax
mov    %eax,%edx
lea    0xd5b(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
cvtsi2ssq -0x40(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xd1a(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2ssq -0x50(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
xorps  %xmm2,%xmm2
mulsd  %xmm2,%xmm1
mov    -0x50(%rbp),%rax
mov    %eax,%esi
lea    0xd2e(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xf35(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,0x8(%rsp)
mov    $0x1,%r14d
mov    $0x773,%ebx
movss  0xe9b(%rip),%xmm1
mov    $0x2625a00,%r13d
movabs $0x70c69fd2bc475a2b,%rbp
9f c6 70
lea    0x8(%rsp),%r15
lea    0x4(%rsp),%r12
nop
imul   $0x6bdb,%rbx,%rbx
mov    %rbx,%rax
imul   %rbp
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0xf,%rdx
add    %rax,%rdx
imul   $0x1228f,%rdx,%rax
sub    %rax,%rbx
xorps  %xmm3,%xmm3
cvtsi2ss %rbx,%xmm3
mulss  0xe53(%rip),%xmm1
movaps %xmm1,%xmm0
movss  0xe4c(%rip),%xmm2
divss  %xmm2,%xmm0
cvttss2si %xmm0,%rax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
divss  0xe2b(%rip),%xmm3
mulss  0xe2f(%rip),%xmm0
addss  %xmm0,%xmm1
movss  %xmm1,0x14(%rsp)
movaps %xmm1,%xmm0
divss  %xmm2,%xmm0
movss  %xmm0,0xc(%rsp)
mulss  %xmm0,%xmm0
movss  %xmm3,0x10(%rsp)
movaps %xmm3,%xmm1
mulss  %xmm3,%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <myadd@plt>
movss  0x14(%rsp),%xmm1
movss  0xde8(%rip),%xmm0
ucomiss 0x4(%rsp),%xmm0
sbb    $0xffffffffffffffff,%r14
add    $0xffffffffffffffff,%r13
jne    1180 <main+0x50>
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0xc(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdce(%rip),%rdi
mov    %r14d,%esi
mov    $0x2625a01,%edx
mov    $0x2,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %r14,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xd9b(%rip),%xmm0
divsd  0xd9b(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x8(%rsp),%xmm1
xorps  %xmm2,%xmm2
cvtss2sd %xmm1,%xmm2
xorps  %xmm1,%xmm1
mulsd  %xmm2,%xmm1
lea    0xdad(%rip),%rdi
mov    $0x2625a00,%esi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Starting PI...\0A\00"
@.str.1 = [45 x i8] c" x = %9.6f y = %12.2f low = %8d j = %7d\0A\00"
@.str.2 = [37 x i8] c"Pi = %9.6f ztot = %12.2f itot = %8d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca i64
%16 = alloca i64
%17 = alloca i64
%18 = alloca i64
%19 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store float 0.000000e+00, float* %6
store i64 1, i64* %15
store i64 1907, i64* %16
store float 5.813000e+03, float* %7
store float 1.307000e+03, float* %8
store float 5.471000e+03, float* %9
store i64 40000000, i64* %17
store i64 1, i64* %18
br label %21
21: ; preds = %67, %2
%22 = load i64, i64* %18
%23 = load i64, i64* %17
%24 = icmp sle i64 %22, %23
br i1 %24, label %25, label %70
25: ; preds = %21
%26 = load i64, i64* %16
%27 = mul nsw i64 27611, %26
store i64 %27, i64* %19
%28 = load i64, i64* %19
%29 = load i64, i64* %19
%30 = sdiv i64 %29, 74383
%31 = mul nsw i64 74383, %30
%32 = sub nsw i64 %28, %31
store i64 %32, i64* %16
%33 = load i64, i64* %16
%34 = sitofp i64 %33 to float
%35 = fpext float %34 to double
%36 = fdiv double %35, 7.438300e+04
%37 = fptrunc double %36 to float
store float %37, float* %10
%38 = load float, float* %8
%39 = load float, float* %7
%40 = fmul float %38, %39
store float %40, float* %14
%41 = load float, float* %14
%42 = load float, float* %9
%43 = load float, float* %14
%44 = load float, float* %9
%45 = fdiv float %43, %44
%46 = fptosi float %45 to i64
%47 = sitofp i64 %46 to float
%48 = fneg float %42
%49 = call float @llvm.fmuladd.f32(float %48, float %47, float %41)
store float %49, float* %7
%50 = load float, float* %7
%51 = load float, float* %9
%52 = fdiv float %50, %51
store float %52, float* %11
%53 = load float, float* %10
%54 = load float, float* %10
%55 = load float, float* %11
%56 = load float, float* %11
%57 = fmul float %55, %56
%58 = call float @llvm.fmuladd.f32(float %53, float %54, float %57)
store float %58, float* %12
%59 = call i32 @myadd(float* %6, float* %12)
%60 = load float, float* %12
%61 = fpext float %60 to double
%62 = fcmp ole double %61, 1.000000e+00
br i1 %62, label %63, label %66
63: ; preds = %25
%64 = load i64, i64* %15
%65 = add nsw i64 %64, 1
store i64 %65, i64* %15
br label %66
66: ; preds = %63, %25
br label %67
67: ; preds = %66
%68 = load i64, i64* %18
%69 = add nsw i64 %68, 1
store i64 %69, i64* %18
br label %21
70: ; preds = %21
%71 = load float, float* %10
%72 = fpext float %71 to double
%73 = load float, float* %11
%74 = fpext float %73 to double
%75 = load i64, i64* %15
%76 = trunc i64 %75 to i32
%77 = load i64, i64* %18
%78 = trunc i64 %77 to i32
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), double %72, double %74, i32 %76, i32 %78)
%80 = load i64, i64* %15
%81 = sitofp i64 %80 to float
%82 = fpext float %81 to double
%83 = fmul double 4.000000e+00, %82
%84 = load i64, i64* %17
%85 = sitofp i64 %84 to float
%86 = fpext float %85 to double
%87 = fdiv double %83, %86
%88 = fptrunc double %87 to float
store float %88, float* %13
%89 = load float, float* %13
%90 = fpext float %89 to double
%91 = load float, float* %6
%92 = fpext float %91 to double
%93 = fmul double %92, 0.000000e+00
%94 = load i64, i64* %17
%95 = trunc i64 %94 to i32
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), double %90, double %93, i32 %95)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [45 x i8] c" x = %9.6f y = %12.2f low = %8d j = %7d\0A\00"
@.str.2 = [37 x i8] c"Pi = %9.6f ztot = %12.2f itot = %8d\0A\00"
@str = [15 x i8] c"Starting PI...\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca float
%4 = alloca float
%5 = bitcast float* %3 to i8*
%6 = bitcast float* %4 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
store float 0.000000e+00, float* %3
br label %8
8: ; preds = %2, %8
%9 = phi float [ 5.813000e+03, %2 ], [ %21, %8 ]
%10 = phi i64 [ 1, %2 ], [ %30, %8 ]
%11 = phi i64 [ 1907, %2 ], [ %14, %8 ]
%12 = phi i64 [ 1, %2 ], [ %29, %8 ]
%13 = mul nsw i64 %11, 27611
%14 = srem i64 %13, 74383
%15 = sitofp i64 %14 to float
%16 = fdiv float %15, 7.438300e+04
%17 = fmul float %9, 1.307000e+03
%18 = fdiv float %17, 5.471000e+03
%19 = fptosi float %18 to i64
%20 = sitofp i64 %19 to float
%21 = call float @llvm.fmuladd.f32(float %20, float -5.471000e+03, float %17)
%22 = fdiv float %21, 5.471000e+03
%23 = fmul float %22, %22
%24 = call float @llvm.fmuladd.f32(float %16, float %16, float %23)
store float %24, float* %4
%25 = call i32 @myadd(float* %3, float* %4)
%26 = load float, float* %4
%27 = fcmp ole float %26, 1.000000e+00
%28 = zext i1 %27 to i64
%29 = add nuw nsw i64 %12, %28
%30 = add nuw nsw i64 %10, 1
%31 = icmp eq i64 %30, 40000001
br i1 %31, label %32, label %8
32: ; preds = %8
%33 = fpext float %16 to double
%34 = fpext float %22 to double
%35 = trunc i64 %29 to i32
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), double %33, double %34, i32 %35, i32 40000001)
%37 = sitofp i64 %29 to float
%38 = fpext float %37 to double
%39 = fmul double %38, 4.000000e+00
%40 = fdiv double %39, 4.000000e+07
%41 = fptrunc double %40 to float
%42 = fpext float %41 to double
%43 = load float, float* %3
%44 = fpext float %43 to double
%45 = fmul double %44, 0.000000e+00
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), double %42, double %45, i32 40000000)
ret i32 0
}