#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 *ai_canroad(int, int);
char *cat(char *, char *);
char *itoa(int);
int /*<<< orphan*/ map_setmessage(char *);
int /*<<< orphan*/ road_vertbuild(int, int, int, int);
int ai_road(int player, int free) {
  int *road = ai_canroad(player, free);
  if (!road[0]) {
    return 0;
  }
  road_vertbuild(player, road[0], road[1], free);
  if (!free)
    map_setmessage(cat(cat("Player ", itoa(player + 1)), " built a road"));
  return 1;
}


x86 assembly (clang, -O0):
<ai_road>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <ai_canroad@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1186 <ai_road+0x36>
movl   $0x0,-0x4(%rbp)
jmp    11e0 <ai_road+0x90>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0xc(%rbp),%ecx
call   1030 <road_vertbuild@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11d9 <ai_road+0x89>
mov    -0x8(%rbp),%edi
add    $0x1,%edi
call   1060 <itoa@plt>
mov    %rax,%rsi
lea    0xe43(%rip),%rdi
call   1070 <cat@plt>
mov    %rax,%rdi
lea    0xe3c(%rip),%rsi
call   1070 <cat@plt>
mov    %rax,%rdi
call   1040 <map_setmessage@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ai_road>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%ebp
call   1050 <ai_canroad@plt>
mov    (%rax),%esi
test   %esi,%esi
je     11ab <ai_road+0x5b>
mov    0x4(%rax),%edx
mov    %ebp,%edi
mov    %ebx,%ecx
call   1030 <road_vertbuild@plt>
mov    $0x1,%r14d
test   %ebx,%ebx
jne    11ae <ai_road+0x5e>
add    $0x1,%ebp
mov    %ebp,%edi
call   1060 <itoa@plt>
lea    0xe76(%rip),%rdi
mov    %rax,%rsi
call   1070 <cat@plt>
lea    0xe6f(%rip),%rsi
mov    %rax,%rdi
call   1070 <cat@plt>
mov    %rax,%rdi
call   1040 <map_setmessage@plt>
jmp    11ae <ai_road+0x5e>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"Player \00"
@.str.1 = [14 x i8] c" built a road\00"
define i32 @ai_road(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %4
%8 = load i32, i32* %5
%9 = call i32* @ai_canroad(i32 %7, i32 %8)
store i32* %9, i32** %6
%10 = load i32*, i32** %6
%11 = getelementptr inbounds i32, i32* %10, i64 0
%12 = load i32, i32* %11
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %2
store i32 0, i32* %3
br label %35
15: ; preds = %2
%16 = load i32, i32* %4
%17 = load i32*, i32** %6
%18 = getelementptr inbounds i32, i32* %17, i64 0
%19 = load i32, i32* %18
%20 = load i32*, i32** %6
%21 = getelementptr inbounds i32, i32* %20, i64 1
%22 = load i32, i32* %21
%23 = load i32, i32* %5
%24 = call i32 @road_vertbuild(i32 %16, i32 %19, i32 %22, i32 %23)
%25 = load i32, i32* %5
%26 = icmp ne i32 %25, 0
br i1 %26, label %34, label %27
27: ; preds = %15
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
%30 = call i8* @itoa(i32 %29)
%31 = call i8* @cat(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %30)
%32 = call i8* @cat(i8* %31, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%33 = call i32 @map_setmessage(i8* %32)
br label %34
34: ; preds = %27, %15
store i32 1, i32* %3
br label %35
35: ; preds = %34, %14
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str = [8 x i8] c"Player \00"
@.str.1 = [14 x i8] c" built a road\00"
define i32 @ai_road(i32 %0, i32 %1) {
%3 = tail call i32* @ai_canroad(i32 %0, i32 %1)
%4 = load i32, i32* %3
%5 = icmp eq i32 %4, 0
br i1 %5, label %17, label %6
6: ; preds = %2
%7 = getelementptr inbounds i32, i32* %3, i64 1
%8 = load i32, i32* %7
%9 = tail call i32 @road_vertbuild(i32 %0, i32 %4, i32 %8, i32 %1)
%10 = icmp eq i32 %1, 0
br i1 %10, label %11, label %17
11: ; preds = %6
%12 = add nsw i32 %0, 1
%13 = tail call i8* @itoa(i32 %12)
%14 = tail call i8* @cat(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = tail call i8* @cat(i8* %14, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%16 = tail call i32 @map_setmessage(i8* %15)
br label %17
17: ; preds = %6, %11, %2
%18 = phi i32 [ 0, %2 ], [ 1, %11 ], [ 1, %6 ]
ret i32 %18
}