#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 */
struct battle_char {
  int dummy;
};

/* Variables and functions */
int get_random(int /*<<< orphan*/, int);
void shuffle_battle_order(struct battle_char **pblist, int num) {
  int i;
  int r;
  struct battle_char *tmp;
  for (i = 0; i < num; i++) {
    r = get_random(0, num);
    tmp = pblist[r];
    pblist[r] = pblist[i];
    pblist[i] = tmp;
  }
}


x86 assembly (clang, -O0):
<shuffle_battle_order>:
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    1185 <shuffle_battle_order+0x75>
mov    -0xc(%rbp),%esi
xor    %edi,%edi
call   1030 <get_random@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rdx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <shuffle_battle_order+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shuffle_battle_order>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    1155 <shuffle_battle_order+0x45>
mov    %esi,%r14d
mov    %rdi,%rbx
mov    %esi,%r15d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %r14d,%esi
call   1030 <get_random@plt>
cltq
mov    (%rbx,%rax,8),%rcx
mov    (%rbx,%rbp,8),%rdx
mov    %rdx,(%rbx,%rax,8)
mov    %rcx,(%rbx,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1130 <shuffle_battle_order+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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