#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_addresource(int, int, int);
void doTrade(int *trade, int player1, int player2) {
  int i;
  for (i = 0; i < 5; i++) {
    data_addresource(player2, i, trade[i]);
    data_addresource(player1, i, trade[i] * -1);
  }
}


x86 assembly (clang, -O0):
<doTrade>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    116e <doTrade+0x5e>
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
call   1030 <data_addresource@plt>
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0xffffffff,(%rax,%rcx,4),%edx
call   1030 <data_addresource@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1129 <doTrade+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doTrade>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %esi,%r15d
mov    %rdi,%rbx
mov    (%rdi),%edx
xor    %r14d,%r14d
mov    %ebp,%edi
xor    %esi,%esi
call   1030 <data_addresource@plt>
xor    %edx,%edx
sub    (%rbx),%edx
mov    %r15d,%edi
xor    %esi,%esi
call   1030 <data_addresource@plt>
mov    0x4(%rbx),%edx
mov    %ebp,%edi
mov    $0x1,%esi
call   1030 <data_addresource@plt>
xor    %edx,%edx
sub    0x4(%rbx),%edx
mov    %r15d,%edi
mov    $0x1,%esi
call   1030 <data_addresource@plt>
mov    0x8(%rbx),%edx
mov    %ebp,%edi
mov    $0x2,%esi
call   1030 <data_addresource@plt>
xor    %edx,%edx
sub    0x8(%rbx),%edx
mov    %r15d,%edi
mov    $0x2,%esi
call   1030 <data_addresource@plt>
mov    0xc(%rbx),%edx
mov    %ebp,%edi
mov    $0x3,%esi
call   1030 <data_addresource@plt>
xor    %edx,%edx
sub    0xc(%rbx),%edx
mov    %r15d,%edi
mov    $0x3,%esi
call   1030 <data_addresource@plt>
mov    0x10(%rbx),%edx
mov    %ebp,%edi
mov    $0x4,%esi
call   1030 <data_addresource@plt>
sub    0x10(%rbx),%r14d
mov    %r15d,%edi
mov    $0x4,%esi
mov    %r14d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <data_addresource@plt>

LLVM IR (-O0):
define void @doTrade(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %29, %3
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 5
br i1 %10, label %11, label %32
11: ; preds = %8
%12 = load i32, i32* %6
%13 = load i32, i32* %7
%14 = load i32*, i32** %4
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
%18 = load i32, i32* %17
%19 = call i32 @data_addresource(i32 %12, i32 %13, i32 %18)
%20 = load i32, i32* %5
%21 = load i32, i32* %7
%22 = load i32*, i32** %4
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = load i32, i32* %25
%27 = mul nsw i32 %26, -1
%28 = call i32 @data_addresource(i32 %20, i32 %21, i32 %27)
br label %29
29: ; preds = %11
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %8
32: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @doTrade(i32* nocapture %0, i32 %1, i32 %2) {
%4 = load i32, i32* %0
%5 = tail call i32 @data_addresource(i32 %2, i32 0, i32 %4)
%6 = load i32, i32* %0
%7 = sub nsw i32 0, %6
%8 = tail call i32 @data_addresource(i32 %1, i32 0, i32 %7)
%9 = getelementptr inbounds i32, i32* %0, i64 1
%10 = load i32, i32* %9
%11 = tail call i32 @data_addresource(i32 %2, i32 1, i32 %10)
%12 = load i32, i32* %9
%13 = sub nsw i32 0, %12
%14 = tail call i32 @data_addresource(i32 %1, i32 1, i32 %13)
%15 = getelementptr inbounds i32, i32* %0, i64 2
%16 = load i32, i32* %15
%17 = tail call i32 @data_addresource(i32 %2, i32 2, i32 %16)
%18 = load i32, i32* %15
%19 = sub nsw i32 0, %18
%20 = tail call i32 @data_addresource(i32 %1, i32 2, i32 %19)
%21 = getelementptr inbounds i32, i32* %0, i64 3
%22 = load i32, i32* %21
%23 = tail call i32 @data_addresource(i32 %2, i32 3, i32 %22)
%24 = load i32, i32* %21
%25 = sub nsw i32 0, %24
%26 = tail call i32 @data_addresource(i32 %1, i32 3, i32 %25)
%27 = getelementptr inbounds i32, i32* %0, i64 4
%28 = load i32, i32* %27
%29 = tail call i32 @data_addresource(i32 %2, i32 4, i32 %28)
%30 = load i32, i32* %27
%31 = sub nsw i32 0, %30
%32 = tail call i32 @data_addresource(i32 %1, i32 4, i32 %31)
ret void
}