#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_isai(int);
scalar_t__ data_multihumans();
int data_totresources(int);
int /*<<< orphan*/ pass_between_humans(int);
int /*<<< orphan*/ robber_discardhandler(int, int);
void robber_discard(int player) {
  int i;
  for (i = 0; i < 4; i++) {
    if (data_totresources(player) > 7) {
      if (!data_isai(player) && data_multihumans())
        pass_between_humans(player);
      robber_discardhandler(player, data_totresources(player) / 2);
    }
    player = (player + 1) % 4;
  }
}


x86 assembly (clang, -O0):
<robber_discard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    11e6 <robber_discard+0x96>
mov    -0x4(%rbp),%edi
call   1070 <data_totresources@plt>
cmp    $0x7,%eax
jle    11c7 <robber_discard+0x77>
mov    -0x4(%rbp),%edi
call   1030 <data_isai@plt>
cmp    $0x0,%eax
jne    11a7 <robber_discard+0x57>
mov    $0x0,%al
call   1040 <data_multihumans@plt>
cmp    $0x0,%rax
je     11a7 <robber_discard+0x57>
mov    -0x4(%rbp),%edi
call   1060 <pass_between_humans@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1070 <data_totresources@plt>
mov    -0xc(%rbp),%edi
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
call   1050 <robber_discardhandler@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1162 <robber_discard+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<robber_discard>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
call   1070 <data_totresources@plt>
cmp    $0x8,%eax
jl     1194 <robber_discard+0x44>
mov    %ebx,%edi
call   1030 <data_isai@plt>
test   %eax,%eax
jne    117d <robber_discard+0x2d>
xor    %eax,%eax
call   1040 <data_multihumans@plt>
test   %rax,%rax
je     117d <robber_discard+0x2d>
mov    %ebx,%edi
call   1060 <pass_between_humans@plt>
mov    %ebx,%edi
call   1070 <data_totresources@plt>
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
mov    %ebx,%edi
call   1050 <robber_discardhandler@plt>
lea    0x1(%rbx),%eax
lea    0x4(%rbx),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
neg    %ecx
add    %ecx,%ebx
add    $0x1,%ebx
mov    %ebx,%edi
call   1070 <data_totresources@plt>
cmp    $0x8,%eax
jl     11ea <robber_discard+0x9a>
mov    %ebx,%edi
call   1030 <data_isai@plt>
test   %eax,%eax
jne    11d3 <robber_discard+0x83>
xor    %eax,%eax
call   1040 <data_multihumans@plt>
test   %rax,%rax
je     11d3 <robber_discard+0x83>
mov    %ebx,%edi
call   1060 <pass_between_humans@plt>
mov    %ebx,%edi
call   1070 <data_totresources@plt>
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
mov    %ebx,%edi
call   1050 <robber_discardhandler@plt>
add    $0x1,%bl
mov    %ebx,%eax
sar    $0x7,%al
shr    $0x6,%al
add    %bl,%al
and    $0xfc,%al
sub    %al,%bl
movsbl %bl,%ebp
mov    %ebp,%edi
call   1070 <data_totresources@plt>
cmp    $0x8,%eax
jl     123f <robber_discard+0xef>
mov    %ebp,%edi
call   1030 <data_isai@plt>
test   %eax,%eax
jne    1228 <robber_discard+0xd8>
xor    %eax,%eax
call   1040 <data_multihumans@plt>
test   %rax,%rax
je     1228 <robber_discard+0xd8>
mov    %ebp,%edi
call   1060 <pass_between_humans@plt>
mov    %ebp,%edi
call   1070 <data_totresources@plt>
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
mov    %ebp,%edi
call   1050 <robber_discardhandler@plt>
add    $0x1,%bl
mov    %ebx,%eax
sar    $0x7,%al
shr    $0x6,%al
add    %bl,%al
and    $0xfc,%al
sub    %al,%bl
movsbl %bl,%ebx
mov    %ebx,%edi
call   1070 <data_totresources@plt>
cmp    $0x8,%eax
jl     129a <robber_discard+0x14a>
mov    %ebx,%edi
call   1030 <data_isai@plt>
test   %eax,%eax
jne    127d <robber_discard+0x12d>
xor    %eax,%eax
call   1040 <data_multihumans@plt>
test   %rax,%rax
je     127d <robber_discard+0x12d>
mov    %ebx,%edi
call   1060 <pass_between_humans@plt>
mov    %ebx,%edi
call   1070 <data_totresources@plt>
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <robber_discardhandler@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @robber_discard(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %31, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 4
br i1 %6, label %7, label %34
7: ; preds = %4
%8 = load i32, i32* %2
%9 = call i32 @data_totresources(i32 %8)
%10 = icmp sgt i32 %9, 7
br i1 %10, label %11, label %27
11: ; preds = %7
%12 = load i32, i32* %2
%13 = call i32 @data_isai(i32 %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %11
%16 = call i64 (...) @data_multihumans()
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* %2
%20 = call i32 @pass_between_humans(i32 %19)
br label %21
21: ; preds = %18, %15, %11
%22 = load i32, i32* %2
%23 = load i32, i32* %2
%24 = call i32 @data_totresources(i32 %23)
%25 = sdiv i32 %24, 2
%26 = call i32 @robber_discardhandler(i32 %22, i32 %25)
br label %27
27: ; preds = %21, %7
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
%30 = srem i32 %29, 4
store i32 %30, i32* %2
br label %31
31: ; preds = %27
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %4
34: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @robber_discard(i32 %0) {
%2 = tail call i32 @data_totresources(i32 %0)
%3 = icmp sgt i32 %2, 7
br i1 %3, label %4, label %16
4: ; preds = %1
%5 = tail call i32 @data_isai(i32 %0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %4
%8 = tail call i64 (...) @data_multihumans()
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 @pass_between_humans(i32 %0)
br label %12
12: ; preds = %10, %7, %4
%13 = tail call i32 @data_totresources(i32 %0)
%14 = sdiv i32 %13, 2
%15 = tail call i32 @robber_discardhandler(i32 %0, i32 %14)
br label %16
16: ; preds = %12, %1
%17 = add nsw i32 %0, 1
%18 = srem i32 %17, 4
%19 = tail call i32 @data_totresources(i32 %18)
%20 = icmp sgt i32 %19, 7
br i1 %20, label %21, label %33
21: ; preds = %16
%22 = tail call i32 @data_isai(i32 %18)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = tail call i64 (...) @data_multihumans()
%26 = icmp eq i64 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %24
%28 = tail call i32 @pass_between_humans(i32 %18)
br label %29
29: ; preds = %27, %24, %21
%30 = tail call i32 @data_totresources(i32 %18)
%31 = sdiv i32 %30, 2
%32 = tail call i32 @robber_discardhandler(i32 %18, i32 %31)
br label %33
33: ; preds = %29, %16
%34 = trunc i32 %18 to i8
%35 = add i8 %34, 1
%36 = srem i8 %35, 4
%37 = sext i8 %36 to i32
%38 = tail call i32 @data_totresources(i32 %37)
%39 = icmp sgt i32 %38, 7
br i1 %39, label %40, label %52
40: ; preds = %33
%41 = tail call i32 @data_isai(i32 %37)
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %48
43: ; preds = %40
%44 = tail call i64 (...) @data_multihumans()
%45 = icmp eq i64 %44, 0
br i1 %45, label %48, label %46
46: ; preds = %43
%47 = tail call i32 @pass_between_humans(i32 %37)
br label %48
48: ; preds = %46, %43, %40
%49 = tail call i32 @data_totresources(i32 %37)
%50 = sdiv i32 %49, 2
%51 = tail call i32 @robber_discardhandler(i32 %37, i32 %50)
br label %52
52: ; preds = %48, %33
%53 = add nsw i8 %36, 1
%54 = srem i8 %53, 4
%55 = sext i8 %54 to i32
%56 = tail call i32 @data_totresources(i32 %55)
%57 = icmp sgt i32 %56, 7
br i1 %57, label %58, label %70
58: ; preds = %52
%59 = tail call i32 @data_isai(i32 %55)
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %66
61: ; preds = %58
%62 = tail call i64 (...) @data_multihumans()
%63 = icmp eq i64 %62, 0
br i1 %63, label %66, label %64
64: ; preds = %61
%65 = tail call i32 @pass_between_humans(i32 %55)
br label %66
66: ; preds = %64, %61, %58
%67 = tail call i32 @data_totresources(i32 %55)
%68 = sdiv i32 %67, 2
%69 = tail call i32 @robber_discardhandler(i32 %55, i32 %68)
br label %70
70: ; preds = %66, %52
ret void
}