#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*/ ai_turn(int);
int /*<<< orphan*/ data_endturn();
scalar_t__ data_isai(int);
int data_numplayers();
int /*<<< orphan*/ player_turn(int);
void main_routine() {
  int player = 0;
  while (1) {
    if (data_isai(player))
      ai_turn(player);
    else
      player_turn(player);
    if (++player == data_numplayers()) {
      data_endturn();
      player = 0;
    }
  }
}


x86 assembly (clang, -O0):
<main_routine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <data_isai@plt>
cmp    $0x0,%rax
je     117e <main_routine+0x2e>
mov    -0x4(%rbp),%edi
call   1050 <ai_turn@plt>
jmp    1186 <main_routine+0x36>
mov    -0x4(%rbp),%edi
call   1040 <player_turn@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1070 <data_numplayers@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
cmp    %ecx,%eax
jne    11b4 <main_routine+0x64>
mov    $0x0,%al
call   1060 <data_endturn@plt>
movl   $0x0,-0x4(%rbp)
jmp    115f <main_routine+0xf>

x86 assembly (clang, -O2):
<main_routine>:
push   %rbx
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%edi
call   1030 <data_isai@plt>
mov    %ebx,%edi
test   %rax,%rax
je     1180 <main_routine+0x30>
call   1050 <ai_turn@plt>
jmp    1185 <main_routine+0x35>
cs nopw 0x0(%rax,%rax,1)
nop
call   1040 <player_turn@plt>
add    $0x1,%ebx
xor    %eax,%eax
call   1070 <data_numplayers@plt>
cmp    %eax,%ebx
jne    1160 <main_routine+0x10>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <data_endturn@plt>
jmp    1160 <main_routine+0x10>

LLVM IR (-O0):
define void @main_routine() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %0, %19
%3 = load i32, i32* %1
%4 = call i64 @data_isai(i32 %3)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* %1
%8 = call i32 @ai_turn(i32 %7)
br label %12
9: ; preds = %2
%10 = load i32, i32* %1
%11 = call i32 @player_turn(i32 %10)
br label %12
12: ; preds = %9, %6
%13 = load i32, i32* %1
%14 = add nsw i32 %13, 1
store i32 %14, i32* %1
%15 = call i32 (...) @data_numplayers()
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = call i32 (...) @data_endturn()
store i32 0, i32* %1
br label %19
19: ; preds = %17, %12
br label %2
}

LLVM IR (-O2):
define void @main_routine() {
br label %1
1: ; preds = %15, %0
%2 = phi i32 [ 0, %0 ], [ %16, %15 ]
%3 = tail call i64 @data_isai(i32 %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = tail call i32 @ai_turn(i32 %2)
br label %9
7: ; preds = %1
%8 = tail call i32 @player_turn(i32 %2)
br label %9
9: ; preds = %7, %5
%10 = add nsw i32 %2, 1
%11 = tail call i32 (...) @data_numplayers()
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call i32 (...) @data_endturn()
br label %15
15: ; preds = %13, %9
%16 = phi i32 [ 0, %13 ], [ %10, %9 ]
br label %1
}