#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__ IVenRatlla(char **, char);
double columnesGuanyadores(char **, char);
double diagonalsGuanyadores(char **, char);
double filesGuanyadores(char **, char);
double heuristic(char tauler[6][7]) {
  if (IVenRatlla(tauler, 'o'))
    return -1e6;
  else if (IVenRatlla(tauler, 'x'))
    return 1e6;
  else {
    return columnesGuanyadores(tauler, 'x') + filesGuanyadores(tauler, 'x') +
           diagonalsGuanyadores(tauler, 'x') -
           columnesGuanyadores(tauler, 'o') - filesGuanyadores(tauler, 'o') -
           diagonalsGuanyadores(tauler, 'o');
  }
}


x86 assembly (clang, -O0):
<heuristic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x6f,%esi
call   1050 <IVenRatlla@plt>
cmp    $0x0,%rax
je     1176 <heuristic+0x36>
movsd  0xe9c(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    124e <heuristic+0x10e>
mov    -0x10(%rbp),%rdi
mov    $0x78,%esi
call   1050 <IVenRatlla@plt>
cmp    $0x0,%rax
je     11a0 <heuristic+0x60>
movsd  0xe6a(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    124e <heuristic+0x10e>
mov    -0x10(%rbp),%rdi
mov    $0x78,%esi
call   1040 <columnesGuanyadores@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x78,%esi
call   1030 <filesGuanyadores@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x78,%esi
call   1060 <diagonalsGuanyadores@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x6f,%esi
call   1040 <columnesGuanyadores@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x6f,%esi
call   1030 <filesGuanyadores@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x6f,%esi
call   1060 <diagonalsGuanyadores@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<heuristic>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    $0x6f,%esi
call   1050 <IVenRatlla@plt>
test   %rax,%rax
je     1164 <heuristic+0x24>
movsd  0xea1(%rip),%xmm0
jmp    121d <heuristic+0xdd>
mov    %rbx,%rdi
mov    $0x78,%esi
call   1050 <IVenRatlla@plt>
test   %rax,%rax
je     1183 <heuristic+0x43>
movsd  0xe8a(%rip),%xmm0
jmp    121d <heuristic+0xdd>
mov    %rbx,%rdi
mov    $0x78,%esi
call   1040 <columnesGuanyadores@plt>
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
mov    $0x78,%esi
call   1030 <filesGuanyadores@plt>
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
mov    $0x78,%esi
call   1060 <diagonalsGuanyadores@plt>
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
mov    $0x6f,%esi
call   1040 <columnesGuanyadores@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %rbx,%rdi
mov    $0x6f,%esi
call   1030 <filesGuanyadores@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %rbx,%rdi
mov    $0x6f,%esi
call   1060 <diagonalsGuanyadores@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @heuristic([7 x i8]* %0) {
%2 = alloca double
%3 = alloca [7 x i8]*
store [7 x i8]* %0, [7 x i8]** %3
%4 = load [7 x i8]*, [7 x i8]** %3
%5 = bitcast [7 x i8]* %4 to i8**
%6 = call i64 @IVenRatlla(i8** %5, i8 signext 111)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store double -1.000000e+06, double* %2
br label %39
9: ; preds = %1
%10 = load [7 x i8]*, [7 x i8]** %3
%11 = bitcast [7 x i8]* %10 to i8**
%12 = call i64 @IVenRatlla(i8** %11, i8 signext 120)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %9
store double 1.000000e+06, double* %2
br label %39
15: ; preds = %9
%16 = load [7 x i8]*, [7 x i8]** %3
%17 = bitcast [7 x i8]* %16 to i8**
%18 = call double @columnesGuanyadores(i8** %17, i8 signext 120)
%19 = load [7 x i8]*, [7 x i8]** %3
%20 = bitcast [7 x i8]* %19 to i8**
%21 = call double @filesGuanyadores(i8** %20, i8 signext 120)
%22 = fadd double %18, %21
%23 = load [7 x i8]*, [7 x i8]** %3
%24 = bitcast [7 x i8]* %23 to i8**
%25 = call double @diagonalsGuanyadores(i8** %24, i8 signext 120)
%26 = fadd double %22, %25
%27 = load [7 x i8]*, [7 x i8]** %3
%28 = bitcast [7 x i8]* %27 to i8**
%29 = call double @columnesGuanyadores(i8** %28, i8 signext 111)
%30 = fsub double %26, %29
%31 = load [7 x i8]*, [7 x i8]** %3
%32 = bitcast [7 x i8]* %31 to i8**
%33 = call double @filesGuanyadores(i8** %32, i8 signext 111)
%34 = fsub double %30, %33
%35 = load [7 x i8]*, [7 x i8]** %3
%36 = bitcast [7 x i8]* %35 to i8**
%37 = call double @diagonalsGuanyadores(i8** %36, i8 signext 111)
%38 = fsub double %34, %37
store double %38, double* %2
br label %39
39: ; preds = %15, %14, %8
%40 = load double, double* %2
ret double %40
}

LLVM IR (-O2):
define double @heuristic([7 x i8]* %0) {
%2 = bitcast [7 x i8]* %0 to i8**
%3 = tail call i64 @IVenRatlla(i8** %2, i8 signext 111)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %20
5: ; preds = %1
%6 = tail call i64 @IVenRatlla(i8** %2, i8 signext 120)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %5
%9 = tail call double @columnesGuanyadores(i8** %2, i8 signext 120)
%10 = tail call double @filesGuanyadores(i8** %2, i8 signext 120)
%11 = fadd double %9, %10
%12 = tail call double @diagonalsGuanyadores(i8** %2, i8 signext 120)
%13 = fadd double %11, %12
%14 = tail call double @columnesGuanyadores(i8** %2, i8 signext 111)
%15 = fsub double %13, %14
%16 = tail call double @filesGuanyadores(i8** %2, i8 signext 111)
%17 = fsub double %15, %16
%18 = tail call double @diagonalsGuanyadores(i8** %2, i8 signext 111)
%19 = fsub double %17, %18
br label %20
20: ; preds = %5, %1, %8
%21 = phi double [ %19, %8 ], [ -1.000000e+06, %1 ], [ 1.000000e+06, %5 ]
ret double %21
}