#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*/ swap(size_t *, unsigned int, unsigned int);
void threadscan_util_randomize(size_t *addrs, int n) {
  unsigned int i;
  for (i = 0; i < n; ++i) {
    unsigned int tmp = (i * 2147483647) % n;
    if (i != tmp) {
      swap(addrs, i, tmp);
    }
  }
}


x86 assembly (clang, -O0):
<threadscan_util_randomize>:
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
jae    116f <threadscan_util_randomize+0x5f>
imul   $0x7fffffff,-0x10(%rbp),%eax
xor    %edx,%edx
divl   -0xc(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     115c <threadscan_util_randomize+0x4c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <swap@plt>
jmp    1161 <threadscan_util_randomize+0x51>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <threadscan_util_randomize+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<threadscan_util_randomize>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
je     1155 <threadscan_util_randomize+0x45>
mov    %esi,%r15d
mov    %rdi,%r14
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    113e <threadscan_util_randomize+0x2e>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebx
add    $0x7fffffff,%ebp
cmp    %ebx,%r15d
je     1155 <threadscan_util_randomize+0x45>
mov    %ebp,%eax
xor    %edx,%edx
div    %r15d
cmp    %edx,%ebx
je     1130 <threadscan_util_randomize+0x20>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <swap@plt>
jmp    1130 <threadscan_util_randomize+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @threadscan_util_randomize(i64* %0, i32 %1) {
%3 = alloca i64*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i64* %0, i64** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %25, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp ult i32 %8, %9
br i1 %10, label %11, label %28
11: ; preds = %7
%12 = load i32, i32* %5
%13 = mul i32 %12, 2147483647
%14 = load i32, i32* %4
%15 = urem i32 %13, %14
store i32 %15, i32* %6
%16 = load i32, i32* %5
%17 = load i32, i32* %6
%18 = icmp ne i32 %16, %17
br i1 %18, label %19, label %24
19: ; preds = %11
%20 = load i64*, i64** %3
%21 = load i32, i32* %5
%22 = load i32, i32* %6
%23 = call i32 @swap(i64* %20, i32 %21, i32 %22)
br label %24
24: ; preds = %19, %11
br label %25
25: ; preds = %24
%26 = load i32, i32* %5
%27 = add i32 %26, 1
store i32 %27, i32* %5
br label %7
28: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @threadscan_util_randomize(i64* %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %14, label %4
4: ; preds = %2, %11
%5 = phi i32 [ %12, %11 ], [ 0, %2 ]
%6 = mul i32 %5, 2147483647
%7 = urem i32 %6, %1
%8 = icmp eq i32 %5, %7
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = tail call i32 @swap(i64* %0, i32 %5, i32 %7)
br label %11
11: ; preds = %9, %4
%12 = add nuw i32 %5, 1
%13 = icmp eq i32 %12, %1
br i1 %13, label %14, label %4
14: ; preds = %11, %2
ret void
}