#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 */
long long lrand48();
scalar_t__ tintoi(char *);
double tindice(char *left, char *right) {
  long long cnt, numdice, sizedice, sum;
  numdice = (long long)tintoi(left);
  sizedice = (long long)tintoi(right);
  for (cnt = sum = 0; cnt < numdice; cnt++) {
    sum += lrand48() % sizedice + 1;
  }
  return (double)sum;
}


x86 assembly (clang, -O0):
<tindice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <tintoi@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <tintoi@plt>
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    1195 <tindice+0x75>
mov    $0x0,%al
call   1040 <lrand48@plt>
cqto
idivq  -0x28(%rbp)
mov    %rdx,%rax
add    $0x1,%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    115a <tindice+0x3a>
cvtsi2sdq -0x30(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tindice>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
call   1030 <tintoi@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <tintoi@plt>
test   %r15,%r15
jle    1183 <tindice+0x63>
mov    %rax,%r14
xor    %ebx,%ebx
jmp    1162 <tindice+0x42>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cqto
idiv   %r14
add    %rdx,%rbx
add    $0x1,%rbx
add    $0xffffffffffffffff,%r15
je     117c <tindice+0x5c>
xor    %eax,%eax
call   1040 <lrand48@plt>
mov    %rax,%rcx
or     %r14,%rcx
shr    $0x20,%rcx
jne    1150 <tindice+0x30>
xor    %edx,%edx
div    %r14d
jmp    1155 <tindice+0x35>
cvtsi2sd %rbx,%xmm0
jmp    1187 <tindice+0x67>
xorpd  %xmm0,%xmm0
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @tindice(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%9 = load i8*, i8** %3
%10 = call i64 @tintoi(i8* %9)
store i64 %10, i64* %6
%11 = load i8*, i8** %4
%12 = call i64 @tintoi(i8* %11)
store i64 %12, i64* %7
store i64 0, i64* %8
store i64 0, i64* %5
br label %13
13: ; preds = %24, %2
%14 = load i64, i64* %5
%15 = load i64, i64* %6
%16 = icmp slt i64 %14, %15
br i1 %16, label %17, label %27
17: ; preds = %13
%18 = call i64 (...) @lrand48()
%19 = load i64, i64* %7
%20 = srem i64 %18, %19
%21 = add nsw i64 %20, 1
%22 = load i64, i64* %8
%23 = add nsw i64 %22, %21
store i64 %23, i64* %8
br label %24
24: ; preds = %17
%25 = load i64, i64* %5
%26 = add nsw i64 %25, 1
store i64 %26, i64* %5
br label %13
27: ; preds = %13
%28 = load i64, i64* %8
%29 = sitofp i64 %28 to double
ret double %29
}

LLVM IR (-O2):
define double @tindice(i8* %0, i8* %1) {
%3 = tail call i64 @tintoi(i8* %0)
%4 = tail call i64 @tintoi(i8* %1)
%5 = icmp sgt i64 %3, 0
br i1 %5, label %6, label %17
6: ; preds = %2, %6
%7 = phi i64 [ %12, %6 ], [ 0, %2 ]
%8 = phi i64 [ %13, %6 ], [ 0, %2 ]
%9 = tail call i64 (...) @lrand48()
%10 = srem i64 %9, %4
%11 = add i64 %7, 1
%12 = add i64 %11, %10
%13 = add nuw nsw i64 %8, 1
%14 = icmp eq i64 %13, %3
br i1 %14, label %15, label %6
15: ; preds = %6
%16 = sitofp i64 %12 to double
br label %17
17: ; preds = %15, %2
%18 = phi double [ 0.000000e+00, %2 ], [ %16, %15 ]
ret double %18
}