#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 */
typedef int /*<<< orphan*/ alphanum;

/* Variables and functions */
int rand();
void get_rnd_str(unsigned char *str, size_t len) {
  size_t i;
  static const unsigned char alphanum[] = "0123456789"
                                          "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                                          "abcdefghijklmnopqrstuvwxyz";
  for (i = 0; i < len; ++i) {
    str[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
  }
}


x86 assembly (clang, -O0):
<get_rnd_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    116f <get_rnd_str+0x5f>
mov    $0x0,%al
call   1030 <rand@plt>
cltq
mov    $0x3e,%ecx
xor    %edx,%edx
div    %rcx
lea    0xeb0(%rip),%rax
mov    (%rax,%rdx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1128 <get_rnd_str+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_rnd_str>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %rsi,%rsi
je     117c <get_rnd_str+0x6c>
mov    %rsi,%r13
mov    %rdi,%r14
movabs $0x8421084210842109,%r15
08 21 84
lea    0xecb(%rip),%r12
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <rand@plt>
movslq %eax,%rcx
mov    %rcx,%rax
shr    %rax
mul    %r15
shr    $0x4,%rdx
mov    %rdx,%rax
shl    $0x6,%rax
mov    %rdx,%rsi
sub    %rax,%rsi
add    %rdx,%rsi
add    %rcx,%rsi
movzbl (%r12,%rsi,1),%eax
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1140 <get_rnd_str+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@get_rnd_str.alphanum = internal constant [63 x i8] c"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\00"
define void @get_rnd_str(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
store i64 0, i64* %5
br label %6
6: ; preds = %19, %2
%7 = load i64, i64* %5
%8 = load i64, i64* %4
%9 = icmp ult i64 %7, %8
br i1 %9, label %10, label %22
10: ; preds = %6
%11 = call i32 (...) @rand()
%12 = sext i32 %11 to i64
%13 = urem i64 %12, 62
%14 = getelementptr inbounds [63 x i8], [63 x i8]* @get_rnd_str.alphanum, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = load i8*, i8** %3
%17 = load i64, i64* %5
%18 = getelementptr inbounds i8, i8* %16, i64 %17
store i8 %15, i8* %18
br label %19
19: ; preds = %10
%20 = load i64, i64* %5
%21 = add i64 %20, 1
store i64 %21, i64* %5
br label %6
22: ; preds = %6
ret void
}

LLVM IR (-O2):
@get_rnd_str.alphanum = internal unnamed_addr constant [63 x i8] c"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\00"
define void @get_rnd_str(i8* nocapture writeonly %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %14, label %4
4: ; preds = %2, %4
%5 = phi i64 [ %12, %4 ], [ 0, %2 ]
%6 = tail call i32 (...) @rand()
%7 = sext i32 %6 to i64
%8 = urem i64 %7, 62
%9 = getelementptr inbounds [63 x i8], [63 x i8]* @get_rnd_str.alphanum, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = getelementptr inbounds i8, i8* %0, i64 %5
store i8 %10, i8* %11
%12 = add nuw i64 %5, 1
%13 = icmp eq i64 %12, %1
br i1 %13, label %14, label %4
14: ; preds = %4, %2
ret void
}