#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 Ran();
void RandomizeFreqs(size_t *freqs, int n) {
  int i;
  for (i = 0; i < n; i++) {
    if ((Ran() >> 4) % 3 == 0)
      freqs[i] = freqs[Ran() % n];
  }
}


x86 assembly (clang, -O0):
<RandomizeFreqs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118a <RandomizeFreqs+0x7a>
mov    $0x0,%al
call   1030 <Ran@plt>
sar    $0x4,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1177 <RandomizeFreqs+0x67>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <Ran@plt>
cltd
idivl  -0xc(%rbp)
mov    -0x18(%rbp),%rax
movslq %edx,%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    117c <RandomizeFreqs+0x6c>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <RandomizeFreqs+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RandomizeFreqs>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    116d <RandomizeFreqs+0x5d>
mov    %esi,%r14d
mov    %rdi,%r15
mov    %esi,%ebp
xor    %ebx,%ebx
jmp    1139 <RandomizeFreqs+0x29>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%rbp
je     116d <RandomizeFreqs+0x5d>
xor    %eax,%eax
call   1030 <Ran@plt>
sar    $0x4,%eax
imul   $0xaaaaaaab,%eax,%eax
add    $0x2aaaaaaa,%eax
cmp    $0x55555554,%eax
ja     1130 <RandomizeFreqs+0x20>
xor    %eax,%eax
call   1030 <Ran@plt>
cltd
idiv   %r14d
movslq %edx,%rax
mov    (%r15,%rax,8),%rax
mov    %rax,(%r15,%rbx,8)
jmp    1130 <RandomizeFreqs+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @RandomizeFreqs(i64* %0, i32 %1) {
%3 = alloca i64*
%4 = alloca i32
%5 = alloca i32
store i64* %0, i64** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %28, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %31
10: ; preds = %6
%11 = call i32 (...) @Ran()
%12 = ashr i32 %11, 4
%13 = srem i32 %12, 3
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %27
15: ; preds = %10
%16 = load i64*, i64** %3
%17 = call i32 (...) @Ran()
%18 = load i32, i32* %4
%19 = srem i32 %17, %18
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i64, i64* %16, i64 %20
%22 = load i64, i64* %21
%23 = load i64*, i64** %3
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i64, i64* %23, i64 %25
store i64 %22, i64* %26
br label %27
27: ; preds = %15, %10
br label %28
28: ; preds = %27
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %6
31: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @RandomizeFreqs(i64* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %22
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %19
%7 = phi i64 [ 0, %4 ], [ %20, %19 ]
%8 = tail call i32 (...) @Ran()
%9 = ashr i32 %8, 4
%10 = srem i32 %9, 3
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %6
%13 = tail call i32 (...) @Ran()
%14 = srem i32 %13, %1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i64, i64* %0, i64 %15
%17 = load i64, i64* %16
%18 = getelementptr inbounds i64, i64* %0, i64 %7
store i64 %17, i64* %18
br label %19
19: ; preds = %6, %12
%20 = add nuw nsw i64 %7, 1
%21 = icmp eq i64 %20, %5
br i1 %21, label %22, label %6
22: ; preds = %19, %2
ret void
}