#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 */
scalar_t__ malloc(int);
int rand();
int /*<<< orphan*/ sprintf(char *, char *, int);
const char *mR() {
  int r = rand() % 16;
  char *str = (char *)malloc(sizeof(char));
  char s;
  if (r > 9) {
    if (r == 10)
      str[0] = 'a';
    if (r == 11)
      str[0] = 'b';
    if (r == 12)
      str[0] = 'c';
    if (r == 13)
      str[0] = 'd';
    if (r == 14)
      str[0] = 'e';
    if (r == 15)
      str[0] = 'f';
  } else {
    char buffer[1];
    sprintf(buffer, "%d", r);
    str[0] = buffer[0];
  }
  return str;
}


x86 assembly (clang, -O0):
<mR>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
mov    $0x1,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpl   $0x9,-0x4(%rbp)
jle    11cd <mR+0x9d>
cmpl   $0xa,-0x4(%rbp)
jne    1173 <mR+0x43>
mov    -0x10(%rbp),%rax
movb   $0x61,(%rax)
cmpl   $0xb,-0x4(%rbp)
jne    1184 <mR+0x54>
mov    -0x10(%rbp),%rax
movb   $0x62,(%rax)
cmpl   $0xc,-0x4(%rbp)
jne    1195 <mR+0x65>
mov    -0x10(%rbp),%rax
movb   $0x63,(%rax)
cmpl   $0xd,-0x4(%rbp)
jne    11a6 <mR+0x76>
mov    -0x10(%rbp),%rax
movb   $0x64,(%rax)
cmpl   $0xe,-0x4(%rbp)
jne    11b7 <mR+0x87>
mov    -0x10(%rbp),%rax
movb   $0x65,(%rax)
cmpl   $0xf,-0x4(%rbp)
jne    11c8 <mR+0x98>
mov    -0x10(%rbp),%rax
movb   $0x66,(%rax)
jmp    11e9 <mR+0xb9>
lea    -0x12(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe25(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x12(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mR>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,%ebx
lea    0xf(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
and    $0xfffffff0,%eax
sub    %eax,%ebx
mov    $0x1,%edi
call   1030 <malloc@plt>
mov    %rax,%r14
cmp    $0xa,%ebx
jl     117a <mR+0x4a>
add    $0xfffffff6,%ebx
cmp    $0x5,%ebx
ja     1194 <mR+0x64>
lea    0xe95(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
movb   $0x61,(%r14)
jmp    1194 <mR+0x64>
lea    0xe97(%rip),%rsi
lea    0x7(%rsp),%rdi
mov    %ebx,%edx
call   1040 <sprintf@plt>
mov    0x7(%rsp),%al
mov    %al,(%r14)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
movb   $0x62,(%r14)
jmp    1194 <mR+0x64>
movb   $0x63,(%r14)
jmp    1194 <mR+0x64>
movb   $0x64,(%r14)
jmp    1194 <mR+0x64>
movb   $0x65,(%r14)
jmp    1194 <mR+0x64>
movb   $0x66,(%r14)
jmp    1194 <mR+0x64>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i8* @mR() {
%1 = alloca [1 x i8]
%2 = tail call i32 (...) @rand()
%3 = srem i32 %2, 16
%4 = tail call i64 @malloc(i32 1)
%5 = inttoptr i64 %4 to i8*
%6 = icmp sgt i32 %3, 9
br i1 %6, label %7, label %14
7: ; preds = %0
switch i32 %3, label %18 [
i32 10, label %8
i32 11, label %9
i32 12, label %10
i32 13, label %11
i32 14, label %12
i32 15, label %13
]
8: ; preds = %7
store i8 97, i8* %5
br label %18
9: ; preds = %7
store i8 98, i8* %5
br label %18
10: ; preds = %7
store i8 99, i8* %5
br label %18
11: ; preds = %7
store i8 100, i8* %5
br label %18
12: ; preds = %7
store i8 101, i8* %5
br label %18
13: ; preds = %7
store i8 102, i8* %5
br label %18
14: ; preds = %0
%15 = getelementptr inbounds [1 x i8], [1 x i8]* %1, i64 0, i64 0
%16 = call i32 @sprintf(i8* %15, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %3)
%17 = load i8, i8* %15
store i8 %17, i8* %5
br label %18
18: ; preds = %12, %11, %10, %9, %8, %7, %13, %14
ret i8* %5
}