#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 random();
void make_random_dest(char *dest) {
  int i, r;
  dest += 2;
  for (i = 0; i < 12; i++) {
    r = random() % 9;
    *(dest++) = (char)(r + 48);
  }
  *(dest + 12) = '\0';
}


x86 assembly (clang, -O0):
<make_random_dest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xc,-0xc(%rbp)
jge    1172 <make_random_dest+0x62>
mov    $0x0,%al
call   1030 <random@plt>
mov    $0x9,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x30,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112f <make_random_dest+0x1f>
mov    -0x8(%rbp),%rax
movb   $0x0,0xc(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_random_dest>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <random@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
add    $0x30,%al
mov    %al,0x2(%rbx)
xor    %eax,%eax
call   1030 <random@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
add    $0x30,%al
mov    %al,0x3(%rbx)
xor    %eax,%eax
call   1030 <random@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
add    $0x30,%al
mov    %al,0x4(%rbx)
xor    %eax,%eax
call   1030 <random@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
add    $0x30,%al
mov    %al,0x5(%rbx)
xor    %eax,%eax
call   1030 <random@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
add    $0x30,%al
mov    %al,0x6(%rbx)
xor    %eax,%eax
call   1030 <random@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
add    $0x30,%al
mov    %al,0x7(%rbx)
xor    %eax,%eax
call   1030 <random@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
add    $0x30,%al
mov    %al,0x8(%rbx)
xor    %eax,%eax
call   1030 <random@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
add    $0x30,%al
mov    %al,0x9(%rbx)
xor    %eax,%eax
call   1030 <random@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
add    $0x30,%al
mov    %al,0xa(%rbx)
xor    %eax,%eax
call   1030 <random@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
add    $0x30,%al
mov    %al,0xb(%rbx)
xor    %eax,%eax
call   1030 <random@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
add    $0x30,%al
mov    %al,0xc(%rbx)
xor    %eax,%eax
call   1030 <random@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
add    $0x30,%al
mov    %al,0xd(%rbx)
movb   $0x0,0x1a(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @make_random_dest(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = getelementptr inbounds i8, i8* %5, i64 2
store i8* %6, i8** %2
store i32 0, i32* %3
br label %7
7: ; preds = %18, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 12
br i1 %9, label %10, label %21
10: ; preds = %7
%11 = call i32 (...) @random()
%12 = srem i32 %11, 9
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 48
%15 = trunc i32 %14 to i8
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %2
store i8 %15, i8* %16
br label %18
18: ; preds = %10
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %7
21: ; preds = %7
%22 = load i8*, i8** %2
%23 = getelementptr inbounds i8, i8* %22, i64 12
store i8 0, i8* %23
ret void
}

LLVM IR (-O2):
define void @make_random_dest(i8* nocapture writeonly %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 2
%3 = tail call i32 (...) @random()
%4 = srem i32 %3, 9
%5 = trunc i32 %4 to i8
%6 = add nsw i8 %5, 48
%7 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %6, i8* %2
%8 = tail call i32 (...) @random()
%9 = srem i32 %8, 9
%10 = trunc i32 %9 to i8
%11 = add nsw i8 %10, 48
%12 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %11, i8* %7
%13 = tail call i32 (...) @random()
%14 = srem i32 %13, 9
%15 = trunc i32 %14 to i8
%16 = add nsw i8 %15, 48
%17 = getelementptr inbounds i8, i8* %0, i64 5
store i8 %16, i8* %12
%18 = tail call i32 (...) @random()
%19 = srem i32 %18, 9
%20 = trunc i32 %19 to i8
%21 = add nsw i8 %20, 48
%22 = getelementptr inbounds i8, i8* %0, i64 6
store i8 %21, i8* %17
%23 = tail call i32 (...) @random()
%24 = srem i32 %23, 9
%25 = trunc i32 %24 to i8
%26 = add nsw i8 %25, 48
%27 = getelementptr inbounds i8, i8* %0, i64 7
store i8 %26, i8* %22
%28 = tail call i32 (...) @random()
%29 = srem i32 %28, 9
%30 = trunc i32 %29 to i8
%31 = add nsw i8 %30, 48
%32 = getelementptr inbounds i8, i8* %0, i64 8
store i8 %31, i8* %27
%33 = tail call i32 (...) @random()
%34 = srem i32 %33, 9
%35 = trunc i32 %34 to i8
%36 = add nsw i8 %35, 48
%37 = getelementptr inbounds i8, i8* %0, i64 9
store i8 %36, i8* %32
%38 = tail call i32 (...) @random()
%39 = srem i32 %38, 9
%40 = trunc i32 %39 to i8
%41 = add nsw i8 %40, 48
%42 = getelementptr inbounds i8, i8* %0, i64 10
store i8 %41, i8* %37
%43 = tail call i32 (...) @random()
%44 = srem i32 %43, 9
%45 = trunc i32 %44 to i8
%46 = add nsw i8 %45, 48
%47 = getelementptr inbounds i8, i8* %0, i64 11
store i8 %46, i8* %42
%48 = tail call i32 (...) @random()
%49 = srem i32 %48, 9
%50 = trunc i32 %49 to i8
%51 = add nsw i8 %50, 48
%52 = getelementptr inbounds i8, i8* %0, i64 12
store i8 %51, i8* %47
%53 = tail call i32 (...) @random()
%54 = srem i32 %53, 9
%55 = trunc i32 %54 to i8
%56 = add nsw i8 %55, 48
%57 = getelementptr inbounds i8, i8* %0, i64 13
store i8 %56, i8* %52
%58 = tail call i32 (...) @random()
%59 = srem i32 %58, 9
%60 = trunc i32 %59 to i8
%61 = add nsw i8 %60, 48
store i8 %61, i8* %57
%62 = getelementptr inbounds i8, i8* %0, i64 26
store i8 0, i8* %62
ret void
}