#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__ atan2(float, float);
float distributions_uniform(float, float);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
float sqrt(float);
int distributions_spirals(int nspirals, float gain, float rmax, float *x) {
  int i, k, kmax;
  float rx = 1.0e35, rik, deltar, dr, thetax, thetak, dtheta0;
  dtheta0 = 6.283185307179586 / (float)nspirals;
  kmax = 1 + (int)(rmax / (gain * 6.283185307179586));
  deltar = dtheta0 * gain;
  x[0] = 1.0;
  while (x[0] != 0.0 && rx > rmax) {
    x[0] = distributions_uniform(-rmax, rmax);
    x[1] = distributions_uniform(-rmax, rmax);
    rx = sqrt(x[0] * x[0] + x[1] * x[1]);
  }
  thetax = (float)atan2((float)x[1], (float)x[0]);
  thetax += 3.141592653589793;
  for (k = 0; k <= kmax; k++) {
    thetak = k * 6.283185307179586;
    for (i = 0; i < nspirals; i++) {
      rik = gain * (thetax + thetak - dtheta0 * (float)i);
      dr = rik - rx;
      if (dr >= 0.0 && dr < deltar)
        goto XX;
    }
  }
  printf("distributions_spirals- ERROR, arm not found.\n");
  exit(0);
XX:;
  return (i);
}


x86 assembly (clang, -O0):
<distributions_spirals>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
movss  0xe93(%rip),%xmm0
movss  %xmm0,-0x28(%rbp)
cvtsi2ssl -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe81(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x40(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x8(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe5a(%rip),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movss  -0x40(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movss  0xe25(%rip),%xmm0
movss  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x41(%rbp)
jne    1208 <distributions_spirals+0xb8>
jp     1208 <distributions_spirals+0xb8>
jmp    1217 <distributions_spirals+0xc7>
movss  -0x28(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
seta   %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    1227 <distributions_spirals+0xd7>
jmp    12a9 <distributions_spirals+0x159>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  -0xc(%rbp),%xmm1
call   1050 <distributions_uniform@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  -0xc(%rbp),%xmm1
call   1050 <distributions_uniform@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm2
mov    -0x18(%rbp),%rax
movss  0x4(%rax),%xmm1
mov    -0x18(%rbp),%rax
mulss  0x4(%rax),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1060 <sqrt@plt>
movss  %xmm0,-0x28(%rbp)
jmp    11df <distributions_spirals+0x8f>
mov    -0x18(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm1
call   1030 <atan2@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x38(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd36(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x38(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     13c1 <distributions_spirals+0x271>
cvtsi2sdl -0x20(%rbp),%xmm0
movsd  0xd01(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x3c(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    13ae <distributions_spirals+0x25e>
movss  -0x8(%rbp),%xmm0
movss  -0x38(%rbp),%xmm2
addss  -0x3c(%rbp),%xmm2
movss  -0x40(%rbp),%xmm1
cvtsi2ssl -0x1c(%rbp),%xmm3
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm3,%xmm1
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x2c(%rbp),%xmm0
subss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     139b <distributions_spirals+0x24b>
movss  -0x34(%rbp),%xmm1
movss  -0x30(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    139b <distributions_spirals+0x24b>
jmp    13d4 <distributions_spirals+0x284>
jmp    13a0 <distributions_spirals+0x250>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    131b <distributions_spirals+0x1cb>
jmp    13b3 <distributions_spirals+0x263>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12ee <distributions_spirals+0x19e>
lea    0xc50(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x1c(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<distributions_spirals>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%rbx
movaps %xmm1,%xmm3
mov    %edi,%ebp
cvtss2sd %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
mulsd  0xe8d(%rip),%xmm1
divsd  %xmm1,%xmm2
cvttsd2si %xmm2,%r14d
movl   $0x3f800000,(%rsi)
movss  0xe8a(%rip),%xmm2
ucomiss %xmm3,%xmm2
movss  %xmm0,0xc(%rsp)
jbe    1223 <distributions_spirals+0xd3>
movaps 0xe80(%rip),%xmm0
xorps  %xmm3,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm3,0x10(%rsp)
nopl   (%rax)
movaps 0x20(%rsp),%xmm0
movaps %xmm3,%xmm1
call   1050 <distributions_uniform@plt>
movss  %xmm0,(%rbx)
movaps 0x20(%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
call   1050 <distributions_uniform@plt>
movaps %xmm0,%xmm1
movss  %xmm0,0x4(%rbx)
movss  (%rbx),%xmm0
mulss  %xmm1,%xmm1
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
ucomiss 0xe29(%rip),%xmm0
jb     1200 <distributions_spirals+0xb0>
xorps  %xmm2,%xmm2
sqrtss %xmm0,%xmm2
jmp    1208 <distributions_spirals+0xb8>
nopw   0x0(%rax,%rax,1)
call   1060 <sqrt@plt>
movaps %xmm0,%xmm2
movss  (%rbx),%xmm1
ucomiss 0xe05(%rip),%xmm1
movaps 0x10(%rsp),%xmm3
jne    121c <distributions_spirals+0xcc>
jnp    122b <distributions_spirals+0xdb>
ucomiss %xmm3,%xmm2
ja     11b0 <distributions_spirals+0x60>
jmp    122b <distributions_spirals+0xdb>
movss  0xde5(%rip),%xmm1
movss  %xmm2,0x10(%rsp)
movss  0x4(%rbx),%xmm0
call   1040 <atan2@plt>
movss  0x10(%rsp),%xmm3
cmp    $0xffffffff,%r14d
movss  0xc(%rsp),%xmm6
movsd  0xdad(%rip),%xmm7
jl     1311 <distributions_spirals+0x1c1>
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
cvtss2sd %xmm0,%xmm0
movapd %xmm7,%xmm1
divsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
xorps  %xmm2,%xmm2
cvtsi2ss %rax,%xmm2
movaps %xmm0,%xmm1
cvtss2sd %xmm2,%xmm2
addsd  0xd7e(%rip),%xmm2
cvtsd2ss %xmm2,%xmm8
xorps  0xd8a(%rip),%xmm0
mulss  %xmm6,%xmm1
add    $0x1,%r14d
xor    %ecx,%ecx
xorps  %xmm2,%xmm2
jmp    12ba <distributions_spirals+0x16a>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x1(%rcx),%eax
cmp    %r14d,%ecx
mov    %eax,%ecx
je     1311 <distributions_spirals+0x1c1>
test   %ebp,%ebp
jle    12b0 <distributions_spirals+0x160>
xorps  %xmm4,%xmm4
cvtsi2sd %ecx,%xmm4
mulsd  %xmm7,%xmm4
cvtsd2ss %xmm4,%xmm4
addss  %xmm8,%xmm4
xor    %eax,%eax
jmp    12e7 <distributions_spirals+0x197>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%eax
cmp    %eax,%ebp
je     12b0 <distributions_spirals+0x160>
xorps  %xmm5,%xmm5
cvtsi2ss %eax,%xmm5
mulss  %xmm0,%xmm5
addss  %xmm4,%xmm5
mulss  %xmm6,%xmm5
subss  %xmm3,%xmm5
ucomiss %xmm2,%xmm5
jb     12e0 <distributions_spirals+0x190>
ucomiss %xmm5,%xmm1
jbe    12e0 <distributions_spirals+0x190>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xd18(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [46 x i8] c"distributions_spirals- ERROR, arm not found.\0A\00"
define i32 @distributions_spirals(i32 %0, float %1, float %2, float* %3) {
%5 = alloca i32
%6 = alloca float
%7 = alloca float
%8 = alloca float*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
store i32 %0, i32* %5
store float %1, float* %6
store float %2, float* %7
store float* %3, float** %8
store float 0x4733426180000000, float* %12
%19 = load i32, i32* %5
%20 = sitofp i32 %19 to float
%21 = fpext float %20 to double
%22 = fdiv double 0x401921FB54442D18, %21
%23 = fptrunc double %22 to float
store float %23, float* %18
%24 = load float, float* %7
%25 = fpext float %24 to double
%26 = load float, float* %6
%27 = fpext float %26 to double
%28 = fmul double %27, 0x401921FB54442D18
%29 = fdiv double %25, %28
%30 = fptosi double %29 to i32
%31 = add nsw i32 1, %30
store i32 %31, i32* %11
%32 = load float, float* %18
%33 = load float, float* %6
%34 = fmul float %32, %33
store float %34, float* %14
%35 = load float*, float** %8
%36 = getelementptr inbounds float, float* %35, i64 0
store float 1.000000e+00, float* %36
br label %37
37: ; preds = %49, %4
%38 = load float*, float** %8
%39 = getelementptr inbounds float, float* %38, i64 0
%40 = load float, float* %39
%41 = fpext float %40 to double
%42 = fcmp une double %41, 0.000000e+00
br i1 %42, label %43, label %47
43: ; preds = %37
%44 = load float, float* %12
%45 = load float, float* %7
%46 = fcmp ogt float %44, %45
br label %47
47: ; preds = %43, %37
%48 = phi i1 [ false, %37 ], [ %46, %43 ]
br i1 %48, label %49, label %77
49: ; preds = %47
%50 = load float, float* %7
%51 = fneg float %50
%52 = load float, float* %7
%53 = call float @distributions_uniform(float %51, float %52)
%54 = load float*, float** %8
%55 = getelementptr inbounds float, float* %54, i64 0
store float %53, float* %55
%56 = load float, float* %7
%57 = fneg float %56
%58 = load float, float* %7
%59 = call float @distributions_uniform(float %57, float %58)
%60 = load float*, float** %8
%61 = getelementptr inbounds float, float* %60, i64 1
store float %59, float* %61
%62 = load float*, float** %8
%63 = getelementptr inbounds float, float* %62, i64 0
%64 = load float, float* %63
%65 = load float*, float** %8
%66 = getelementptr inbounds float, float* %65, i64 0
%67 = load float, float* %66
%68 = load float*, float** %8
%69 = getelementptr inbounds float, float* %68, i64 1
%70 = load float, float* %69
%71 = load float*, float** %8
%72 = getelementptr inbounds float, float* %71, i64 1
%73 = load float, float* %72
%74 = fmul float %70, %73
%75 = call float @llvm.fmuladd.f32(float %64, float %67, float %74)
%76 = call float @sqrt(float %75)
store float %76, float* %12
br label %37
77: ; preds = %47
%78 = load float*, float** %8
%79 = getelementptr inbounds float, float* %78, i64 1
%80 = load float, float* %79
%81 = load float*, float** %8
%82 = getelementptr inbounds float, float* %81, i64 0
%83 = load float, float* %82
%84 = call i64 @atan2(float %80, float %83)
%85 = sitofp i64 %84 to float
store float %85, float* %16
%86 = load float, float* %16
%87 = fpext float %86 to double
%88 = fadd double %87, 0x400921FB54442D18
%89 = fptrunc double %88 to float
store float %89, float* %16
store i32 0, i32* %10
br label %90
90: ; preds = %130, %77
%91 = load i32, i32* %10
%92 = load i32, i32* %11
%93 = icmp sle i32 %91, %92
br i1 %93, label %94, label %133
94: ; preds = %90
%95 = load i32, i32* %10
%96 = sitofp i32 %95 to double
%97 = fmul double %96, 0x401921FB54442D18
%98 = fptrunc double %97 to float
store float %98, float* %17
store i32 0, i32* %9
br label %99
99: ; preds = %126, %94
%100 = load i32, i32* %9
%101 = load i32, i32* %5
%102 = icmp slt i32 %100, %101
br i1 %102, label %103, label %129
103: ; preds = %99
%104 = load float, float* %6
%105 = load float, float* %16
%106 = load float, float* %17
%107 = fadd float %105, %106
%108 = load float, float* %18
%109 = load i32, i32* %9
%110 = sitofp i32 %109 to float
%111 = fneg float %108
%112 = call float @llvm.fmuladd.f32(float %111, float %110, float %107)
%113 = fmul float %104, %112
store float %113, float* %13
%114 = load float, float* %13
%115 = load float, float* %12
%116 = fsub float %114, %115
store float %116, float* %15
%117 = load float, float* %15
%118 = fpext float %117 to double
%119 = fcmp oge double %118, 0.000000e+00
br i1 %119, label %120, label %125
120: ; preds = %103
%121 = load float, float* %15
%122 = load float, float* %14
%123 = fcmp olt float %121, %122
br i1 %123, label %124, label %125
124: ; preds = %120
br label %136
125: ; preds = %120, %103
br label %126
126: ; preds = %125
%127 = load i32, i32* %9
%128 = add nsw i32 %127, 1
store i32 %128, i32* %9
br label %99
129: ; preds = %99
br label %130
130: ; preds = %129
%131 = load i32, i32* %10
%132 = add nsw i32 %131, 1
store i32 %132, i32* %10
br label %90
133: ; preds = %90
%134 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%135 = call i32 @exit(i32 0)
unreachable
136: ; preds = %124
%137 = load i32, i32* %9
ret i32 %137
}

LLVM IR (-O2):
@str = [45 x i8] c"distributions_spirals- ERROR, arm not found.\00"
define i32 @distributions_spirals(i32 %0, float %1, float %2, float* nocapture %3) {
%5 = sitofp i32 %0 to float
%6 = fpext float %5 to double
%7 = fdiv double 0x401921FB54442D18, %6
%8 = fptrunc double %7 to float
%9 = fpext float %2 to double
%10 = fpext float %1 to double
%11 = fmul double %10, 0x401921FB54442D18
%12 = fdiv double %9, %11
%13 = fptosi double %12 to i32
%14 = fmul float %8, %1
store float 1.000000e+00, float* %3
%15 = fcmp olt float %2, 0x4733426180000000
br i1 %15, label %16, label %30
16: ; preds = %4
%17 = fneg float %2
%18 = getelementptr inbounds float, float* %3, i64 1
br label %19
19: ; preds = %16, %19
%20 = tail call float @distributions_uniform(float %17, float %2)
store float %20, float* %3
%21 = tail call float @distributions_uniform(float %17, float %2)
store float %21, float* %18
%22 = load float, float* %3
%23 = fmul float %21, %21
%24 = tail call float @llvm.fmuladd.f32(float %22, float %22, float %23)
%25 = tail call float @sqrt(float %24)
%26 = load float, float* %3
%27 = fcmp une float %26, 0.000000e+00
%28 = fcmp ogt float %25, %2
%29 = select i1 %27, i1 %28, i1 false
br i1 %29, label %19, label %30
30: ; preds = %19, %4
%31 = phi float [ 0x4733426180000000, %4 ], [ %25, %19 ]
%32 = phi float [ 1.000000e+00, %4 ], [ %26, %19 ]
%33 = getelementptr inbounds float, float* %3, i64 1
%34 = load float, float* %33
%35 = tail call i64 @atan2(float %34, float %32)
%36 = sitofp i64 %35 to float
%37 = fpext float %36 to double
%38 = fadd double %37, 0x400921FB54442D18
%39 = fptrunc double %38 to float
%40 = icmp slt i32 %13, -1
br i1 %40, label %67, label %41
41: ; preds = %30
%42 = icmp sgt i32 %0, 0
%43 = fneg float %8
%44 = add i32 %13, 1
br label %45
45: ; preds = %41, %64
%46 = phi i32 [ 0, %41 ], [ %65, %64 ]
br i1 %42, label %47, label %64
47: ; preds = %45
%48 = sitofp i32 %46 to double
%49 = fmul double %48, 0x401921FB54442D18
%50 = fptrunc double %49 to float
%51 = fadd float %39, %50
br label %52
52: ; preds = %47, %61
%53 = phi i32 [ 0, %47 ], [ %62, %61 ]
%54 = sitofp i32 %53 to float
%55 = tail call float @llvm.fmuladd.f32(float %43, float %54, float %51)
%56 = fmul float %55, %1
%57 = fsub float %56, %31
%58 = fcmp oge float %57, 0.000000e+00
%59 = fcmp olt float %57, %14
%60 = and i1 %58, %59
br i1 %60, label %70, label %61
61: ; preds = %52
%62 = add nuw nsw i32 %53, 1
%63 = icmp eq i32 %62, %0
br i1 %63, label %64, label %52
64: ; preds = %61, %45
%65 = add nuw i32 %46, 1
%66 = icmp eq i32 %46, %44
br i1 %66, label %67, label %45
67: ; preds = %64, %30
%68 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%69 = tail call i32 @exit(i32 0)
unreachable
70: ; preds = %52
ret i32 %53
}