#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*/ printf(char *, ...);
int place_piece(int col, int player, char b[7][6 + 1]) {
  if (col < 0 || col > 7 - 1) {
    printf("ERROR: Faulty column: %d.\n", col);
    return 1;
  }
  if (b[col][6] >= 6) {
    return 1;
  }
  if (player == 1)
    b[col][(int)b[col][6]] = 'o';
  else if (player == 2)
    b[col][(int)b[col][6]] = 'x';
  else {
    printf("ERROR: Unknown player.\n");
    return 1;
  }
  b[col][6]++;
  return 0;
}


x86 assembly (clang, -O0):
<place_piece>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1136 <place_piece+0x26>
cmpl   $0x6,-0x8(%rbp)
jle    1153 <place_piece+0x43>
mov    -0x8(%rbp),%esi
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1229 <place_piece+0x119>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
imul   $0x7,%rcx,%rcx
add    %rcx,%rax
movsbl 0x6(%rax),%eax
cmp    $0x6,%eax
jl     117b <place_piece+0x6b>
movl   $0x1,-0x4(%rbp)
jmp    1229 <place_piece+0x119>
cmpl   $0x1,-0xc(%rbp)
jne    11b3 <place_piece+0xa3>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
imul   $0x7,%rcx,%rcx
add    %rcx,%rax
mov    -0x18(%rbp),%rcx
movslq -0x8(%rbp),%rdx
imul   $0x7,%rdx,%rdx
add    %rdx,%rcx
movsbl 0x6(%rcx),%ecx
movslq %ecx,%rcx
movb   $0x6f,(%rax,%rcx,1)
jmp    120a <place_piece+0xfa>
cmpl   $0x2,-0xc(%rbp)
jne    11eb <place_piece+0xdb>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
imul   $0x7,%rcx,%rcx
add    %rcx,%rax
mov    -0x18(%rbp),%rcx
movslq -0x8(%rbp),%rdx
imul   $0x7,%rdx,%rdx
add    %rdx,%rcx
movsbl 0x6(%rcx),%ecx
movslq %ecx,%rcx
movb   $0x78,(%rax,%rcx,1)
jmp    1205 <place_piece+0xf5>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1229 <place_piece+0x119>
jmp    120a <place_piece+0xfa>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
imul   $0x7,%rcx,%rcx
add    %rcx,%rax
mov    0x6(%rax),%cl
add    $0x1,%cl
mov    %cl,0x6(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<place_piece>:
push   %rbx
mov    %edi,%eax
cmp    $0x7,%edi
jb     113f <place_piece+0x1f>
lea    0xed1(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebx
jmp    118e <place_piece+0x6e>
mov    %eax,%ecx
lea    0x0(,%rcx,8),%rax
sub    %rcx,%rax
movsbq 0x6(%rdx,%rax,1),%rcx
mov    $0x1,%ebx
cmp    $0x5,%rcx
jg     118e <place_piece+0x6e>
cmp    $0x1,%esi
je     116b <place_piece+0x4b>
cmp    $0x2,%esi
jne    1182 <place_piece+0x62>
mov    $0x78,%bl
jmp    116d <place_piece+0x4d>
mov    $0x6f,%bl
lea    (%rdx,%rax,1),%rsi
add    $0x6,%rsi
add    %rax,%rdx
mov    %bl,(%rcx,%rdx,1)
addb   $0x1,(%rsi)
xor    %ebx,%ebx
jmp    118e <place_piece+0x6e>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"ERROR: Faulty column: %d.\0A\00"
@.str.1 = [24 x i8] c"ERROR: Unknown player.\0A\00"
define i32 @place_piece(i32 %0, i32 %1, [7 x i8]* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [7 x i8]*
store i32 %0, i32* %5
store i32 %1, i32* %6
store [7 x i8]* %2, [7 x i8]** %7
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = load i32, i32* %5
%12 = icmp sgt i32 %11, 6
br i1 %12, label %13, label %16
13: ; preds = %10, %3
%14 = load i32, i32* %5
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %14)
store i32 1, i32* %4
br label %71
16: ; preds = %10
%17 = load [7 x i8]*, [7 x i8]** %7
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [7 x i8], [7 x i8]* %17, i64 %19
%21 = getelementptr inbounds [7 x i8], [7 x i8]* %20, i64 0, i64 6
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp sge i32 %23, 6
br i1 %24, label %25, label %26
25: ; preds = %16
store i32 1, i32* %4
br label %71
26: ; preds = %16
%27 = load i32, i32* %6
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %43
29: ; preds = %26
%30 = load [7 x i8]*, [7 x i8]** %7
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [7 x i8], [7 x i8]* %30, i64 %32
%34 = load [7 x i8]*, [7 x i8]** %7
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [7 x i8], [7 x i8]* %34, i64 %36
%38 = getelementptr inbounds [7 x i8], [7 x i8]* %37, i64 0, i64 6
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [7 x i8], [7 x i8]* %33, i64 0, i64 %41
store i8 111, i8* %42
br label %63
43: ; preds = %26
%44 = load i32, i32* %6
%45 = icmp eq i32 %44, 2
br i1 %45, label %46, label %60
46: ; preds = %43
%47 = load [7 x i8]*, [7 x i8]** %7
%48 = load i32, i32* %5
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [7 x i8], [7 x i8]* %47, i64 %49
%51 = load [7 x i8]*, [7 x i8]** %7
%52 = load i32, i32* %5
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [7 x i8], [7 x i8]* %51, i64 %53
%55 = getelementptr inbounds [7 x i8], [7 x i8]* %54, i64 0, i64 6
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [7 x i8], [7 x i8]* %50, i64 0, i64 %58
store i8 120, i8* %59
br label %62
60: ; preds = %43
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %4
br label %71
62: ; preds = %46
br label %63
63: ; preds = %62, %29
%64 = load [7 x i8]*, [7 x i8]** %7
%65 = load i32, i32* %5
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [7 x i8], [7 x i8]* %64, i64 %66
%68 = getelementptr inbounds [7 x i8], [7 x i8]* %67, i64 0, i64 6
%69 = load i8, i8* %68
%70 = add i8 %69, 1
store i8 %70, i8* %68
store i32 0, i32* %4
br label %71
71: ; preds = %63, %60, %25, %13
%72 = load i32, i32* %4
ret i32 %72
}

LLVM IR (-O2):
@.str = [27 x i8] c"ERROR: Faulty column: %d.\0A\00"
@str = [23 x i8] c"ERROR: Unknown player.\00"
define i32 @place_piece(i32 %0, i32 %1, [7 x i8]* nocapture %2) {
%4 = icmp ugt i32 %0, 6
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %22
7: ; preds = %3
%8 = zext i32 %0 to i64
%9 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 %8, i64 6
%10 = load i8, i8* %9
%11 = icmp sgt i8 %10, 5
br i1 %11, label %22, label %12
12: ; preds = %7
switch i32 %1, label %14 [
i32 1, label %16
i32 2, label %13
]
13: ; preds = %12
br label %16
14: ; preds = %12
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %22
16: ; preds = %12, %13
%17 = phi i8 [ 120, %13 ], [ 111, %12 ]
%18 = sext i8 %10 to i64
%19 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 %8, i64 %18
store i8 %17, i8* %19
%20 = load i8, i8* %9
%21 = add i8 %20, 1
store i8 %21, i8* %9
br label %22
22: ; preds = %7, %16, %14, %5
%23 = phi i32 [ 1, %5 ], [ 0, %16 ], [ 1, %14 ], [ 1, %7 ]
ret i32 %23
}