#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 rand();
int BattleOne(int atkForce, int defForce, int *defSurvivors) {
  *defSurvivors = defForce - (atkForce * (15 + rand() % 11)) / 100;
  if (*defSurvivors > 0)
    return -1;
  else {
    *defSurvivors = 0;
    return 1;
  }
}


x86 assembly (clang, -O0):
<BattleOne>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    -0x20(%rbp),%ecx
mov    $0xb,%esi
cltd
idiv   %esi
mov    -0x1c(%rbp),%eax
add    $0xf,%edx
imul   %edx,%eax
mov    $0x64,%esi
cltd
idiv   %esi
sub    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jle    1172 <BattleOne+0x62>
movl   $0xffffffff,-0x4(%rbp)
jmp    1183 <BattleOne+0x73>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BattleOne>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%ebp
mov    %edi,%ebx
xor    %r15d,%r15d
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x2e8ba2e9,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rcx,%rdx,2),%ecx
neg    %ecx
add    %ecx,%eax
add    $0xf,%eax
imul   %ebx,%eax
cltq
imul   $0xffffffffae147ae1,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
add    %ebp,%eax
xor    %ecx,%ecx
test   %eax,%eax
setle  %cl
cmovs  %r15d,%eax
mov    %eax,(%r14)
lea    (%rcx,%rcx,1),%eax
add    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @BattleOne(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32* %2, i32** %7
%8 = load i32, i32* %6
%9 = load i32, i32* %5
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 11
%12 = add nsw i32 15, %11
%13 = mul nsw i32 %9, %12
%14 = sdiv i32 %13, 100
%15 = sub nsw i32 %8, %14
%16 = load i32*, i32** %7
store i32 %15, i32* %16
%17 = load i32*, i32** %7
%18 = load i32, i32* %17
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %3
store i32 -1, i32* %4
br label %23
21: ; preds = %3
%22 = load i32*, i32** %7
store i32 0, i32* %22
store i32 1, i32* %4
br label %23
23: ; preds = %21, %20
%24 = load i32, i32* %4
ret i32 %24
}

LLVM IR (-O2):
define i32 @BattleOne(i32 %0, i32 %1, i32* nocapture writeonly %2) {
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 11
%6 = add nsw i32 %5, 15
%7 = mul nsw i32 %6, %0
%8 = sdiv i32 %7, -100
%9 = add i32 %8, %1
%10 = icmp sgt i32 %9, 0
%11 = select i1 %10, i32 %9, i32 0
store i32 %11, i32* %2
%12 = select i1 %10, i32 -1, i32 1
ret i32 %12
}