#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 random();
void qd_generate_discriminator(char *string) {
  static const char *table =
      "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+_";
  long int rnd1 = random();
  long int rnd2 = random();
  long int rnd3 = random();
  int idx;
  int cursor = 0;
  for (idx = 0; idx < 5; idx++) {
    string[cursor++] = table[(rnd1 >> (idx * 6)) & 63];
    string[cursor++] = table[(rnd2 >> (idx * 6)) & 63];
    string[cursor++] = table[(rnd3 >> (idx * 6)) & 63];
  }
  string[cursor] = '\0';
}


x86 assembly (clang, -O0):
<qd_generate_discriminator>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <random@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <random@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <random@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jge    11fc <qd_generate_discriminator+0xec>
mov    0x2ecc(%rip),%rax
mov    -0x10(%rbp),%rdx
imul   $0x6,-0x24(%rbp),%ecx
mov    %ecx,%ecx
sar    %cl,%rdx
mov    %rdx,%rcx
and    $0x3f,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x28(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    0x2e99(%rip),%rax
mov    -0x18(%rbp),%rdx
imul   $0x6,-0x24(%rbp),%ecx
mov    %ecx,%ecx
sar    %cl,%rdx
mov    %rdx,%rcx
and    $0x3f,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x28(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    0x2e66(%rip),%rax
mov    -0x20(%rbp),%rdx
imul   $0x6,-0x24(%rbp),%ecx
mov    %ecx,%ecx
sar    %cl,%rdx
mov    %rdx,%rcx
and    $0x3f,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x28(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114b <qd_generate_discriminator+0x3b>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qd_generate_discriminator>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <random@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1030 <random@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1030 <random@plt>
mov    %r15d,%edx
and    $0x3f,%edx
lea    0xec0(%rip),%rcx
mov    (%rdx,%rcx,1),%dl
mov    %dl,(%rbx)
mov    %r14d,%edx
and    $0x3f,%edx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0x1(%rbx)
mov    %eax,%edx
and    $0x3f,%edx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0x2(%rbx)
mov    %r15d,%edx
shr    $0x6,%edx
and    $0x3f,%edx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0x3(%rbx)
mov    %r14d,%edx
shr    $0x6,%edx
and    $0x3f,%edx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0x4(%rbx)
mov    %eax,%edx
shr    $0x6,%edx
and    $0x3f,%edx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0x5(%rbx)
mov    %r15d,%edx
shr    $0xc,%edx
and    $0x3f,%edx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0x6(%rbx)
mov    %r14d,%edx
shr    $0xc,%edx
and    $0x3f,%edx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0x7(%rbx)
mov    %eax,%edx
shr    $0xc,%edx
and    $0x3f,%edx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0x8(%rbx)
mov    %r15d,%edx
shr    $0x12,%edx
and    $0x3f,%edx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0x9(%rbx)
mov    %r14d,%edx
shr    $0x12,%edx
and    $0x3f,%edx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0xa(%rbx)
mov    %eax,%edx
shr    $0x12,%edx
and    $0x3f,%edx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0xb(%rbx)
shr    $0x18,%r15d
and    $0x3f,%r15d
mov    (%r15,%rcx,1),%dl
mov    %dl,0xc(%rbx)
shr    $0x18,%r14d
and    $0x3f,%r14d
mov    (%r14,%rcx,1),%dl
mov    %dl,0xd(%rbx)
shr    $0x18,%eax
and    $0x3f,%eax
mov    (%rax,%rcx,1),%al
mov    %al,0xe(%rbx)
movb   $0x0,0xf(%rbx)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@qd_generate_discriminator.table = internal global i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0)
@.str = [65 x i8] c"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+_\00"
define void @qd_generate_discriminator(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %2
%8 = call i64 (...) @random()
store i64 %8, i64* %3
%9 = call i64 (...) @random()
store i64 %9, i64* %4
%10 = call i64 (...) @random()
store i64 %10, i64* %5
store i32 0, i32* %7
store i32 0, i32* %6
br label %11
11: ; preds = %57, %1
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 5
br i1 %13, label %14, label %60
14: ; preds = %11
%15 = load i8*, i8** @qd_generate_discriminator.table
%16 = load i64, i64* %3
%17 = load i32, i32* %6
%18 = mul nsw i32 %17, 6
%19 = zext i32 %18 to i64
%20 = ashr i64 %16, %19
%21 = and i64 %20, 63
%22 = getelementptr inbounds i8, i8* %15, i64 %21
%23 = load i8, i8* %22
%24 = load i8*, i8** %2
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
%27 = sext i32 %25 to i64
%28 = getelementptr inbounds i8, i8* %24, i64 %27
store i8 %23, i8* %28
%29 = load i8*, i8** @qd_generate_discriminator.table
%30 = load i64, i64* %4
%31 = load i32, i32* %6
%32 = mul nsw i32 %31, 6
%33 = zext i32 %32 to i64
%34 = ashr i64 %30, %33
%35 = and i64 %34, 63
%36 = getelementptr inbounds i8, i8* %29, i64 %35
%37 = load i8, i8* %36
%38 = load i8*, i8** %2
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
%41 = sext i32 %39 to i64
%42 = getelementptr inbounds i8, i8* %38, i64 %41
store i8 %37, i8* %42
%43 = load i8*, i8** @qd_generate_discriminator.table
%44 = load i64, i64* %5
%45 = load i32, i32* %6
%46 = mul nsw i32 %45, 6
%47 = zext i32 %46 to i64
%48 = ashr i64 %44, %47
%49 = and i64 %48, 63
%50 = getelementptr inbounds i8, i8* %43, i64 %49
%51 = load i8, i8* %50
%52 = load i8*, i8** %2
%53 = load i32, i32* %7
%54 = add nsw i32 %53, 1
store i32 %54, i32* %7
%55 = sext i32 %53 to i64
%56 = getelementptr inbounds i8, i8* %52, i64 %55
store i8 %51, i8* %56
br label %57
57: ; preds = %14
%58 = load i32, i32* %6
%59 = add nsw i32 %58, 1
store i32 %59, i32* %6
br label %11
60: ; preds = %11
%61 = load i8*, i8** %2
%62 = load i32, i32* %7
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %61, i64 %63
store i8 0, i8* %64
ret void
}

LLVM IR (-O2):
@.str = [65 x i8] c"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+_\00"
define void @qd_generate_discriminator(i8* nocapture writeonly %0) {
%2 = tail call i64 (...) @random()
%3 = tail call i64 (...) @random()
%4 = tail call i64 (...) @random()
%5 = and i64 %2, 63
%6 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %5
%7 = load i8, i8* %6
store i8 %7, i8* %0
%8 = and i64 %3, 63
%9 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %10, i8* %11
%12 = and i64 %4, 63
%13 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %14, i8* %15
%16 = lshr i64 %2, 6
%17 = and i64 %16, 63
%18 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %19, i8* %20
%21 = lshr i64 %3, 6
%22 = and i64 %21, 63
%23 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %24, i8* %25
%26 = lshr i64 %4, 6
%27 = and i64 %26, 63
%28 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = getelementptr inbounds i8, i8* %0, i64 5
store i8 %29, i8* %30
%31 = lshr i64 %2, 12
%32 = and i64 %31, 63
%33 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = getelementptr inbounds i8, i8* %0, i64 6
store i8 %34, i8* %35
%36 = lshr i64 %3, 12
%37 = and i64 %36, 63
%38 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = getelementptr inbounds i8, i8* %0, i64 7
store i8 %39, i8* %40
%41 = lshr i64 %4, 12
%42 = and i64 %41, 63
%43 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = getelementptr inbounds i8, i8* %0, i64 8
store i8 %44, i8* %45
%46 = lshr i64 %2, 18
%47 = and i64 %46, 63
%48 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = getelementptr inbounds i8, i8* %0, i64 9
store i8 %49, i8* %50
%51 = lshr i64 %3, 18
%52 = and i64 %51, 63
%53 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %52
%54 = load i8, i8* %53
%55 = getelementptr inbounds i8, i8* %0, i64 10
store i8 %54, i8* %55
%56 = lshr i64 %4, 18
%57 = and i64 %56, 63
%58 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %57
%59 = load i8, i8* %58
%60 = getelementptr inbounds i8, i8* %0, i64 11
store i8 %59, i8* %60
%61 = lshr i64 %2, 24
%62 = and i64 %61, 63
%63 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %62
%64 = load i8, i8* %63
%65 = getelementptr inbounds i8, i8* %0, i64 12
store i8 %64, i8* %65
%66 = lshr i64 %3, 24
%67 = and i64 %66, 63
%68 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %67
%69 = load i8, i8* %68
%70 = getelementptr inbounds i8, i8* %0, i64 13
store i8 %69, i8* %70
%71 = lshr i64 %4, 24
%72 = and i64 %71, 63
%73 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %72
%74 = load i8, i8* %73
%75 = getelementptr inbounds i8, i8* %0, i64 14
store i8 %74, i8* %75
%76 = getelementptr inbounds i8, i8* %0, i64 15
store i8 0, i8* %76
ret void
}