#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 game {
  int dummy;
};

/* Variables and functions */
scalar_t__ roll(struct game *, int);
int rollMany(struct game *game, int pins, int count) {
  for (int i = 0; i < count; i++) {
    if (roll(game, pins) != 0) {
      return (-1);
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<rollMany>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    116a <rollMany+0x5a>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <roll@plt>
cmp    $0x0,%rax
je     1157 <rollMany+0x47>
movl   $0xffffffff,-0x4(%rbp)
jmp    1171 <rollMany+0x61>
jmp    115c <rollMany+0x4c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1129 <rollMany+0x19>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rollMany>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edx,%edx
jle    1164 <rollMany+0x54>
mov    %edx,%ebx
mov    %esi,%r14d
mov    %rdi,%r15
call   1030 <roll@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    1166 <rollMany+0x56>
mov    $0x1,%ecx
nopw   0x0(%rax,%rax,1)
mov    %ecx,%ebp
cmp    %ecx,%ebx
je     1159 <rollMany+0x49>
mov    %r15,%rdi
mov    %r14d,%esi
call   1030 <roll@plt>
lea    0x1(%rbp),%ecx
test   %rax,%rax
je     1140 <rollMany+0x30>
xor    %eax,%eax
cmp    %ebx,%ebp
setl   %al
neg    %eax
jmp    1166 <rollMany+0x56>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.game = type { i32 }
define i32 @rollMany(%struct.game* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.game*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store %struct.game* %0, %struct.game** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %20, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %7
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %23
13: ; preds = %9
%14 = load %struct.game*, %struct.game** %5
%15 = load i32, i32* %6
%16 = call i64 @roll(%struct.game* %14, i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %13
store i32 -1, i32* %4
br label %24
19: ; preds = %13
br label %20
20: ; preds = %19
%21 = load i32, i32* %8
%22 = add nsw i32 %21, 1
store i32 %22, i32* %8
br label %9
23: ; preds = %9
store i32 0, i32* %4
br label %24
24: ; preds = %23, %18
%25 = load i32, i32* %4
ret i32 %25
}

LLVM IR (-O2):
%struct.game = type { i32 }
define i32 @rollMany(%struct.game* %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %18
5: ; preds = %3
%6 = tail call i64 @roll(%struct.game* %0, i32 %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %5, %11
%9 = phi i32 [ %14, %11 ], [ 1, %5 ]
%10 = icmp eq i32 %9, %2
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = tail call i64 @roll(%struct.game* %0, i32 %1)
%13 = icmp eq i64 %12, 0
%14 = add nuw nsw i32 %9, 1
br i1 %13, label %8, label %15
15: ; preds = %8, %11
%16 = icmp slt i32 %9, %2
%17 = sext i1 %16 to i32
br label %18
18: ; preds = %15, %5, %3
%19 = phi i32 [ 0, %3 ], [ -1, %5 ], [ %17, %15 ]
ret i32 %19
}