#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 */
double M_PI;
scalar_t__ check_overlap(int, double, double, double, double *);
double drand48();
double pow(double, double);
int /*<<< orphan*/ srand48(long);
void init_config_random(long seed, double phi, int np, double *pos, double *lx,
                        double *ly, double *lz) {
  int i;
  int ix, iy, iz;
  int i_tor = 1000;
  int j;
  srand48(seed);
  (*lx) = (*ly) = (*lz) = pow(4.0 * M_PI * (double)np / phi / 3.0, 1.0 / 3.0);
  j = 0;
  for (i = 0; i < np; i++) {
  retry_init_config_random:
    ix = i * 3;
    iy = ix + 1;
    iz = ix + 2;
    pos[ix] = (*lx) * drand48();
    pos[iy] = (*ly) * drand48();
    pos[iz] = (*lz) * drand48();
    if (check_overlap(i + 1, (*lx), (*ly), (*lz), pos) != 0) {
      ++j;
      if (j > i_tor) {
        j = 0;
        if (i > 0)
          --i;
      }
      goto retry_init_config_random;
    }
  }
}


x86 assembly (clang, -O0):
<init_config_random>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
movl   $0x3e8,-0x4c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <srand48@plt>
movsd  0xe94(%rip),%xmm0
mov    0x2e65(%rip),%rax
mulsd  (%rax),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  0xe6b(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe57(%rip),%xmm1
call   1040 <pow@plt>
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1302 <init_config_random+0x1c2>
jmp    11e5 <init_config_random+0xa5>
imul   $0x3,-0x3c(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x48(%rbp)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    $0x0,%al
call   1060 <drand48@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    $0x0,%al
call   1060 <drand48@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    $0x0,%al
call   1060 <drand48@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x48(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%edi
add    $0x1,%edi
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x20(%rbp),%rsi
call   1050 <check_overlap@plt>
cmp    $0x0,%rax
je     12ef <init_config_random+0x1af>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jle    12ea <init_config_random+0x1aa>
movl   $0x0,-0x50(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jle    12e5 <init_config_random+0x1a5>
mov    -0x3c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3c(%rbp)
jmp    12ea <init_config_random+0x1aa>
jmp    11e5 <init_config_random+0xa5>
jmp    12f4 <init_config_random+0x1b4>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11d4 <init_config_random+0x94>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_config_random>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9,%rbp
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,0x28(%rsp)
mov    %esi,%ebx
movsd  %xmm0,0x8(%rsp)
call   1030 <srand48@plt>
mov    0x2e78(%rip),%rax
movsd  (%rax),%xmm1
mulsd  0xe84(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  %xmm1,%xmm0
divsd  0x8(%rsp),%xmm0
divsd  0xe73(%rip),%xmm0
movsd  0xe73(%rip),%xmm1
call   1040 <pow@plt>
mov    %rbp,0x40(%rsp)
movsd  %xmm0,0x0(%rbp)
mov    %r14,0x38(%rsp)
movsd  %xmm0,(%r14)
mov    %r15,0x30(%rsp)
movsd  %xmm0,(%r15)
mov    %ebx,0x18(%rsp)
test   %ebx,%ebx
jle    12fb <init_config_random+0x1bb>
xor    %eax,%eax
mov    %rax,0x8(%rsp)
xor    %eax,%eax
mov    %rax,0x20(%rsp)
mov    0x30(%rsp),%r15
mov    0x28(%rsp),%r13
mov    0x38(%rsp),%rbx
mov    0x40(%rsp),%r12
mov    0x8(%rsp),%rax
lea    (%rax,%rax,2),%r14d
nopw   0x0(%rax,%rax,1)
lea    0x1(%r14),%ebp
lea    0x2(%r14),%eax
mov    %eax,0x1c(%rsp)
movsd  (%r15),%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1060 <drand48@plt>
mulsd  0x10(%rsp),%xmm0
movslq %r14d,%rax
movsd  %xmm0,0x0(%r13,%rax,8)
movsd  (%rbx),%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1060 <drand48@plt>
mulsd  0x10(%rsp),%xmm0
movslq %ebp,%rax
movsd  %xmm0,0x0(%r13,%rax,8)
movsd  (%r12),%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1060 <drand48@plt>
mulsd  0x10(%rsp),%xmm0
movslq 0x1c(%rsp),%rax
movsd  %xmm0,0x0(%r13,%rax,8)
mov    0x8(%rsp),%rax
lea    0x1(%rax),%ebp
movsd  (%r15),%xmm0
movsd  (%rbx),%xmm1
movsd  (%r12),%xmm2
mov    %ebp,%edi
mov    %r13,%rsi
call   1050 <check_overlap@plt>
test   %rax,%rax
jne    12c0 <init_config_random+0x180>
add    $0x3,%r14d
mov    %ebp,%eax
mov    %rax,0x8(%rsp)
cmp    0x18(%rsp),%ebp
jl     1200 <init_config_random+0xc0>
jmp    12fb <init_config_random+0x1bb>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rsi
test   %esi,%esi
setg   %al
mov    0x20(%rsp),%rcx
cmp    $0x3e8,%ecx
lea    0x1(%rcx),%ecx
mov    $0x0,%edx
cmovge %edx,%ecx
setge  %dl
and    %al,%dl
movzbl %dl,%eax
sub    %eax,%esi
mov    %rsi,0x8(%rsp)
mov    %ecx,%eax
mov    %rax,0x20(%rsp)
jmp    11ee <init_config_random+0xae>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define void @init_config_random(i64 %0, double %1, i32 %2, double* %3, double* %4, double* %5, double* %6) {
%8 = alloca i64
%9 = alloca double
%10 = alloca i32
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
store i64 %0, i64* %8
store double %1, double* %9
store i32 %2, i32* %10
store double* %3, double** %11
store double* %4, double** %12
store double* %5, double** %13
store double* %6, double** %14
store i32 1000, i32* %19
%21 = load i64, i64* %8
%22 = call i32 @srand48(i64 %21)
%23 = load double, double* @M_PI
%24 = fmul double 4.000000e+00, %23
%25 = load i32, i32* %10
%26 = sitofp i32 %25 to double
%27 = fmul double %24, %26
%28 = load double, double* %9
%29 = fdiv double %27, %28
%30 = fdiv double %29, 3.000000e+00
%31 = call double @pow(double %30, double 0x3FD5555555555555)
%32 = load double*, double** %14
store double %31, double* %32
%33 = load double*, double** %13
store double %31, double* %33
%34 = load double*, double** %12
store double %31, double* %34
store i32 0, i32* %20
store i32 0, i32* %15
br label %35
35: ; preds = %97, %7
%36 = load i32, i32* %15
%37 = load i32, i32* %10
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %100
39: ; preds = %35
br label %40
40: ; preds = %95, %39
%41 = load i32, i32* %15
%42 = mul nsw i32 %41, 3
store i32 %42, i32* %16
%43 = load i32, i32* %16
%44 = add nsw i32 %43, 1
store i32 %44, i32* %17
%45 = load i32, i32* %16
%46 = add nsw i32 %45, 2
store i32 %46, i32* %18
%47 = load double*, double** %12
%48 = load double, double* %47
%49 = call double (...) @drand48()
%50 = fmul double %48, %49
%51 = load double*, double** %11
%52 = load i32, i32* %16
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
store double %50, double* %54
%55 = load double*, double** %13
%56 = load double, double* %55
%57 = call double (...) @drand48()
%58 = fmul double %56, %57
%59 = load double*, double** %11
%60 = load i32, i32* %17
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds double, double* %59, i64 %61
store double %58, double* %62
%63 = load double*, double** %14
%64 = load double, double* %63
%65 = call double (...) @drand48()
%66 = fmul double %64, %65
%67 = load double*, double** %11
%68 = load i32, i32* %18
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds double, double* %67, i64 %69
store double %66, double* %70
%71 = load i32, i32* %15
%72 = add nsw i32 %71, 1
%73 = load double*, double** %12
%74 = load double, double* %73
%75 = load double*, double** %13
%76 = load double, double* %75
%77 = load double*, double** %14
%78 = load double, double* %77
%79 = load double*, double** %11
%80 = call i64 @check_overlap(i32 %72, double %74, double %76, double %78, double* %79)
%81 = icmp ne i64 %80, 0
br i1 %81, label %82, label %96
82: ; preds = %40
%83 = load i32, i32* %20
%84 = add nsw i32 %83, 1
store i32 %84, i32* %20
%85 = load i32, i32* %20
%86 = load i32, i32* %19
%87 = icmp sgt i32 %85, %86
br i1 %87, label %88, label %95
88: ; preds = %82
store i32 0, i32* %20
%89 = load i32, i32* %15
%90 = icmp sgt i32 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %88
%92 = load i32, i32* %15
%93 = add nsw i32 %92, -1
store i32 %93, i32* %15
br label %94
94: ; preds = %91, %88
br label %95
95: ; preds = %94, %82
br label %40
96: ; preds = %40
br label %97
97: ; preds = %96
%98 = load i32, i32* %15
%99 = add nsw i32 %98, 1
store i32 %99, i32* %15
br label %35
100: ; preds = %35
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define void @init_config_random(i64 %0, double %1, i32 %2, double* %3, double* nocapture %4, double* nocapture %5, double* nocapture %6) {
%8 = tail call i32 @srand48(i64 %0)
%9 = load double, double* @M_PI
%10 = fmul double %9, 4.000000e+00
%11 = sitofp i32 %2 to double
%12 = fmul double %10, %11
%13 = fdiv double %12, %1
%14 = fdiv double %13, 3.000000e+00
%15 = tail call double @pow(double %14, double 0x3FD5555555555555)
store double %15, double* %6
store double %15, double* %5
store double %15, double* %4
%16 = icmp sgt i32 %2, 0
br i1 %16, label %17, label %56
17: ; preds = %7, %48
%18 = phi i32 [ %54, %48 ], [ 0, %7 ]
%19 = phi i32 [ %55, %48 ], [ 0, %7 ]
br label %22
20: ; preds = %22
%21 = icmp slt i32 %42, %2
br i1 %21, label %22, label %56
22: ; preds = %17, %20
%23 = phi i32 [ %42, %20 ], [ %18, %17 ]
%24 = mul nsw i32 %23, 3
%25 = add nsw i32 %24, 1
%26 = add nsw i32 %24, 2
%27 = load double, double* %4
%28 = tail call double (...) @drand48()
%29 = fmul double %27, %28
%30 = sext i32 %24 to i64
%31 = getelementptr inbounds double, double* %3, i64 %30
store double %29, double* %31
%32 = load double, double* %5
%33 = tail call double (...) @drand48()
%34 = fmul double %32, %33
%35 = sext i32 %25 to i64
%36 = getelementptr inbounds double, double* %3, i64 %35
store double %34, double* %36
%37 = load double, double* %6
%38 = tail call double (...) @drand48()
%39 = fmul double %37, %38
%40 = sext i32 %26 to i64
%41 = getelementptr inbounds double, double* %3, i64 %40
store double %39, double* %41
%42 = add nsw i32 %23, 1
%43 = load double, double* %4
%44 = load double, double* %5
%45 = load double, double* %6
%46 = tail call i64 @check_overlap(i32 %42, double %43, double %44, double %45, double* %3)
%47 = icmp eq i64 %46, 0
br i1 %47, label %20, label %48
48: ; preds = %22
%49 = add nsw i32 %19, 1
%50 = icmp sgt i32 %19, 999
%51 = icmp sgt i32 %23, 0
%52 = select i1 %50, i1 %51, i1 false
%53 = sext i1 %52 to i32
%54 = add nsw i32 %23, %53
%55 = select i1 %50, i32 0, i32 %49
br label %17
56: ; preds = %20, %7
ret void
}