#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 */
scalar_t__ get_black_captured();
int get_last_move_color();
int get_last_move_count_stones();
int get_last_move_i();
int get_last_move_j();
scalar_t__ get_last_move_pass();
int /*<<< orphan*/ get_last_move_stones(int **);
scalar_t__ get_white_captured();
int /*<<< orphan*/ pop_move();
int /*<<< orphan*/ set_black_captured(scalar_t__);
int /*<<< orphan*/ set_vertex(int, int, int);
int /*<<< orphan*/ set_white_captured(scalar_t__);
void undo_move(void) {
  int k;
  int i = get_last_move_i();
  int j = get_last_move_j();
  int color = get_last_move_color();
  int count_stones = get_last_move_count_stones();
  int stones[21 * 21][2];
  if (get_last_move_pass()) {
    pop_move();
    return;
  }
  get_last_move_stones(stones);
  set_vertex(0, i, j);
  if (count_stones > 0) {
    for (k = 0; k < count_stones; k++) {
      set_vertex(color * -1, stones[k][0], stones[k][1]);
    }
    if (color == 1) {
      set_black_captured(get_black_captured() - count_stones);
    } else {
      set_white_captured(get_white_captured() - count_stones);
    }
  }
  pop_move();
  return;
}


x86 assembly (clang, -O0):
<undo_move>:
push   %rbp
mov    %rsp,%rbp
sub    $0xde0,%rsp
mov    $0x0,%al
call   1030 <get_last_move_i@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1070 <get_last_move_j@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1080 <get_last_move_color@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   10c0 <get_last_move_count_stones@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   10a0 <get_last_move_pass@plt>
cmp    $0x0,%rax
je     1210 <undo_move+0x50>
mov    $0x0,%al
call   10e0 <pop_move@plt>
jmp    12ba <undo_move+0xfa>
lea    -0xde0(%rbp),%rdi
call   10b0 <get_last_move_stones@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
xor    %edi,%edi
call   1060 <set_vertex@plt>
cmpl   $0x0,-0x14(%rbp)
jle    12b3 <undo_move+0xf3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1273 <undo_move+0xb3>
imul   $0xffffffff,-0x10(%rbp),%edi
movslq -0x4(%rbp),%rax
mov    -0xde0(%rbp,%rax,8),%esi
movslq -0x4(%rbp),%rax
mov    -0xddc(%rbp,%rax,8),%edx
call   1060 <set_vertex@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    123a <undo_move+0x7a>
cmpl   $0x1,-0x10(%rbp)
jne    1298 <undo_move+0xd8>
mov    $0x0,%al
call   1040 <get_black_captured@plt>
mov    %rax,%rdi
movslq -0x14(%rbp),%rax
sub    %rax,%rdi
call   1050 <set_black_captured@plt>
jmp    12ae <undo_move+0xee>
mov    $0x0,%al
call   10d0 <get_white_captured@plt>
mov    %rax,%rdi
movslq -0x14(%rbp),%rax
sub    %rax,%rdi
call   1090 <set_white_captured@plt>
jmp    12b3 <undo_move+0xf3>
mov    $0x0,%al
call   10e0 <pop_move@plt>
add    $0xde0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<undo_move>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xdd0,%rsp
xor    %eax,%eax
call   1030 <get_last_move_i@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1070 <get_last_move_j@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1080 <get_last_move_color@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   10c0 <get_last_move_count_stones@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   10a0 <get_last_move_pass@plt>
test   %rax,%rax
je     1217 <undo_move+0x57>
xor    %eax,%eax
add    $0xdd0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    10e0 <pop_move@plt>
mov    %rsp,%rdi
call   10b0 <get_last_move_stones@plt>
xor    %edi,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1060 <set_vertex@plt>
test   %r15d,%r15d
jle    1287 <undo_move+0xc7>
mov    %r14d,%ebx
neg    %ebx
mov    %r15d,%r12d
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%rsp,%rbp,8),%esi
mov    0x4(%rsp,%rbp,8),%edx
mov    %ebx,%edi
call   1060 <set_vertex@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1240 <undo_move+0x80>
xor    %eax,%eax
cmp    $0x1,%r14d
jne    1274 <undo_move+0xb4>
call   1040 <get_black_captured@plt>
movslq %r15d,%rcx
sub    %rcx,%rax
mov    %rax,%rdi
call   1050 <set_black_captured@plt>
jmp    1287 <undo_move+0xc7>
call   10d0 <get_white_captured@plt>
movslq %r15d,%rcx
sub    %rcx,%rax
mov    %rax,%rdi
call   1090 <set_white_captured@plt>
xor    %eax,%eax
call   10e0 <pop_move@plt>
add    $0xdd0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @undo_move() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [441 x [2 x i32]]
%7 = call i32 (...) @get_last_move_i()
store i32 %7, i32* %2
%8 = call i32 (...) @get_last_move_j()
store i32 %8, i32* %3
%9 = call i32 (...) @get_last_move_color()
store i32 %9, i32* %4
%10 = call i32 (...) @get_last_move_count_stones()
store i32 %10, i32* %5
%11 = call i64 (...) @get_last_move_pass()
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 (...) @pop_move()
br label %64
15: ; preds = %0
%16 = getelementptr inbounds [441 x [2 x i32]], [441 x [2 x i32]]* %6, i64 0, i64 0
%17 = bitcast [2 x i32]* %16 to i32**
%18 = call i32 @get_last_move_stones(i32** %17)
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = call i32 @set_vertex(i32 0, i32 %19, i32 %20)
%22 = load i32, i32* %5
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %62
24: ; preds = %15
store i32 0, i32* %1
br label %25
25: ; preds = %43, %24
%26 = load i32, i32* %1
%27 = load i32, i32* %5
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %46
29: ; preds = %25
%30 = load i32, i32* %4
%31 = mul nsw i32 %30, -1
%32 = load i32, i32* %1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [441 x [2 x i32]], [441 x [2 x i32]]* %6, i64 0, i64 %33
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %34, i64 0, i64 0
%36 = load i32, i32* %35
%37 = load i32, i32* %1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [441 x [2 x i32]], [441 x [2 x i32]]* %6, i64 0, i64 %38
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %39, i64 0, i64 1
%41 = load i32, i32* %40
%42 = call i32 @set_vertex(i32 %31, i32 %36, i32 %41)
br label %43
43: ; preds = %29
%44 = load i32, i32* %1
%45 = add nsw i32 %44, 1
store i32 %45, i32* %1
br label %25
46: ; preds = %25
%47 = load i32, i32* %4
%48 = icmp eq i32 %47, 1
br i1 %48, label %49, label %55
49: ; preds = %46
%50 = call i64 (...) @get_black_captured()
%51 = load i32, i32* %5
%52 = sext i32 %51 to i64
%53 = sub nsw i64 %50, %52
%54 = call i32 @set_black_captured(i64 %53)
br label %61
55: ; preds = %46
%56 = call i64 (...) @get_white_captured()
%57 = load i32, i32* %5
%58 = sext i32 %57 to i64
%59 = sub nsw i64 %56, %58
%60 = call i32 @set_white_captured(i64 %59)
br label %61
61: ; preds = %55, %49
br label %62
62: ; preds = %61, %15
%63 = call i32 (...) @pop_move()
br label %64
64: ; preds = %62, %13
ret void
}

LLVM IR (-O2):
define void @undo_move() {
%1 = alloca [441 x [2 x i32]]
%2 = tail call i32 (...) @get_last_move_i()
%3 = tail call i32 (...) @get_last_move_j()
%4 = tail call i32 (...) @get_last_move_color()
%5 = tail call i32 (...) @get_last_move_count_stones()
%6 = bitcast [441 x [2 x i32]]* %1 to i8*
%7 = tail call i64 (...) @get_last_move_pass()
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %0
%10 = tail call i32 (...) @pop_move()
br label %42
11: ; preds = %0
%12 = bitcast [441 x [2 x i32]]* %1 to i32**
%13 = call i32 @get_last_move_stones(i32** %12)
%14 = call i32 @set_vertex(i32 0, i32 %2, i32 %3)
%15 = icmp sgt i32 %5, 0
br i1 %15, label %16, label %40
16: ; preds = %11
%17 = sub nsw i32 0, %4
%18 = zext i32 %5 to i64
br label %19
19: ; preds = %16, %19
%20 = phi i64 [ 0, %16 ], [ %26, %19 ]
%21 = getelementptr inbounds [441 x [2 x i32]], [441 x [2 x i32]]* %1, i64 0, i64 %20, i64 0
%22 = load i32, i32* %21
%23 = getelementptr inbounds [441 x [2 x i32]], [441 x [2 x i32]]* %1, i64 0, i64 %20, i64 1
%24 = load i32, i32* %23
%25 = call i32 @set_vertex(i32 %17, i32 %22, i32 %24)
%26 = add nuw nsw i64 %20, 1
%27 = icmp eq i64 %26, %18
br i1 %27, label %28, label %19
28: ; preds = %19
%29 = icmp eq i32 %4, 1
br i1 %29, label %30, label %35
30: ; preds = %28
%31 = call i64 (...) @get_black_captured()
%32 = sext i32 %5 to i64
%33 = sub nsw i64 %31, %32
%34 = call i32 @set_black_captured(i64 %33)
br label %40
35: ; preds = %28
%36 = call i64 (...) @get_white_captured()
%37 = sext i32 %5 to i64
%38 = sub nsw i64 %36, %37
%39 = call i32 @set_white_captured(i64 %38)
br label %40
40: ; preds = %30, %35, %11
%41 = call i32 (...) @pop_move()
br label %42
42: ; preds = %40, %9
ret void
}