#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 assign(int, int);
int /*<<< orphan*/ box();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int varification(int);
void choice() {
  printf("\t***## THIS IS A PEEBLE DROPING GAME ##***\n\n\n");
  printf("**This game is human vs human.\n");
  printf("**Play by selecting columns.\n\n");
  int i;
  for (i = 0; i < 30;) {
    box();
    int p;
    if (i % 2 == 0)
      p = 1;
    else
      p = 2;
    printf("##Player %d\n", p);
    int sel;
    printf("Select a column (1-5): ");
    scanf("%d", &sel);
    printf("\n");
    if (sel < 1 || sel > 5) {
      printf("**Wrong input1!\a");
      continue;
    } else {
      int assi = assign(sel, i);
      if (assi == 1) {
        printf("\nInvalid move!\a");
        continue;
      }
    }
    int r;
    r = varification(i);
    if (r == 1) {
      box();
      printf("\a\a\n**# Player %d wins! #**\a\n", p);
      break;
    } else if (i == 29) {
      box();
      printf("\n**The match is draw.\n");
      break;
    }
    i++;
  }
  return;
}


x86 assembly (clang, -O0):
<choice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x1e,-0x4(%rbp)
jge    12be <choice+0x16e>
mov    $0x0,%al
call   1040 <box@plt>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11ba <choice+0x6a>
movl   $0x1,-0x8(%rbp)
jmp    11c1 <choice+0x71>
movl   $0x2,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeab(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0xc(%rbp)
jl     1212 <choice+0xc2>
cmpl   $0x5,-0xc(%rbp)
jle    1225 <choice+0xd5>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1189 <choice+0x39>
mov    -0xc(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1070 <assign@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    1250 <choice+0x100>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1189 <choice+0x39>
jmp    1255 <choice+0x105>
mov    -0x4(%rbp),%edi
call   1050 <varification@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    1287 <choice+0x137>
mov    $0x0,%al
call   1040 <box@plt>
mov    -0x8(%rbp),%esi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12be <choice+0x16e>
cmpl   $0x1d,-0x4(%rbp)
jne    12ab <choice+0x15b>
mov    $0x0,%al
call   1040 <box@plt>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12be <choice+0x16e>
jmp    12b0 <choice+0x160>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1189 <choice+0x39>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<choice>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xee4(%rip),%rdi
call   1040 <puts@plt>
lea    0xf05(%rip),%rdi
call   1040 <puts@plt>
lea    0xf18(%rip),%rdi
call   1040 <puts@plt>
lea    0xe5a(%rip),%r14
lea    0xe60(%rip),%r15
lea    0xe71(%rip),%r12
lea    0x4(%rsp),%rbx
xor    %r13d,%r13d
jmp    11ce <choice+0x5e>
xchg   %ax,%ax
lea    0xe61(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <box@plt>
mov    %r13d,%ebp
and    $0x1,%ebp
add    $0x1,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%edi
lea    -0x6(%rdi),%eax
cmp    $0xfffffffa,%eax
jbe    11c0 <choice+0x50>
mov    %r13d,%esi
call   1090 <assign@plt>
cmp    $0x1,%eax
jne    1230 <choice+0xc0>
lea    0xe10(%rip),%rdi
jmp    11c7 <choice+0x57>
nopl   0x0(%rax,%rax,1)
mov    %r13d,%edi
call   1070 <varification@plt>
cmp    $0x1,%eax
je     1249 <choice+0xd9>
cmp    $0x1d,%r13d
je     1262 <choice+0xf2>
add    $0x1,%r13d
jmp    11ce <choice+0x5e>
xor    %eax,%eax
call   1060 <box@plt>
lea    0xdf2(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1275 <choice+0x105>
xor    %eax,%eax
call   1060 <box@plt>
lea    0xe60(%rip),%rdi
call   1040 <puts@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"\09***## THIS IS A PEEBLE DROPING GAME ##***\0A\0A\0A\00"
@.str.1 = [32 x i8] c"**This game is human vs human.\0A\00"
@.str.2 = [31 x i8] c"**Play by selecting columns.\0A\0A\00"
@.str.3 = [13 x i8] c"##Player %d\0A\00"
@.str.4 = [24 x i8] c"Select a column (1-5): \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [2 x i8] c"\0A\00"
@.str.7 = [17 x i8] c"**Wrong input1!\07\00"
@.str.8 = [16 x i8] c"\0AInvalid move!\07\00"
@.str.9 = [29 x i8] c"\07\07\0A**# Player %d wins! #**\07\0A\00"
@.str.10 = [23 x i8] c"\0A**The match is draw.\0A\00"
define void @choice() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %9
9: ; preds = %57, %38, %30, %0
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 30
br i1 %11, label %12, label %60
12: ; preds = %9
%13 = call i32 (...) @box()
%14 = load i32, i32* %1
%15 = srem i32 %14, 2
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 1, i32* %2
br label %19
18: ; preds = %12
store i32 2, i32* %2
br label %19
19: ; preds = %18, %17
%20 = load i32, i32* %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%25 = load i32, i32* %3
%26 = icmp slt i32 %25, 1
br i1 %26, label %30, label %27
27: ; preds = %19
%28 = load i32, i32* %3
%29 = icmp sgt i32 %28, 5
br i1 %29, label %30, label %32
30: ; preds = %27, %19
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
br label %9
32: ; preds = %27
%33 = load i32, i32* %3
%34 = load i32, i32* %1
%35 = call i32 @assign(i32 %33, i32 %34)
store i32 %35, i32* %4
%36 = load i32, i32* %4
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %40
38: ; preds = %32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
br label %9
40: ; preds = %32
br label %41
41: ; preds = %40
%42 = load i32, i32* %1
%43 = call i32 @varification(i32 %42)
store i32 %43, i32* %5
%44 = load i32, i32* %5
%45 = icmp eq i32 %44, 1
br i1 %45, label %46, label %50
46: ; preds = %41
%47 = call i32 (...) @box()
%48 = load i32, i32* %2
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i32 %48)
br label %60
50: ; preds = %41
%51 = load i32, i32* %1
%52 = icmp eq i32 %51, 29
br i1 %52, label %53, label %56
53: ; preds = %50
%54 = call i32 (...) @box()
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0))
br label %60
56: ; preds = %50
br label %57
57: ; preds = %56
%58 = load i32, i32* %1
%59 = add nsw i32 %58, 1
store i32 %59, i32* %1
br label %9
60: ; preds = %53, %46, %9
ret void
}

LLVM IR (-O2):
@.str.3 = [13 x i8] c"##Player %d\0A\00"
@.str.4 = [24 x i8] c"Select a column (1-5): \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.7 = [17 x i8] c"**Wrong input1!\07\00"
@.str.8 = [16 x i8] c"\0AInvalid move!\07\00"
@.str.9 = [29 x i8] c"\07\07\0A**# Player %d wins! #**\07\0A\00"
@str = [45 x i8] c"\09***## THIS IS A PEEBLE DROPING GAME ##***\0A\0A\00"
@str.11 = [31 x i8] c"**This game is human vs human.\00"
@str.12 = [30 x i8] c"**Play by selecting columns.\0A\00"
@str.13 = [22 x i8] c"\0A**The match is draw.\00"
define void @choice() {
%1 = alloca i32
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.11, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.12, i64 0, i64 0))
%5 = bitcast i32* %1 to i8*
br label %6
6: ; preds = %39, %0
%7 = phi i32 [ 0, %0 ], [ %40, %39 ]
%8 = call i32 (...) @box()
%9 = and i32 %7, 1
%10 = icmp eq i32 %9, 0
%11 = select i1 %10, i32 1, i32 2
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%15 = call i32 @putchar(i32 10)
%16 = load i32, i32* %1
%17 = add i32 %16, -6
%18 = icmp ult i32 %17, -5
br i1 %18, label %19, label %21
19: ; preds = %6
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
br label %39
21: ; preds = %6
%22 = call i32 @assign(i32 %16, i32 %7)
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
br label %39
26: ; preds = %21
%27 = call i32 @varification(i32 %7)
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = call i32 (...) @box()
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i32 %11)
br label %41
32: ; preds = %26
%33 = icmp eq i32 %7, 29
br i1 %33, label %34, label %37
34: ; preds = %32
%35 = call i32 (...) @box()
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.13, i64 0, i64 0))
br label %41
37: ; preds = %32
%38 = add nsw i32 %7, 1
br label %39
39: ; preds = %24, %37, %19
%40 = phi i32 [ %7, %19 ], [ %38, %37 ], [ %7, %24 ]
br label %6
41: ; preds = %29, %34
ret void
}