#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 Player {
  int dummy;
};
struct Config {
  int dummy;
};

/* Variables and functions */
struct Config *config_construct(int, int, int, int);
int /*<<< orphan*/ config_destruct(struct Config *);
int /*<<< orphan*/ create_players(struct Player **, int, struct Config *);
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ free(struct Player **);
int /*<<< orphan*/ initialize_curses();
struct Player **malloc(int);
int /*<<< orphan*/ player_destruct(struct Player *);
int /*<<< orphan*/ run_game(struct Player **);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int i;
  struct Player **players = NULL;
  struct Config *config = NULL;
  srand(time(NULL));
  initialize_curses();
  players = malloc(sizeof(*players) * 2);
  config = config_construct(10, 10, 10, 4);
  create_players(players, 2, config);
  run_game(players);
  for (i = 0; i < 2; ++i)
    player_destruct(players[i]);
  config_destruct(config);
  free(players);
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0x0,%al
call   1060 <initialize_curses@plt>
mov    $0x10,%edi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0xa,%edx
mov    $0x4,%ecx
mov    %edx,%edi
mov    %edx,%esi
call   1040 <config_construct@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x2,%esi
call   10c0 <create_players@plt>
mov    -0x20(%rbp),%rdi
call   10a0 <run_game@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jge    125d <main+0xad>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <player_destruct@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1234 <main+0x84>
mov    -0x28(%rbp),%rdi
call   10b0 <config_destruct@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   10d0 <endwin@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1060 <initialize_curses@plt>
mov    $0x10,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    $0xa,%edi
mov    $0xa,%esi
mov    $0xa,%edx
mov    $0x4,%ecx
call   1040 <config_construct@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %rax,%rdx
call   10c0 <create_players@plt>
mov    %rbx,%rdi
call   10a0 <run_game@plt>
mov    (%rbx),%rdi
call   1070 <player_destruct@plt>
mov    0x8(%rbx),%rdi
call   1070 <player_destruct@plt>
mov    %r14,%rdi
call   10b0 <config_destruct@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   10d0 <endwin@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.Player = type { i32 }
%struct.Config = type { i32 }
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.Player**
%8 = alloca %struct.Config*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.Player** null, %struct.Player*** %7
store %struct.Config* null, %struct.Config** %8
%9 = call i32 @time(i32* null)
%10 = call i32 @srand(i32 %9)
%11 = call i32 (...) @initialize_curses()
%12 = call %struct.Player** @malloc(i32 16)
store %struct.Player** %12, %struct.Player*** %7
%13 = call %struct.Config* @config_construct(i32 10, i32 10, i32 10, i32 4)
store %struct.Config* %13, %struct.Config** %8
%14 = load %struct.Player**, %struct.Player*** %7
%15 = load %struct.Config*, %struct.Config** %8
%16 = call i32 @create_players(%struct.Player** %14, i32 2, %struct.Config* %15)
%17 = load %struct.Player**, %struct.Player*** %7
%18 = call i32 @run_game(%struct.Player** %17)
store i32 0, i32* %6
br label %19
19: ; preds = %29, %2
%20 = load i32, i32* %6
%21 = icmp slt i32 %20, 2
br i1 %21, label %22, label %32
22: ; preds = %19
%23 = load %struct.Player**, %struct.Player*** %7
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds %struct.Player*, %struct.Player** %23, i64 %25
%27 = load %struct.Player*, %struct.Player** %26
%28 = call i32 @player_destruct(%struct.Player* %27)
br label %29
29: ; preds = %22
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %19
32: ; preds = %19
%33 = load %struct.Config*, %struct.Config** %8
%34 = call i32 @config_destruct(%struct.Config* %33)
%35 = load %struct.Player**, %struct.Player*** %7
%36 = call i32 @free(%struct.Player** %35)
%37 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
%struct.Player = type { i32 }
%struct.Config = type { i32 }
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = tail call i32 (...) @initialize_curses()
%6 = tail call %struct.Player** @malloc(i32 16)
%7 = tail call %struct.Config* @config_construct(i32 10, i32 10, i32 10, i32 4)
%8 = tail call i32 @create_players(%struct.Player** %6, i32 2, %struct.Config* %7)
%9 = tail call i32 @run_game(%struct.Player** %6)
%10 = load %struct.Player*, %struct.Player** %6
%11 = tail call i32 @player_destruct(%struct.Player* %10)
%12 = getelementptr inbounds %struct.Player*, %struct.Player** %6, i64 1
%13 = load %struct.Player*, %struct.Player** %12
%14 = tail call i32 @player_destruct(%struct.Player* %13)
%15 = tail call i32 @config_destruct(%struct.Config* %7)
%16 = tail call i32 @free(%struct.Player** %6)
%17 = tail call i32 (...) @endwin()
ret i32 0
}