#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*/ map_setmessage(char *);
int /*<<< orphan*/ marker_move(int);
int /*<<< orphan*/ pregame(int, int);
int rand();
int pregame_routine() {
  marker_move(1);
  int player, p;
  p = rand() % 4;
  for (player = 0; player < 4; player++)
    pregame((player + p) % 4, 0);
  for (player = 3; player >= 0; player--)
    pregame((player + p) % 4, 1);
  map_setmessage("");
  return p;
}


x86 assembly (clang, -O0):
<pregame_routine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%edi
call   1030 <marker_move@plt>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x4,-0x4(%rbp)
jge    119a <pregame_routine+0x5a>
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
xor    %esi,%esi
call   1050 <pregame@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    116b <pregame_routine+0x2b>
movl   $0x3,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     11d3 <pregame_routine+0x93>
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
mov    $0x1,%esi
call   1050 <pregame@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    11a1 <pregame_routine+0x61>
lea    0xe26(%rip),%rdi
call   1040 <map_setmessage@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pregame_routine>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x1,%edi
call   1030 <marker_move@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%r14d
lea    0x3(%r14),%ebp
test   %eax,%eax
cmovns %eax,%ebp
and    $0xfffffffc,%ebp
mov    %eax,%ebx
sub    %ebp,%ebx
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <pregame@plt>
lea    0x1(%rbx),%eax
mov    %eax,%ecx
sar    $0x7,%cl
shr    $0x6,%cl
add    %al,%cl
and    $0xfc,%cl
sub    %cl,%al
movsbl %al,%r15d
mov    %r15d,%edi
xor    %esi,%esi
call   1050 <pregame@plt>
lea    0x2(%rbx),%eax
mov    %eax,%ecx
sar    $0x7,%cl
shr    $0x6,%cl
add    %al,%cl
and    $0xfc,%cl
sub    %cl,%al
movsbl %al,%r12d
mov    %r12d,%edi
xor    %esi,%esi
call   1050 <pregame@plt>
neg    %ebp
add    %r14d,%ebp
add    $0xffffffff,%ebp
and    $0x3,%ebp
mov    %ebp,%edi
xor    %esi,%esi
call   1050 <pregame@plt>
mov    %ebp,%edi
mov    $0x1,%esi
call   1050 <pregame@plt>
mov    %r12d,%edi
mov    $0x1,%esi
call   1050 <pregame@plt>
mov    %r15d,%edi
mov    $0x1,%esi
call   1050 <pregame@plt>
mov    %ebx,%edi
mov    $0x1,%esi
call   1050 <pregame@plt>
lea    0xdfe(%rip),%rdi
call   1040 <map_setmessage@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i32 @pregame_routine() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @marker_move(i32 1)
%4 = call i32 (...) @rand()
%5 = srem i32 %4, 4
store i32 %5, i32* %2
store i32 0, i32* %1
br label %6
6: ; preds = %15, %0
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = load i32, i32* %1
%11 = load i32, i32* %2
%12 = add nsw i32 %10, %11
%13 = srem i32 %12, 4
%14 = call i32 @pregame(i32 %13, i32 0)
br label %15
15: ; preds = %9
%16 = load i32, i32* %1
%17 = add nsw i32 %16, 1
store i32 %17, i32* %1
br label %6
18: ; preds = %6
store i32 3, i32* %1
br label %19
19: ; preds = %28, %18
%20 = load i32, i32* %1
%21 = icmp sge i32 %20, 0
br i1 %21, label %22, label %31
22: ; preds = %19
%23 = load i32, i32* %1
%24 = load i32, i32* %2
%25 = add nsw i32 %23, %24
%26 = srem i32 %25, 4
%27 = call i32 @pregame(i32 %26, i32 1)
br label %28
28: ; preds = %22
%29 = load i32, i32* %1
%30 = add nsw i32 %29, -1
store i32 %30, i32* %1
br label %19
31: ; preds = %19
%32 = call i32 @map_setmessage(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i32 @pregame_routine() {
%1 = tail call i32 @marker_move(i32 1)
%2 = tail call i32 (...) @rand()
%3 = srem i32 %2, 4
%4 = tail call i32 @pregame(i32 %3, i32 0)
%5 = trunc i32 %3 to i8
%6 = add i8 %5, 1
%7 = srem i8 %6, 4
%8 = sext i8 %7 to i32
%9 = tail call i32 @pregame(i32 %8, i32 0)
%10 = trunc i32 %3 to i8
%11 = add i8 %10, 2
%12 = srem i8 %11, 4
%13 = sext i8 %12 to i32
%14 = tail call i32 @pregame(i32 %13, i32 0)
%15 = add nsw i32 %3, 3
%16 = and i32 %15, 3
%17 = tail call i32 @pregame(i32 %16, i32 0)
%18 = tail call i32 @pregame(i32 %16, i32 1)
%19 = tail call i32 @pregame(i32 %13, i32 1)
%20 = tail call i32 @pregame(i32 %8, i32 1)
%21 = tail call i32 @pregame(i32 %3, i32 1)
%22 = tail call i32 @map_setmessage(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
ret i32 %3
}