#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 birth_function(int);
int /*<<< orphan*/ err_check(scalar_t__);
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main(void) {
  int s, people, collisions;
  double probability;
  errno = 0;
  srand(time(0));
  printf("\nInput number of people involved in study SIMULATION:\n");
  s = scanf("%d", &people);
  if (people > 4096) {
    printf("\nToo many individuals for buffer, try smaller value:\n");
    s = scanf("%d", &people);
  }
  if (s != 1) {
    printf("\nInput Error\n");
    exit(0);
  }
  collisions = birth_function(people);
  err_check(errno);
  probability = collisions / (people - 1.0);
  probability = probability * 100;
  printf("\nThe Estimated Probabilty of Collison is %f%%\n\n", probability);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e5a(%rip),%rax
movq   $0x0,(%rax)
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe97(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1080 <scanf@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1000,-0xc(%rbp)
jle    11ea <main+0x7a>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe69(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1080 <scanf@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     1209 <main+0x99>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0xc(%rbp),%edi
call   1050 <birth_function@plt>
mov    %eax,-0x10(%rbp)
mov    0x2dc5(%rip),%rax
mov    (%rax),%rdi
call   1030 <err_check@plt>
cvtsi2sdl -0x10(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xdd3(%rip),%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xdb6(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe2e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2e55(%rip),%r14
movq   $0x0,(%r14)
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
lea    0xe9c(%rip),%rdi
call   1040 <puts@plt>
lea    0xe5d(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1090 <scanf@plt>
cmpl   $0x1001,0x4(%rsp)
jl     11e4 <main+0x64>
lea    0xeb8(%rip),%rdi
call   1040 <puts@plt>
lea    0xe36(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1090 <scanf@plt>
cmp    $0x1,%eax
jne    1232 <main+0xb2>
mov    0x4(%rsp),%edi
call   1060 <birth_function@plt>
mov    %eax,%ebx
mov    (%r14),%rdi
call   1030 <err_check@plt>
cvtsi2sd %ebx,%xmm0
cvtsi2sdl 0x4(%rsp),%xmm1
addsd  0xdf2(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  0xdee(%rip),%xmm0
lea    0xdf2(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe40(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@errno = global i64 0
@.str = [55 x i8] c"\0AInput number of people involved in study SIMULATION:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [54 x i8] c"\0AToo many individuals for buffer, try smaller value:\0A\00"
@.str.3 = [14 x i8] c"\0AInput Error\0A\00"
@.str.4 = [48 x i8] c"\0AThe Estimated Probabilty of Collison is %f%%\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
store i32 0, i32* %1
store i64 0, i64* @errno
%6 = call i32 @time(i32 0)
%7 = call i32 @srand(i32 %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 %9, i32* %2
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 4096
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 %14, i32* %2
br label %15
15: ; preds = %12, %0
%16 = load i32, i32* %2
%17 = icmp ne i32 %16, 1
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 @exit(i32 0)
unreachable
21: ; preds = %15
%22 = load i32, i32* %3
%23 = call i32 @birth_function(i32 %22)
store i32 %23, i32* %4
%24 = load i64, i64* @errno
%25 = call i32 @err_check(i64 %24)
%26 = load i32, i32* %4
%27 = sitofp i32 %26 to double
%28 = load i32, i32* %3
%29 = sitofp i32 %28 to double
%30 = fsub double %29, 1.000000e+00
%31 = fdiv double %27, %30
store double %31, double* %5
%32 = load double, double* %5
%33 = fmul double %32, 1.000000e+02
store double %33, double* %5
%34 = load double, double* %5
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), double %34)
ret i32 0
}

LLVM IR (-O2):
@errno = global i64 0
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [48 x i8] c"\0AThe Estimated Probabilty of Collison is %f%%\0A\0A\00"
@str = [54 x i8] c"\0AInput number of people involved in study SIMULATION:\00"
@str.5 = [13 x i8] c"\0AInput Error\00"
@str.6 = [53 x i8] c"\0AToo many individuals for buffer, try smaller value:\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i64 0, i64* @errno
%3 = tail call i32 @time(i32 0)
%4 = tail call i32 @srand(i32 %3)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, 4096
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.6, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %12
12: ; preds = %9, %0
%13 = phi i32 [ %11, %9 ], [ %6, %0 ]
%14 = icmp eq i32 %13, 1
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.5, i64 0, i64 0))
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %12
%19 = load i32, i32* %1
%20 = call i32 @birth_function(i32 %19)
%21 = load i64, i64* @errno
%22 = call i32 @err_check(i64 %21)
%23 = sitofp i32 %20 to double
%24 = load i32, i32* %1
%25 = sitofp i32 %24 to double
%26 = fadd double %25, -1.000000e+00
%27 = fdiv double %23, %26
%28 = fmul double %27, 1.000000e+02
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), double %28)
ret i32 0
}