#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*/ printf(char *, ...);
void printDice(int rolledDice[], int toRoll, int heldValues[], int numberHeld) {
  int i;
  if (numberHeld > 0) {
    printf("\n");
    for (i = 0; i < numberHeld; i++) {
      printf("Held Dice %d: %d\n", i + 1, heldValues[i]);
    }
  }
  printf("\n");
  if (toRoll == 0) {
    return;
  }
  for (i = 0; i < toRoll; i++) {
    printf("Dice %d: %d\n", i + 1, rolledDice[i]);
  }
  printf("\n");
  return;
}


x86 assembly (clang, -O0):
<printDice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    1183 <printDice+0x73>
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    117e <printDice+0x6e>
mov    -0x20(%rbp),%esi
add    $0x1,%esi
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1145 <printDice+0x35>
jmp    1183 <printDice+0x73>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11a0 <printDice+0x90>
jmp    11ee <printDice+0xde>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e0 <printDice+0xd0>
mov    -0x20(%rbp),%esi
add    $0x1,%esi
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a7 <printDice+0x97>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printDice>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r15
test   %ecx,%ecx
jle    116a <printDice+0x4a>
mov    %ecx,%ebx
mov    %rdx,%r13
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,%ebp
lea    0xeb3(%rip),%r12
xor    %ebx,%ebx
nop
mov    0x0(%r13,%rbx,4),%edx
add    $0x1,%rbx
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %rbx,%rbp
jne    1150 <printDice+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %r14d,%r14d
je     11c1 <printDice+0xa1>
jle    11a9 <printDice+0x89>
mov    %r14d,%ebx
lea    0xe80(%rip),%r14
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbp,4),%edx
add    $0x1,%rbp
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %rbp,%rbx
jne    1190 <printDice+0x70>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [18 x i8] c"Held Dice %d: %d\0A\00"
@.str.2 = [13 x i8] c"Dice %d: %d\0A\00"
define void @printDice(i32* %0, i32 %1, i32* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32 %3, i32* %8
%10 = load i32, i32* %8
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %31
12: ; preds = %4
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %9
br label %14
14: ; preds = %27, %12
%15 = load i32, i32* %9
%16 = load i32, i32* %8
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %30
18: ; preds = %14
%19 = load i32, i32* %9
%20 = add nsw i32 %19, 1
%21 = load i32*, i32** %7
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %25)
br label %27
27: ; preds = %18
%28 = load i32, i32* %9
%29 = add nsw i32 %28, 1
store i32 %29, i32* %9
br label %14
30: ; preds = %14
br label %31
31: ; preds = %30, %4
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%33 = load i32, i32* %6
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %31
br label %55
36: ; preds = %31
store i32 0, i32* %9
br label %37
37: ; preds = %50, %36
%38 = load i32, i32* %9
%39 = load i32, i32* %6
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %53
41: ; preds = %37
%42 = load i32, i32* %9
%43 = add nsw i32 %42, 1
%44 = load i32*, i32** %5
%45 = load i32, i32* %9
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %44, i64 %46
%48 = load i32, i32* %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %43, i32 %48)
br label %50
50: ; preds = %41
%51 = load i32, i32* %9
%52 = add nsw i32 %51, 1
store i32 %52, i32* %9
br label %37
53: ; preds = %37
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %55
55: ; preds = %53, %35
ret void
}

LLVM IR (-O2):
@.str.1 = [18 x i8] c"Held Dice %d: %d\0A\00"
@.str.2 = [13 x i8] c"Dice %d: %d\0A\00"
define void @printDice(i32* nocapture %0, i32 %1, i32* nocapture %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %17
6: ; preds = %4
%7 = tail call i32 @putchar(i32 10)
%8 = zext i32 %3 to i64
br label %9
9: ; preds = %6, %9
%10 = phi i64 [ 0, %6 ], [ %11, %9 ]
%11 = add nuw nsw i64 %10, 1
%12 = getelementptr inbounds i32, i32* %2, i64 %10
%13 = load i32, i32* %12
%14 = trunc i64 %11 to i32
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %13)
%16 = icmp eq i64 %11, %8
br i1 %16, label %17, label %9
17: ; preds = %9, %4
%18 = tail call i32 @putchar(i32 10)
%19 = icmp eq i32 %1, 0
br i1 %19, label %34, label %20
20: ; preds = %17
%21 = icmp sgt i32 %1, 0
br i1 %21, label %22, label %32
22: ; preds = %20
%23 = zext i32 %1 to i64
br label %24
24: ; preds = %22, %24
%25 = phi i64 [ 0, %22 ], [ %26, %24 ]
%26 = add nuw nsw i64 %25, 1
%27 = getelementptr inbounds i32, i32* %0, i64 %25
%28 = load i32, i32* %27
%29 = trunc i64 %26 to i32
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 %28)
%31 = icmp eq i64 %26, %23
br i1 %31, label %32, label %24
32: ; preds = %24, %20
%33 = tail call i32 @putchar(i32 10)
br label %34
34: ; preds = %17, %32
ret void
}