#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 */
int /*<<< orphan*/ dswap(double *, double *);
int random_int(double);
void randomize_dvector(double *v, double n) {
  int rpos = 0;
  for (int i = 0; i < n; i++) {
    rpos = random_int(n - 1);
    dswap(&v[rpos], &v[i]);
  }
}


x86 assembly (clang, -O0):
<randomize_dvector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cvtsi2sdl -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    119d <randomize_dvector+0x7d>
movsd  -0x10(%rbp),%xmm0
movsd  0xea0(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1040 <random_int@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
call   1030 <dswap@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113f <randomize_dvector+0x1f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randomize_dvector>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xorpd  %xmm1,%xmm1
movsd  %xmm0,(%rsp)
ucomisd %xmm1,%xmm0
jbe    1192 <randomize_dvector+0x72>
mov    %rdi,%r14
movsd  0xebe(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%ebp
mov    %rdi,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  0x8(%rsp),%xmm0
call   1040 <random_int@plt>
cltq
lea    (%r14,%rax,8),%rdi
mov    %rbx,%rsi
call   1030 <dswap@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
add    $0x8,%rbx
add    $0x1,%ebp
movsd  (%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     1160 <randomize_dvector+0x40>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @randomize_dvector(double* %0, double %1) {
%3 = alloca double*
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
store double* %0, double** %3
store double %1, double* %4
store i32 0, i32* %5
store i32 0, i32* %6
br label %7
7: ; preds = %25, %2
%8 = load i32, i32* %6
%9 = sitofp i32 %8 to double
%10 = load double, double* %4
%11 = fcmp olt double %9, %10
br i1 %11, label %12, label %28
12: ; preds = %7
%13 = load double, double* %4
%14 = fsub double %13, 1.000000e+00
%15 = call i32 @random_int(double %14)
store i32 %15, i32* %5
%16 = load double*, double** %3
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %16, i64 %18
%20 = load double*, double** %3
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
%24 = call i32 @dswap(double* %19, double* %23)
br label %25
25: ; preds = %12
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %7
28: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @randomize_dvector(double* %0, double %1) {
%3 = fcmp ogt double %1, 0.000000e+00
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = fadd double %1, -1.000000e+00
br label %7
6: ; preds = %7, %2
ret void
7: ; preds = %4, %7
%8 = phi i64 [ 0, %4 ], [ %14, %7 ]
%9 = tail call i32 @random_int(double %5)
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds double, double* %0, i64 %10
%12 = getelementptr inbounds double, double* %0, i64 %8
%13 = tail call i32 @dswap(double* %11, double* %12)
%14 = add nuw i64 %8, 1
%15 = trunc i64 %14 to i32
%16 = sitofp i32 %15 to double
%17 = fcmp olt double %16, %1
br i1 %17, label %7, label %6
}