#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;
int calc_trials(int, int *);
double rand();
int birth_function(int ppl) {
  int bmonth[4096];
  int person, i = ppl - 1, *p;
  p = bmonth;
  for (i; i >= 0; --i) {
    person = 12 * (rand() / ((double)RAND_MAX + 1));
    bmonth[i] = person;
  }
  return calc_trials(ppl, p);
}


x86 assembly (clang, -O0):
<birth_function>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4020,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x4018(%rbp)
lea    -0x4010(%rbp),%rax
mov    %rax,-0x4020(%rbp)
cmpl   $0x0,-0x4018(%rbp)
jl     11b9 <birth_function+0x99>
mov    $0x0,%al
call   1040 <rand@plt>
movaps %xmm0,%xmm1
mov    0x2e82(%rip),%rax
cvtsi2sdq (%rax),%xmm0
movsd  0xe95(%rip),%xmm2
addsd  %xmm2,%xmm0
divsd  %xmm0,%xmm1
movsd  0xe7d(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x4014(%rbp)
mov    -0x4014(%rbp),%ecx
movslq -0x4018(%rbp),%rax
mov    %ecx,-0x4010(%rbp,%rax,4)
mov    -0x4018(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4018(%rbp)
jmp    1148 <birth_function+0x28>
mov    -0x4(%rbp),%edi
mov    -0x4020(%rbp),%rsi
call   1030 <calc_trials@plt>
add    $0x4020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<birth_function>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x4008,%rsp
mov    %edi,%r14d
test   %edi,%edi
jle    1187 <birth_function+0x67>
mov    %r14d,%ebx
add    $0x1,%rbx
mov    0x2ea6(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    -0x2(%rbx),%ebp
xor    %eax,%eax
call   1040 <rand@plt>
xorps  %xmm1,%xmm1
cvtsi2sdq (%r15),%xmm1
addsd  0xe96(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  0xe92(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,(%rsp,%rbp,4)
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1150 <birth_function+0x30>
mov    %rsp,%rsi
mov    %r14d,%edi
call   1030 <calc_trials@plt>
add    $0x4008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global i64 0
define i32 @birth_function(i32 %0) {
%2 = alloca i32
%3 = alloca [4096 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
store i32 %0, i32* %2
%7 = load i32, i32* %2
%8 = sub nsw i32 %7, 1
store i32 %8, i32* %5
%9 = getelementptr inbounds [4096 x i32], [4096 x i32]* %3, i64 0, i64 0
store i32* %9, i32** %6
%10 = load i32, i32* %5
br label %11
11: ; preds = %26, %1
%12 = load i32, i32* %5
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %29
14: ; preds = %11
%15 = call double (...) @rand()
%16 = load i64, i64* @RAND_MAX
%17 = sitofp i64 %16 to double
%18 = fadd double %17, 1.000000e+00
%19 = fdiv double %15, %18
%20 = fmul double 1.200000e+01, %19
%21 = fptosi double %20 to i32
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [4096 x i32], [4096 x i32]* %3, i64 0, i64 %24
store i32 %22, i32* %25
br label %26
26: ; preds = %14
%27 = load i32, i32* %5
%28 = add nsw i32 %27, -1
store i32 %28, i32* %5
br label %11
29: ; preds = %11
%30 = load i32, i32* %2
%31 = load i32*, i32** %6
%32 = call i32 @calc_trials(i32 %30, i32* %31)
ret i32 %32
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
define i32 @birth_function(i32 %0) {
%2 = alloca [4096 x i32]
%3 = bitcast [4096 x i32]* %2 to i8*
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %20
5: ; preds = %1
%6 = zext i32 %0 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ %6, %5 ], [ %9, %7 ]
%9 = add nsw i64 %8, -1
%10 = tail call double (...) @rand()
%11 = load i64, i64* @RAND_MAX
%12 = sitofp i64 %11 to double
%13 = fadd double %12, 1.000000e+00
%14 = fdiv double %10, %13
%15 = fmul double %14, 1.200000e+01
%16 = fptosi double %15 to i32
%17 = and i64 %9, 4294967295
%18 = getelementptr inbounds [4096 x i32], [4096 x i32]* %2, i64 0, i64 %17
store i32 %16, i32* %18
%19 = icmp ugt i64 %8, 1
br i1 %19, label %7, label %20
20: ; preds = %7, %1
%21 = getelementptr inbounds [4096 x i32], [4096 x i32]* %2, i64 0, i64 0
%22 = call i32 @calc_trials(i32 %0, i32* %21)
ret i32 %22
}