#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 EXIT_SUCCESS;
int add_coin(int, int);
int /*<<< orphan*/ clear_game_area();
int /*<<< orphan*/ display_game_area(int, int);
int /*<<< orphan*/ printf(char *, int);
int select_column(int);
int win(int, int);
int main(int argc, char *argv[]) {
  clear_game_area();
  int turn_counter = 0;
  int player = 2;
  int winner = 0;
  int column = 0;
  int row;
  do {
    switch (player) {
    case 1:
      player++;
      break;
    case 2:
      player--;
      turn_counter++;
      break;
    }
    display_game_area(column, player);
    row = -1;
    while (row == -1) {
      column = select_column(column);
      row = add_coin(player, column);
    }
    if (turn_counter >= 4) {
      winner = win(column, row);
    }
    display_game_area(column, player);
  } while (winner == 0);
  printf("The winner is player %d!\n", winner);
  return EXIT_SUCCESS;
}


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)
mov    $0x0,%al
call   1080 <clear_game_area@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x1,%eax
je     11be <main+0x5e>
jmp    11ad <main+0x4d>
mov    -0x28(%rbp),%eax
sub    $0x2,%eax
je     11cc <main+0x6c>
jmp    11de <main+0x7e>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11de <main+0x7e>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1070 <display_game_area@plt>
movl   $0xffffffff,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1218 <main+0xb8>
mov    -0x20(%rbp),%edi
call   1030 <select_column@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1060 <add_coin@plt>
mov    %eax,-0x24(%rbp)
jmp    11f0 <main+0x90>
cmpl   $0x4,-0x14(%rbp)
jl     1230 <main+0xd0>
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1050 <win@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1070 <display_game_area@plt>
cmpl   $0x0,-0x1c(%rbp)
je     1199 <main+0x39>
mov    -0x1c(%rbp),%esi
lea    0xdb1(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %r15d,%r15d
xor    %eax,%eax
call   1080 <clear_game_area@plt>
mov    $0x2,%ebx
xor    %ebp,%ebp
jmp    118e <main+0x2e>
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %ebx,%esi
call   1070 <display_game_area@plt>
test   %r14d,%r14d
jne    11ee <main+0x8e>
cmp    $0x2,%ebx
je     11a0 <main+0x40>
cmp    $0x1,%ebx
jne    11a9 <main+0x49>
mov    $0x2,%ebx
jmp    11a9 <main+0x49>
nop
add    $0x1,%r15d
mov    $0x1,%ebx
mov    %ebp,%edi
mov    %ebx,%esi
call   1070 <display_game_area@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edi
call   1030 <select_column@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %eax,%esi
call   1060 <add_coin@plt>
cmp    $0xffffffff,%eax
je     11c0 <main+0x60>
xor    %r14d,%r14d
cmp    $0x4,%r15d
jl     1180 <main+0x20>
mov    %ebp,%edi
mov    %eax,%esi
call   1050 <win@plt>
mov    %eax,%r14d
jmp    1180 <main+0x20>
lea    0xe0b(%rip),%rdi
mov    %r14d,%esi
call   1040 <printf@plt>
mov    0x2ddc(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"The winner is player %d!\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 (...) @clear_game_area()
store i32 0, i32* %6
store i32 2, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
br label %12
12: ; preds = %46, %2
%13 = load i32, i32* %7
switch i32 %13, label %22 [
i32 1, label %14
i32 2, label %17
]
14: ; preds = %12
%15 = load i32, i32* %7
%16 = add nsw i32 %15, 1
store i32 %16, i32* %7
br label %22
17: ; preds = %12
%18 = load i32, i32* %7
%19 = add nsw i32 %18, -1
store i32 %19, i32* %7
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
br label %22
22: ; preds = %12, %17, %14
%23 = load i32, i32* %9
%24 = load i32, i32* %7
%25 = call i32 @display_game_area(i32 %23, i32 %24)
store i32 -1, i32* %10
br label %26
26: ; preds = %29, %22
%27 = load i32, i32* %10
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = load i32, i32* %9
%31 = call i32 @select_column(i32 %30)
store i32 %31, i32* %9
%32 = load i32, i32* %7
%33 = load i32, i32* %9
%34 = call i32 @add_coin(i32 %32, i32 %33)
store i32 %34, i32* %10
br label %26
35: ; preds = %26
%36 = load i32, i32* %6
%37 = icmp sge i32 %36, 4
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = load i32, i32* %9
%40 = load i32, i32* %10
%41 = call i32 @win(i32 %39, i32 %40)
store i32 %41, i32* %8
br label %42
42: ; preds = %38, %35
%43 = load i32, i32* %9
%44 = load i32, i32* %7
%45 = call i32 @display_game_area(i32 %43, i32 %44)
br label %46
46: ; preds = %42
%47 = load i32, i32* %8
%48 = icmp eq i32 %47, 0
br i1 %48, label %12, label %49
49: ; preds = %46
%50 = load i32, i32* %8
%51 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %50)
%52 = load i32, i32* @EXIT_SUCCESS
ret i32 %52
}

LLVM IR (-O2):
@.str = [26 x i8] c"The winner is player %d!\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @clear_game_area()
br label %4
4: ; preds = %24, %2
%5 = phi i32 [ 0, %2 ], [ %12, %24 ]
%6 = phi i32 [ 2, %2 ], [ %13, %24 ]
%7 = phi i32 [ 0, %2 ], [ %17, %24 ]
switch i32 %6, label %11 [
i32 1, label %8
i32 2, label %9
]
8: ; preds = %4
br label %11
9: ; preds = %4
%10 = add nsw i32 %5, 1
br label %11
11: ; preds = %4, %9, %8
%12 = phi i32 [ %5, %4 ], [ %10, %9 ], [ %5, %8 ]
%13 = phi i32 [ %6, %4 ], [ 1, %9 ], [ 2, %8 ]
%14 = tail call i32 @display_game_area(i32 %7, i32 %13)
br label %15
15: ; preds = %11, %15
%16 = phi i32 [ %7, %11 ], [ %17, %15 ]
%17 = tail call i32 @select_column(i32 %16)
%18 = tail call i32 @add_coin(i32 %13, i32 %17)
%19 = icmp eq i32 %18, -1
br i1 %19, label %15, label %20
20: ; preds = %15
%21 = icmp sgt i32 %12, 3
br i1 %21, label %22, label %24
22: ; preds = %20
%23 = tail call i32 @win(i32 %17, i32 %18)
br label %24
24: ; preds = %22, %20
%25 = phi i32 [ %23, %22 ], [ 0, %20 ]
%26 = tail call i32 @display_game_area(i32 %17, i32 %13)
%27 = icmp eq i32 %25, 0
br i1 %27, label %4, label %28
28: ; preds = %24
%29 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %25)
%30 = load i32, i32* @EXIT_SUCCESS
ret i32 %30
}