#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 abs(scalar_t__);
scalar_t__ ai_playerweight(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ ai_vertsonhex(int, int *);
int /*<<< orphan*/ data_playeratvertex(int);
scalar_t__ map_getdat(int, int);
int ai_robweight(int player, int hex) {
  int verts[6];
  ai_vertsonhex(hex, verts);
  int sum = 0;
  int i;
  for (i = 0; i < 6; i++)
    sum += ai_playerweight(player, data_playeratvertex(verts[i]), verts[i]);
  sum *= abs(map_getdat(hex, 1) - 7) * -1 + 6;
  return sum;
}


x86 assembly (clang, -O0):
<ai_robweight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1030 <ai_vertsonhex@plt>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x6,-0x28(%rbp)
jge    11c2 <ai_robweight+0x72>
mov    -0x4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edi
call   1050 <data_playeratvertex@plt>
mov    -0x2c(%rbp),%edi
mov    %eax,%esi
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edx
call   1060 <ai_playerweight@plt>
mov    %rax,%rcx
movslq -0x24(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1178 <ai_robweight+0x28>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1070 <map_getdat@plt>
mov    %rax,%rdi
sub    $0x7,%rdi
call   1040 <abs@plt>
imul   $0xffffffff,%eax,%eax
add    $0x6,%eax
imul   -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ai_robweight>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %esi,%r14d
mov    %edi,%r12d
mov    %rsp,%rsi
mov    %r14d,%edi
call   1030 <ai_vertsonhex@plt>
mov    (%rsp),%edi
call   1050 <data_playeratvertex@plt>
mov    (%rsp),%edx
mov    %r12d,%edi
mov    %eax,%esi
call   1060 <ai_playerweight@plt>
mov    %rax,%r15
mov    0x4(%rsp),%edi
call   1050 <data_playeratvertex@plt>
mov    0x4(%rsp),%edx
mov    %r12d,%edi
mov    %eax,%esi
call   1060 <ai_playerweight@plt>
mov    %rax,%rbx
add    %r15d,%ebx
mov    0x8(%rsp),%edi
call   1050 <data_playeratvertex@plt>
mov    0x8(%rsp),%edx
mov    %r12d,%edi
mov    %eax,%esi
call   1060 <ai_playerweight@plt>
mov    %rax,%rbp
add    %ebx,%ebp
mov    0xc(%rsp),%edi
call   1050 <data_playeratvertex@plt>
mov    0xc(%rsp),%edx
mov    %r12d,%edi
mov    %eax,%esi
call   1060 <ai_playerweight@plt>
mov    %rax,%rbx
add    %ebp,%ebx
mov    0x10(%rsp),%edi
call   1050 <data_playeratvertex@plt>
mov    0x10(%rsp),%edx
mov    %r12d,%edi
mov    %eax,%esi
call   1060 <ai_playerweight@plt>
mov    %rax,%rbp
add    %ebx,%ebp
mov    0x14(%rsp),%edi
call   1050 <data_playeratvertex@plt>
mov    0x14(%rsp),%edx
mov    %r12d,%edi
mov    %eax,%esi
call   1060 <ai_playerweight@plt>
mov    %rax,%rbx
add    %ebp,%ebx
mov    %r14d,%edi
mov    $0x1,%esi
call   1070 <map_getdat@plt>
lea    -0x7(%rax),%rdi
call   1040 <abs@plt>
mov    $0x6,%ecx
sub    %eax,%ecx
imul   %ebx,%ecx
mov    %ecx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ai_robweight(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [6 x i32]
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 0
%10 = call i32 @ai_vertsonhex(i32 %8, i32* %9)
store i32 0, i32* %6
store i32 0, i32* %7
br label %11
11: ; preds = %30, %2
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 6
br i1 %13, label %14, label %33
14: ; preds = %11
%15 = load i32, i32* %3
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = call i32 @data_playeratvertex(i32 %19)
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = call i64 @ai_playerweight(i32 %15, i32 %20, i32 %24)
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = add nsw i64 %27, %25
%29 = trunc i64 %28 to i32
store i32 %29, i32* %6
br label %30
30: ; preds = %14
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %11
33: ; preds = %11
%34 = load i32, i32* %4
%35 = call i64 @map_getdat(i32 %34, i32 1)
%36 = sub nsw i64 %35, 7
%37 = call i32 @abs(i64 %36)
%38 = mul nsw i32 %37, -1
%39 = add nsw i32 %38, 6
%40 = load i32, i32* %6
%41 = mul nsw i32 %40, %39
store i32 %41, i32* %6
%42 = load i32, i32* %6
ret i32 %42
}

LLVM IR (-O2):
define i32 @ai_robweight(i32 %0, i32 %1) {
%3 = alloca [6 x i32]
%4 = bitcast [6 x i32]* %3 to i8*
%5 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%6 = call i32 @ai_vertsonhex(i32 %1, i32* %5)
%7 = load i32, i32* %5
%8 = call i32 @data_playeratvertex(i32 %7)
%9 = load i32, i32* %5
%10 = call i64 @ai_playerweight(i32 %0, i32 %8, i32 %9)
%11 = trunc i64 %10 to i32
%12 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 1
%13 = load i32, i32* %12
%14 = call i32 @data_playeratvertex(i32 %13)
%15 = load i32, i32* %12
%16 = call i64 @ai_playerweight(i32 %0, i32 %14, i32 %15)
%17 = trunc i64 %16 to i32
%18 = add i32 %11, %17
%19 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 2
%20 = load i32, i32* %19
%21 = call i32 @data_playeratvertex(i32 %20)
%22 = load i32, i32* %19
%23 = call i64 @ai_playerweight(i32 %0, i32 %21, i32 %22)
%24 = trunc i64 %23 to i32
%25 = add i32 %18, %24
%26 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 3
%27 = load i32, i32* %26
%28 = call i32 @data_playeratvertex(i32 %27)
%29 = load i32, i32* %26
%30 = call i64 @ai_playerweight(i32 %0, i32 %28, i32 %29)
%31 = trunc i64 %30 to i32
%32 = add i32 %25, %31
%33 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 4
%34 = load i32, i32* %33
%35 = call i32 @data_playeratvertex(i32 %34)
%36 = load i32, i32* %33
%37 = call i64 @ai_playerweight(i32 %0, i32 %35, i32 %36)
%38 = trunc i64 %37 to i32
%39 = add i32 %32, %38
%40 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 5
%41 = load i32, i32* %40
%42 = call i32 @data_playeratvertex(i32 %41)
%43 = load i32, i32* %40
%44 = call i64 @ai_playerweight(i32 %0, i32 %42, i32 %43)
%45 = trunc i64 %44 to i32
%46 = add i32 %39, %45
%47 = call i64 @map_getdat(i32 %1, i32 1)
%48 = add nsw i64 %47, -7
%49 = call i32 @abs(i64 %48)
%50 = sub i32 6, %49
%51 = mul nsw i32 %50, %46
ret i32 %51
}