#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 RAND_MAX;
scalar_t__ rand();
int /*<<< orphan*/ srand(unsigned int);
int /*<<< orphan*/ swop(char **, int, int);
scalar_t__ time(int /*<<< orphan*/ *);
void shuffle(int size, char *arr[]) {
  srand((unsigned int)time(NULL));
  for (int i = 0; i < size; i++) {
    int j = size * ((double)rand() / RAND_MAX);
    if (i != j)
      swop(arr, i, j);
  }
}


x86 assembly (clang, -O0):
<shuffle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11d1 <shuffle+0x91>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
movsd  -0x20(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
mov    0x2e54(%rip),%rax
divsd  (%rax),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     11be <shuffle+0x7e>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1030 <swop@plt>
jmp    11c3 <shuffle+0x83>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1166 <shuffle+0x26>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shuffle>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebp
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
test   %ebp,%ebp
jle    11b4 <shuffle+0x74>
cvtsi2sd %ebp,%xmm0
movsd  %xmm0,(%rsp)
mov    0x2e7a(%rip),%r15
xor    %ebx,%ebx
jmp    1187 <shuffle+0x47>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebx
cmp    %ebx,%ebp
je     11b4 <shuffle+0x74>
xor    %eax,%eax
call   1060 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r15),%xmm0
mulsd  (%rsp),%xmm0
cvttsd2si %xmm0,%edx
cmp    %edx,%ebx
je     1180 <shuffle+0x40>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <swop@plt>
jmp    1180 <shuffle+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define void @shuffle(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = call i64 @time(i32* null)
%8 = trunc i64 %7 to i32
%9 = call i32 @srand(i32 %8)
store i32 0, i32* %5
br label %10
10: ; preds = %32, %2
%11 = load i32, i32* %5
%12 = load i32, i32* %3
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %35
14: ; preds = %10
%15 = load i32, i32* %3
%16 = sitofp i32 %15 to double
%17 = call i64 (...) @rand()
%18 = sitofp i64 %17 to double
%19 = load double, double* @RAND_MAX
%20 = fdiv double %18, %19
%21 = fmul double %16, %20
%22 = fptosi double %21 to i32
store i32 %22, i32* %6
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = icmp ne i32 %23, %24
br i1 %25, label %26, label %31
26: ; preds = %14
%27 = load i8**, i8*** %4
%28 = load i32, i32* %5
%29 = load i32, i32* %6
%30 = call i32 @swop(i8** %27, i32 %28, i32 %29)
br label %31
31: ; preds = %26, %14
br label %32
32: ; preds = %31
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %10
35: ; preds = %10
ret void
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define void @shuffle(i32 %0, i8** %1) {
%3 = tail call i64 @time(i32* null)
%4 = trunc i64 %3 to i32
%5 = tail call i32 @srand(i32 %4)
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = sitofp i32 %0 to double
br label %10
9: ; preds = %21, %2
ret void
10: ; preds = %7, %21
%11 = phi i32 [ 0, %7 ], [ %22, %21 ]
%12 = tail call i64 (...) @rand()
%13 = sitofp i64 %12 to double
%14 = load double, double* @RAND_MAX
%15 = fdiv double %13, %14
%16 = fmul double %15, %8
%17 = fptosi double %16 to i32
%18 = icmp eq i32 %11, %17
br i1 %18, label %21, label %19
19: ; preds = %10
%20 = tail call i32 @swop(i8** %1, i32 %11, i32 %17)
br label %21
21: ; preds = %19, %10
%22 = add nuw nsw i32 %11, 1
%23 = icmp eq i32 %22, %0
br i1 %23, label %9, label %10
}