#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 log10(double);
double pow(double, int);
scalar_t__ rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void salpeter(int N, double *m, double alpha, double m1, double m2) {
  int i;
  srand(time(NULL));
  double lm, prob, mass;
  double lmin = log10(m1);
  double lmax = log10(m2);
  for (i = 0; i < N; i++) {
    mass = m2;
    prob = 1.;
    while (prob > pow(mass, 1 - alpha)) {
      mass =
          pow(10, lmin + ((double)rand() / (double)RAND_MAX) * (lmax - lmin));
      prob = 1.05 * ((double)rand() / (double)RAND_MAX) * pow(m1, 1 - alpha);
    }
    m[i] = mass;
  }
}


x86 assembly (clang, -O0):
<salpeter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movsd  -0x20(%rbp),%xmm0
call   1060 <log10@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1060 <log10@plt>
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12ce <salpeter+0x17e>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe3f(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  0xe23(%rip),%xmm1
subsd  -0x18(%rbp),%xmm1
cvttsd2si %xmm1,%edi
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12ae <salpeter+0x15e>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
movsd  -0x70(%rbp),%xmm1
cvtsi2sd %rax,%xmm0
mov    0x2dc9(%rip),%rax
cvtsi2sdq (%rax),%xmm2
divsd  %xmm2,%xmm0
movsd  -0x58(%rbp),%xmm2
subsd  -0x50(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
movsd  0xdca(%rip),%xmm0
call   1050 <pow@plt>
movsd  %xmm0,-0x48(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
cvtsi2sd %rax,%xmm1
mov    0x2d85(%rip),%rax
cvtsi2sdq (%rax),%xmm0
divsd  %xmm0,%xmm1
movsd  0xd94(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xd76(%rip),%xmm1
subsd  -0x18(%rbp),%xmm1
cvttsd2si %xmm1,%edi
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    11c6 <salpeter+0x76>
movsd  -0x48(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11a3 <salpeter+0x53>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<salpeter>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x28(%rsp)
movsd  %xmm0,(%rsp)
mov    %rsi,%r15
mov    %edi,%r14d
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movsd  0x28(%rsp),%xmm0
call   1060 <log10@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <log10@plt>
movsd  %xmm0,0x10(%rsp)
test   %r14d,%r14d
jle    12c5 <salpeter+0x175>
movsd  0xe4c(%rip),%xmm0
subsd  (%rsp),%xmm0
cvttsd2si %xmm0,%ebp
movsd  0x10(%rsp),%xmm0
subsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %r14d,%r14d
mov    0x2e0f(%rip),%rbx
xor    %r12d,%r12d
jmp    11f3 <salpeter+0xa3>
xchg   %ax,%ax
movsd  %xmm0,(%r15,%r12,8)
add    $0x1,%r12
cmp    %r14,%r12
je     12c5 <salpeter+0x175>
movsd  0x8(%rsp),%xmm0
mov    %ebp,%edi
call   1050 <pow@plt>
movsd  0xdf8(%rip),%xmm1
ucomisd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
jbe    11e0 <salpeter+0x90>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1070 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq (%rbx),%xmm1
divsd  %xmm1,%xmm0
mulsd  0x10(%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
cvttsd2si %xmm0,%edi
movsd  0xdb5(%rip),%xmm0
call   1050 <pow@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sdq (%rbx),%xmm0
divsd  %xmm0,%xmm1
mulsd  0xd90(%rip),%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0x28(%rsp),%xmm0
mov    %ebp,%edi
call   1050 <pow@plt>
mulsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  (%rsp),%xmm0
mov    %ebp,%edi
call   1050 <pow@plt>
movsd  0x18(%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     1220 <salpeter+0xd0>
movsd  (%rsp),%xmm0
jmp    11e0 <salpeter+0x90>
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global i64 0
define void @salpeter(i32 %0, double* %1, double %2, double %3, double %4) {
%6 = alloca i32
%7 = alloca double*
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
store i32 %0, i32* %6
store double* %1, double** %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
%17 = call i32 @time(i32* null)
%18 = call i32 @srand(i32 %17)
%19 = load double, double* %9
%20 = call double @log10(double %19)
store double %20, double* %15
%21 = load double, double* %10
%22 = call double @log10(double %21)
store double %22, double* %16
store i32 0, i32* %11
br label %23
23: ; preds = %68, %5
%24 = load i32, i32* %11
%25 = load i32, i32* %6
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %71
27: ; preds = %23
%28 = load double, double* %10
store double %28, double* %14
store double 1.000000e+00, double* %13
br label %29
29: ; preds = %37, %27
%30 = load double, double* %13
%31 = load double, double* %14
%32 = load double, double* %8
%33 = fsub double 1.000000e+00, %32
%34 = fptosi double %33 to i32
%35 = call double @pow(double %31, i32 %34)
%36 = fcmp ogt double %30, %35
br i1 %36, label %37, label %62
37: ; preds = %29
%38 = load double, double* %15
%39 = call i64 (...) @rand()
%40 = sitofp i64 %39 to double
%41 = load i64, i64* @RAND_MAX
%42 = sitofp i64 %41 to double
%43 = fdiv double %40, %42
%44 = load double, double* %16
%45 = load double, double* %15
%46 = fsub double %44, %45
%47 = call double @llvm.fmuladd.f64(double %43, double %46, double %38)
%48 = fptosi double %47 to i32
%49 = call double @pow(double 1.000000e+01, i32 %48)
store double %49, double* %14
%50 = call i64 (...) @rand()
%51 = sitofp i64 %50 to double
%52 = load i64, i64* @RAND_MAX
%53 = sitofp i64 %52 to double
%54 = fdiv double %51, %53
%55 = fmul double 1.050000e+00, %54
%56 = load double, double* %9
%57 = load double, double* %8
%58 = fsub double 1.000000e+00, %57
%59 = fptosi double %58 to i32
%60 = call double @pow(double %56, i32 %59)
%61 = fmul double %55, %60
store double %61, double* %13
br label %29
62: ; preds = %29
%63 = load double, double* %14
%64 = load double*, double** %7
%65 = load i32, i32* %11
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %64, i64 %66
store double %63, double* %67
br label %68
68: ; preds = %62
%69 = load i32, i32* %11
%70 = add nsw i32 %69, 1
store i32 %70, i32* %11
br label %23
71: ; preds = %23
ret void
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
define void @salpeter(i32 %0, double* nocapture writeonly %1, double %2, double %3, double %4) {
%6 = tail call i32 @time(i32* null)
%7 = tail call i32 @srand(i32 %6)
%8 = tail call double @log10(double %3)
%9 = tail call double @log10(double %4)
%10 = icmp sgt i32 %0, 0
br i1 %10, label %11, label %44
11: ; preds = %5
%12 = fsub double 1.000000e+00, %2
%13 = fptosi double %12 to i32
%14 = fsub double %9, %8
%15 = zext i32 %0 to i64
br label %16
16: ; preds = %11, %39
%17 = phi i64 [ 0, %11 ], [ %42, %39 ]
%18 = tail call double @pow(double %4, i32 %13)
%19 = fcmp olt double %18, 1.000000e+00
br i1 %19, label %20, label %39
20: ; preds = %16, %20
%21 = tail call i64 (...) @rand()
%22 = sitofp i64 %21 to double
%23 = load i64, i64* @RAND_MAX
%24 = sitofp i64 %23 to double
%25 = fdiv double %22, %24
%26 = tail call double @llvm.fmuladd.f64(double %25, double %14, double %8)
%27 = fptosi double %26 to i32
%28 = tail call double @pow(double 1.000000e+01, i32 %27)
%29 = tail call i64 (...) @rand()
%30 = sitofp i64 %29 to double
%31 = load i64, i64* @RAND_MAX
%32 = sitofp i64 %31 to double
%33 = fdiv double %30, %32
%34 = fmul double %33, 1.050000e+00
%35 = tail call double @pow(double %3, i32 %13)
%36 = fmul double %35, %34
%37 = tail call double @pow(double %28, i32 %13)
%38 = fcmp ogt double %36, %37
br i1 %38, label %20, label %39
39: ; preds = %20, %16
%40 = phi double [ %4, %16 ], [ %28, %20 ]
%41 = getelementptr inbounds double, double* %1, i64 %17
store double %40, double* %41
%42 = add nuw nsw i64 %17, 1
%43 = icmp eq i64 %42, %15
br i1 %43, label %44, label %16
44: ; preds = %39, %5
ret void
}