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


x86 assembly (clang, -O0):
<init_config_random_2d>:
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)
mov    -0x8(%rbp),%rdi
call   1030 <srand48@plt>
mov    -0x38(%rbp),%rax
movsd  0xe9f(%rip),%xmm0
movsd  %xmm0,(%rax)
movsd  0xe8b(%rip),%xmm0
mov    0x2e5c(%rip),%rax
mulsd  (%rax),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  0xe62(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
divsd  (%rax),%xmm0
movsd  0xe46(%rip),%xmm1
call   1040 <pow@plt>
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%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
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    $0x0,%al
call   1060 <drand48@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x10(%rax)
movl   $0x1,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1320 <init_config_random_2d+0x1e0>
jmp    1244 <init_config_random_2d+0x104>
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    -0x20(%rbp),%rax
movslq -0x48(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%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     130d <init_config_random_2d+0x1cd>
cmpl   $0x1,-0x3c(%rbp)
jle    1308 <init_config_random_2d+0x1c8>
mov    -0x3c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3c(%rbp)
jmp    1244 <init_config_random_2d+0x104>
jmp    1312 <init_config_random_2d+0x1d2>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1233 <init_config_random_2d+0xf3>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_config_random_2d>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%rbx
mov    %r8,%r12
mov    %rcx,%r15
mov    %rdx,%r14
mov    %esi,%ebp
movsd  %xmm0,(%rsp)
call   1030 <srand48@plt>
movabs $0x4000000000000000,%rax
mov    %rbx,0x10(%rsp)
mov    %rax,(%rbx)
mov    0x2e69(%rip),%rax
movsd  (%rax),%xmm1
mulsd  0xe75(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  %xmm1,%xmm0
divsd  (%rsp),%xmm0
divsd  0xe65(%rip),%xmm0
movsd  0xe65(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1040 <pow@plt>
movsd  %xmm0,(%rsp)
movsd  %xmm0,(%r12)
movsd  %xmm0,(%r15)
xor    %eax,%eax
call   1060 <drand48@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%r14)
movsd  (%r12),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <drand48@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%r14)
movq   $0x0,0x10(%r14)
mov    %ebp,0xc(%rsp)
cmp    $0x2,%ebp
jl     1291 <init_config_random_2d+0x151>
mov    $0x1,%ebp
jmp    121a <init_config_random_2d+0xda>
xchg   %ax,%ax
xor    %eax,%eax
cmp    $0x2,%ebp
setge  %al
sub    %eax,%ebp
lea    0x0(%rbp,%rbp,2),%r13d
movsd  (%r15),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <drand48@plt>
mulsd  (%rsp),%xmm0
movslq %r13d,%rbx
movsd  %xmm0,(%r14,%rbx,8)
movsd  (%r12),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <drand48@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%r14,%rbx,8)
movq   $0x0,0x10(%r14,%rbx,8)
movsd  (%r15),%xmm0
movsd  (%r12),%xmm1
mov    0x10(%rsp),%rax
movsd  (%rax),%xmm2
mov    %ebp,%edi
mov    %r14,%rsi
call   1050 <check_overlap@plt>
test   %rax,%rax
jne    1210 <init_config_random_2d+0xd0>
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jl     121a <init_config_random_2d+0xda>
add    $0x18,%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_2d(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
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
%19 = load i64, i64* %8
%20 = call i32 @srand48(i64 %19)
%21 = load double*, double** %14
store double 2.000000e+00, double* %21
%22 = load double, double* @M_PI
%23 = fmul double 4.000000e+00, %22
%24 = load i32, i32* %10
%25 = sitofp i32 %24 to double
%26 = fmul double %23, %25
%27 = load double, double* %9
%28 = fdiv double %26, %27
%29 = fdiv double %28, 3.000000e+00
%30 = load double*, double** %14
%31 = load double, double* %30
%32 = fdiv double %29, %31
%33 = call double @pow(double %32, double 5.000000e-01)
%34 = load double*, double** %13
store double %33, double* %34
%35 = load double*, double** %12
store double %33, double* %35
%36 = load double*, double** %12
%37 = load double, double* %36
%38 = call double (...) @drand48()
%39 = fmul double %37, %38
%40 = load double*, double** %11
%41 = getelementptr inbounds double, double* %40, i64 0
store double %39, double* %41
%42 = load double*, double** %13
%43 = load double, double* %42
%44 = call double (...) @drand48()
%45 = fmul double %43, %44
%46 = load double*, double** %11
%47 = getelementptr inbounds double, double* %46, i64 1
store double %45, double* %47
%48 = load double*, double** %11
%49 = getelementptr inbounds double, double* %48, i64 2
store double 0.000000e+00, double* %49
store i32 1, i32* %15
br label %50
50: ; preds = %100, %7
%51 = load i32, i32* %15
%52 = load i32, i32* %10
%53 = icmp slt i32 %51, %52
br i1 %53, label %54, label %103
54: ; preds = %50
br label %55
55: ; preds = %98, %54
%56 = load i32, i32* %15
%57 = mul nsw i32 %56, 3
store i32 %57, i32* %16
%58 = load i32, i32* %16
%59 = add nsw i32 %58, 1
store i32 %59, i32* %17
%60 = load i32, i32* %16
%61 = add nsw i32 %60, 2
store i32 %61, i32* %18
%62 = load double*, double** %12
%63 = load double, double* %62
%64 = call double (...) @drand48()
%65 = fmul double %63, %64
%66 = load double*, double** %11
%67 = load i32, i32* %16
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %66, i64 %68
store double %65, double* %69
%70 = load double*, double** %13
%71 = load double, double* %70
%72 = call double (...) @drand48()
%73 = fmul double %71, %72
%74 = load double*, double** %11
%75 = load i32, i32* %17
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds double, double* %74, i64 %76
store double %73, double* %77
%78 = load double*, double** %11
%79 = load i32, i32* %18
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds double, double* %78, i64 %80
store double 0.000000e+00, double* %81
%82 = load i32, i32* %15
%83 = load double*, double** %12
%84 = load double, double* %83
%85 = load double*, double** %13
%86 = load double, double* %85
%87 = load double*, double** %14
%88 = load double, double* %87
%89 = load double*, double** %11
%90 = call i64 @check_overlap(i32 %82, double %84, double %86, double %88, double* %89)
%91 = icmp ne i64 %90, 0
br i1 %91, label %92, label %99
92: ; preds = %55
%93 = load i32, i32* %15
%94 = icmp sgt i32 %93, 1
br i1 %94, label %95, label %98
95: ; preds = %92
%96 = load i32, i32* %15
%97 = add nsw i32 %96, -1
store i32 %97, i32* %15
br label %98
98: ; preds = %95, %92
br label %55
99: ; preds = %55
br label %100
100: ; preds = %99
%101 = load i32, i32* %15
%102 = add nsw i32 %101, 1
store i32 %102, i32* %15
br label %50
103: ; preds = %50
ret void
}

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