#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*/ assert(int);
scalar_t__ dice_parse(char const *, int *, int *, int *);
int dice_roll_numeric(int, int, int);
int dice_roll(const char *ptr) {
  int num = 0, faces = 0, bias = 0;
  if (dice_parse(ptr, &num, &faces, &bias)) {
    assert(false);
    return 0;
  }
  return dice_roll_numeric(num, faces, bias);
}


x86 assembly (clang, -O0):
<dice_roll>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
call   1050 <dice_parse@plt>
cmp    $0x0,%rax
je     1183 <dice_roll+0x53>
xor    %edi,%edi
call   1040 <assert@plt>
movl   $0x0,-0x4(%rbp)
jmp    1194 <dice_roll+0x64>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1030 <dice_roll_numeric@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dice_roll>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
call   1050 <dice_parse@plt>
test   %rax,%rax
je     1171 <dice_roll+0x41>
xor    %ebx,%ebx
xor    %edi,%edi
call   1040 <assert@plt>
jmp    1184 <dice_roll+0x54>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
mov    0x4(%rsp),%edx
call   1030 <dice_roll_numeric@plt>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @dice_roll(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%7 = load i8*, i8** %3
%8 = call i64 @dice_parse(i8* %7, i32* %4, i32* %5, i32* %6)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 @assert(i32 0)
store i32 0, i32* %2
br label %17
12: ; preds = %1
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = call i32 @dice_roll_numeric(i32 %13, i32 %14, i32 %15)
store i32 %16, i32* %2
br label %17
17: ; preds = %12, %10
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
define i32 @dice_roll(i8* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = call i64 @dice_parse(i8* %0, i32* %2, i32* %3, i32* %4)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %1
%11 = call i32 @assert(i32 0)
br label %17
12: ; preds = %1
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = call i32 @dice_roll_numeric(i32 %13, i32 %14, i32 %15)
br label %17
17: ; preds = %12, %10
%18 = phi i32 [ 0, %10 ], [ %16, %12 ]
ret i32 %18
}