#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 */
struct Player {
  int dummy;
};

/* Variables and functions */
int print_enemy(struct Player *);
int print_friendly(struct Player *);
int print_fields(struct Player **players, int friendly_player_index) {
  int err_code;
  int i;
  err_code = print_friendly(players[friendly_player_index]);
  if (err_code != 0)
    return err_code;
  for (i = 0; i < 2; ++i) {
    if (i != friendly_player_index) {
      err_code = print_enemy(players[i]);
      if (err_code != 0)
        return err_code;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<print_fields>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <print_friendly@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1158 <print_fields+0x38>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11bd <print_fields+0x9d>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    11b6 <print_fields+0x96>
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     11a3 <print_fields+0x83>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <print_enemy@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     119e <print_fields+0x7e>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11bd <print_fields+0x9d>
jmp    11a3 <print_fields+0x83>
jmp    11a8 <print_fields+0x88>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115f <print_fields+0x3f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_fields>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
movslq %esi,%rax
mov    (%rdi,%rax,8),%rdi
call   1040 <print_friendly@plt>
test   %eax,%eax
je     113f <print_fields+0x1f>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
test   %ebp,%ebp
je     1154 <print_fields+0x34>
mov    (%rbx),%rdi
call   1030 <print_enemy@plt>
test   %eax,%eax
jne    1138 <print_fields+0x18>
cmp    $0x1,%ebp
je     1161 <print_fields+0x41>
mov    0x8(%rbx),%rdi
call   1030 <print_enemy@plt>
test   %eax,%eax
jne    1138 <print_fields+0x18>
xor    %eax,%eax
jmp    1138 <print_fields+0x18>

LLVM IR (-O0):
%struct.Player = type { i32 }
define i32 @print_fields(%struct.Player** %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.Player**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store %struct.Player** %0, %struct.Player*** %4
store i32 %1, i32* %5
%8 = load %struct.Player**, %struct.Player*** %4
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds %struct.Player*, %struct.Player** %8, i64 %10
%12 = load %struct.Player*, %struct.Player** %11
%13 = call i32 @print_friendly(%struct.Player* %12)
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = load i32, i32* %6
store i32 %17, i32* %3
br label %43
18: ; preds = %2
store i32 0, i32* %7
br label %19
19: ; preds = %39, %18
%20 = load i32, i32* %7
%21 = icmp slt i32 %20, 2
br i1 %21, label %22, label %42
22: ; preds = %19
%23 = load i32, i32* %7
%24 = load i32, i32* %5
%25 = icmp ne i32 %23, %24
br i1 %25, label %26, label %38
26: ; preds = %22
%27 = load %struct.Player**, %struct.Player*** %4
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds %struct.Player*, %struct.Player** %27, i64 %29
%31 = load %struct.Player*, %struct.Player** %30
%32 = call i32 @print_enemy(%struct.Player* %31)
store i32 %32, i32* %6
%33 = load i32, i32* %6
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %26
%36 = load i32, i32* %6
store i32 %36, i32* %3
br label %43
37: ; preds = %26
br label %38
38: ; preds = %37, %22
br label %39
39: ; preds = %38
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %19
42: ; preds = %19
store i32 0, i32* %3
br label %43
43: ; preds = %42, %35, %16
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
%struct.Player = type { i32 }
define i32 @print_fields(%struct.Player** nocapture %0, i32 %1) {
%3 = sext i32 %1 to i64
%4 = getelementptr inbounds %struct.Player*, %struct.Player** %0, i64 %3
%5 = load %struct.Player*, %struct.Player** %4
%6 = tail call i32 @print_friendly(%struct.Player* %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %22
8: ; preds = %2
%9 = icmp eq i32 %1, 0
br i1 %9, label %16, label %10
10: ; preds = %8
%11 = load %struct.Player*, %struct.Player** %0
%12 = tail call i32 @print_enemy(%struct.Player* %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %10
%15 = icmp eq i32 %1, 1
br i1 %15, label %21, label %16
16: ; preds = %8, %14
%17 = getelementptr inbounds %struct.Player*, %struct.Player** %0, i64 1
%18 = load %struct.Player*, %struct.Player** %17
%19 = tail call i32 @print_enemy(%struct.Player* %18)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16, %14
br label %22
22: ; preds = %10, %16, %21, %2
%23 = phi i32 [ %6, %2 ], [ %12, %10 ], [ %19, %16 ], [ 0, %21 ]
ret i32 %23
}