#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 /*<<< orphan*/ data_adddefeat(int);
int /*<<< orphan*/ data_addvictory(int);
int data_getdir(int, int);
int data_numplayers();
scalar_t__ military_might(int);
void war() {
  int numplayers = data_numplayers();
  int player, j;
  for (player = 0; player < numplayers; player++)
    for (j = 0; j < 2; j++) {
      if (military_might(player) > military_might(data_getdir(j, player)))
        data_addvictory(player);
      else if (military_might(player) != military_might(data_getdir(j, player)))
        data_adddefeat(player);
    }
}


x86 assembly (clang, -O0):
<war>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1070 <data_numplayers@plt>
mov    %eax,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1222 <war+0xd2>
movl   $0x0,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jge    120f <war+0xbf>
mov    -0x8(%rbp),%edi
call   1040 <military_might@plt>
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <data_getdir@plt>
mov    %eax,%edi
call   1040 <military_might@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
cmp    %rcx,%rax
jle    11c1 <war+0x71>
mov    -0x8(%rbp),%edi
call   1060 <data_addvictory@plt>
jmp    11fc <war+0xac>
mov    -0x8(%rbp),%edi
call   1040 <military_might@plt>
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <data_getdir@plt>
mov    %eax,%edi
call   1040 <military_might@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
je     11f7 <war+0xa7>
mov    -0x8(%rbp),%edi
call   1050 <data_adddefeat@plt>
jmp    11fc <war+0xac>
jmp    1201 <war+0xb1>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117c <war+0x2c>
jmp    1214 <war+0xc4>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1169 <war+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<war>:
push   %rbp
push   %r14
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <data_numplayers@plt>
test   %eax,%eax
jle    122c <war+0xdc>
mov    %eax,%r14d
jmp    1181 <war+0x31>
nopw   0x0(%rax,%rax,1)
call   1060 <data_addvictory@plt>
add    $0x1,%ebx
cmp    %ebx,%r14d
je     122c <war+0xdc>
mov    %ebx,%edi
call   1040 <military_might@plt>
mov    %rax,%rbp
xor    %edi,%edi
mov    %ebx,%esi
call   1030 <data_getdir@plt>
mov    %eax,%edi
call   1040 <military_might@plt>
mov    %ebx,%edi
cmp    %rax,%rbp
jle    11b0 <war+0x60>
call   1060 <data_addvictory@plt>
jmp    11d4 <war+0x84>
nopl   0x0(%rax)
call   1040 <military_might@plt>
mov    %rax,%rbp
xor    %edi,%edi
mov    %ebx,%esi
call   1030 <data_getdir@plt>
mov    %eax,%edi
call   1040 <military_might@plt>
cmp    %rax,%rbp
je     11d4 <war+0x84>
mov    %ebx,%edi
call   1050 <data_adddefeat@plt>
mov    %ebx,%edi
call   1040 <military_might@plt>
mov    %rax,%rbp
mov    $0x1,%edi
mov    %ebx,%esi
call   1030 <data_getdir@plt>
mov    %eax,%edi
call   1040 <military_might@plt>
mov    %ebx,%edi
cmp    %rax,%rbp
jg     1170 <war+0x20>
call   1040 <military_might@plt>
mov    %rax,%rbp
mov    $0x1,%edi
mov    %ebx,%esi
call   1030 <data_getdir@plt>
mov    %eax,%edi
call   1040 <military_might@plt>
cmp    %rax,%rbp
je     1175 <war+0x25>
mov    %ebx,%edi
call   1050 <data_adddefeat@plt>
jmp    1175 <war+0x25>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define void @war() {
%1 = tail call i32 (...) @data_numplayers()
%2 = icmp sgt i32 %1, 0
br i1 %2, label %3, label %35
3: ; preds = %0, %32
%4 = phi i32 [ %33, %32 ], [ 0, %0 ]
%5 = tail call i64 @military_might(i32 %4)
%6 = tail call i32 @data_getdir(i32 0, i32 %4)
%7 = tail call i64 @military_might(i32 %6)
%8 = icmp sgt i64 %5, %7
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = tail call i32 @data_addvictory(i32 %4)
br label %18
11: ; preds = %3
%12 = tail call i64 @military_might(i32 %4)
%13 = tail call i32 @data_getdir(i32 0, i32 %4)
%14 = tail call i64 @military_might(i32 %13)
%15 = icmp eq i64 %12, %14
br i1 %15, label %18, label %16
16: ; preds = %11
%17 = tail call i32 @data_adddefeat(i32 %4)
br label %18
18: ; preds = %9, %16, %11
%19 = tail call i64 @military_might(i32 %4)
%20 = tail call i32 @data_getdir(i32 1, i32 %4)
%21 = tail call i64 @military_might(i32 %20)
%22 = icmp sgt i64 %19, %21
br i1 %22, label %30, label %23
23: ; preds = %18
%24 = tail call i64 @military_might(i32 %4)
%25 = tail call i32 @data_getdir(i32 1, i32 %4)
%26 = tail call i64 @military_might(i32 %25)
%27 = icmp eq i64 %24, %26
br i1 %27, label %32, label %28
28: ; preds = %23
%29 = tail call i32 @data_adddefeat(i32 %4)
br label %32
30: ; preds = %18
%31 = tail call i32 @data_addvictory(i32 %4)
br label %32
32: ; preds = %30, %28, %23
%33 = add nuw nsw i32 %4, 1
%34 = icmp eq i32 %33, %1
br i1 %34, label %35, label %3
35: ; preds = %32, %0
ret void
}