#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*/ brnd(double, double, double *, double *);
int /*<<< orphan*/ printf(char *, ...);
void box_muller() {
  int hist[100];
  int i;
  int j;
  double x, y;
  for (i = 0; i < 100; i++) {
    hist[i] = 0;
  }
  for (i = 0; i < 1000; i++) {
    brnd(2.5, 10.0, &x, &y);
    hist[(int)x]++;
    hist[(int)y]++;
  }
  for (i = 0; i <= 20; i++) {
    printf("%3d : I ", i);
    for (j = 1; j <= hist[i] / 10; j++) {
      printf("*");
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<box_muller>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x194(%rbp)
cmpl   $0x64,-0x194(%rbp)
jge    1168 <box_muller+0x48>
movslq -0x194(%rbp),%rax
movl   $0x0,-0x190(%rbp,%rax,4)
mov    -0x194(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x194(%rbp)
jmp    1135 <box_muller+0x15>
movl   $0x0,-0x194(%rbp)
cmpl   $0x3e8,-0x194(%rbp)
jge    11ef <box_muller+0xcf>
movsd  0xe76(%rip),%xmm0
movsd  0xe76(%rip),%xmm1
lea    -0x1a0(%rbp),%rdi
lea    -0x1a8(%rbp),%rsi
call   1040 <brnd@plt>
cvttsd2si -0x1a0(%rbp),%eax
ff
cltq
mov    -0x190(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x190(%rbp,%rax,4)
cvttsd2si -0x1a8(%rbp),%eax
ff
cltq
mov    -0x190(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x190(%rbp,%rax,4)
mov    -0x194(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x194(%rbp)
jmp    1172 <box_muller+0x52>
movl   $0x0,-0x194(%rbp)
cmpl   $0x14,-0x194(%rbp)
jg     129a <box_muller+0x17a>
mov    -0x194(%rbp),%esi
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x198(%rbp)
mov    -0x198(%rbp),%eax
mov    %eax,-0x1ac(%rbp)
movslq -0x194(%rbp),%rax
mov    -0x190(%rbp,%rax,4),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1ac(%rbp),%eax
cmp    %ecx,%eax
jg     1278 <box_muller+0x158>
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x198(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x198(%rbp)
jmp    1224 <box_muller+0x104>
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x194(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x194(%rbp)
jmp    11f9 <box_muller+0xd9>
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<box_muller>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x1a8,%rsp
lea    0x10(%rsp),%rdi
mov    $0x190,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    $0x3e8,%ebp
lea    0x8(%rsp),%r14
mov    %rsp,%rbx
nopl   0x0(%rax,%rax,1)
movsd  0xe88(%rip),%xmm0
movsd  0xe88(%rip),%xmm1
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <brnd@plt>
cvttsd2si 0x8(%rsp),%eax
cltq
addl   $0x1,0x10(%rsp,%rax,4)
cvttsd2si (%rsp),%eax
cltq
addl   $0x1,0x10(%rsp,%rax,4)
add    $0xffffffff,%ebp
jne    1170 <box_muller+0x30>
lea    0xe60(%rip),%r14
mov    $0xcccccccd,%r15d
xor    %ebx,%ebx
jmp    11d4 <box_muller+0x94>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x15,%rbx
je     1211 <box_muller+0xd1>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp,%rbx,4),%eax
cmp    $0xa,%eax
jl     11c0 <box_muller+0x80>
mov    %eax,%ebp
imul   %r15,%rbp
shr    $0x23,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1200 <box_muller+0xc0>
jmp    11c0 <box_muller+0x80>
add    $0x1a8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%3d : I \00"
@.str.1 = [2 x i8] c"*\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @box_muller() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca double
store i32 0, i32* %2
br label %6
6: ; preds = %13, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 100
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %11
store i32 0, i32* %12
br label %13
13: ; preds = %9
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
br label %6
16: ; preds = %6
store i32 0, i32* %2
br label %17
17: ; preds = %34, %16
%18 = load i32, i32* %2
%19 = icmp slt i32 %18, 1000
br i1 %19, label %20, label %37
20: ; preds = %17
%21 = call i32 @brnd(double 2.500000e+00, double 1.000000e+01, double* %4, double* %5)
%22 = load double, double* %4
%23 = fptosi double %22 to i32
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = add nsw i32 %26, 1
store i32 %27, i32* %25
%28 = load double, double* %5
%29 = fptosi double %28 to i32
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = add nsw i32 %32, 1
store i32 %33, i32* %31
br label %34
34: ; preds = %20
%35 = load i32, i32* %2
%36 = add nsw i32 %35, 1
store i32 %36, i32* %2
br label %17
37: ; preds = %17
store i32 0, i32* %2
br label %38
38: ; preds = %59, %37
%39 = load i32, i32* %2
%40 = icmp sle i32 %39, 20
br i1 %40, label %41, label %62
41: ; preds = %38
%42 = load i32, i32* %2
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %42)
store i32 1, i32* %3
br label %44
44: ; preds = %54, %41
%45 = load i32, i32* %3
%46 = load i32, i32* %2
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %47
%49 = load i32, i32* %48
%50 = sdiv i32 %49, 10
%51 = icmp sle i32 %45, %50
br i1 %51, label %52, label %57
52: ; preds = %44
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %54
54: ; preds = %52
%55 = load i32, i32* %3
%56 = add nsw i32 %55, 1
store i32 %56, i32* %3
br label %44
57: ; preds = %44
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %59
59: ; preds = %57
%60 = load i32, i32* %2
%61 = add nsw i32 %60, 1
store i32 %61, i32* %2
br label %38
62: ; preds = %38
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%3d : I \00"
define void @box_muller() {
%1 = alloca [100 x i32]
%2 = bitcast [100 x i32]* %1 to i8*
%3 = alloca double
%4 = alloca double
%5 = bitcast double* %3 to i8*
%6 = bitcast double* %4 to i8*
br label %7
7: ; preds = %0, %7
%8 = phi i32 [ %22, %7 ], [ 0, %0 ]
%9 = call i32 @brnd(double 2.500000e+00, double 1.000000e+01, double* %3, double* %4)
%10 = load double, double* %3
%11 = fptosi double %10 to i32
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = add nsw i32 %14, 1
store i32 %15, i32* %13
%16 = load double, double* %4
%17 = fptosi double %16 to i32
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 1
store i32 %21, i32* %19
%22 = add nuw nsw i32 %8, 1
%23 = icmp eq i32 %22, 1000
br i1 %23, label %24, label %7
24: ; preds = %7, %38
%25 = phi i64 [ %40, %38 ], [ 0, %7 ]
%26 = trunc i64 %25 to i32
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %25
%29 = load i32, i32* %28
%30 = icmp slt i32 %29, 10
br i1 %30, label %38, label %31
31: ; preds = %24
%32 = udiv i32 %29, 10
br label %33
33: ; preds = %31, %33
%34 = phi i32 [ %36, %33 ], [ 1, %31 ]
%35 = call i32 @putchar(i32 42)
%36 = add nuw nsw i32 %34, 1
%37 = icmp eq i32 %34, %32
br i1 %37, label %38, label %33
38: ; preds = %33, %24
%39 = call i32 @putchar(i32 10)
%40 = add nuw nsw i64 %25, 1
%41 = icmp eq i64 %40, 21
br i1 %41, label %42, label %24
42: ; preds = %38
ret void
}