#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 */
size_t RandomNumber(int, int);
int MakeAlphaString(int x, int y, char str[]) {
  static char *alphanum = "0123456789"
                          "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                          "abcdefghijklmnopqrstuvwxyz";
  int arrmax = 61;
  register int i, len;
  len = RandomNumber(x, y);
  for (i = 0; i < len; i++)
    str[i] = alphanum[RandomNumber(0, arrmax)];
  return len;
}


x86 assembly (clang, -O0):
<MakeAlphaString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movl   $0x3d,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <RandomNumber@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1182 <MakeAlphaString+0x72>
mov    0x2ed7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%esi
xor    %edi,%edi
call   1030 <RandomNumber@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113e <MakeAlphaString+0x2e>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MakeAlphaString>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r15
call   1030 <RandomNumber@plt>
mov    %rax,%r14
test   %r14d,%r14d
jle    115e <MakeAlphaString+0x4e>
mov    %r14d,%r12d
xor    %ebx,%ebx
lea    0xecb(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nop
xor    %edi,%edi
mov    $0x3d,%esi
call   1030 <RandomNumber@plt>
movzbl (%rax,%r13,1),%eax
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <MakeAlphaString+0x30>
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@MakeAlphaString.alphanum = internal global i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i32 0, i32 0)
@.str = [63 x i8] c"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\00"
define i32 @MakeAlphaString(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i32 61, i32* %7
%10 = load i32, i32* %4
%11 = load i32, i32* %5
%12 = call i64 @RandomNumber(i32 %10, i32 %11)
%13 = trunc i64 %12 to i32
store i32 %13, i32* %9
store i32 0, i32* %8
br label %14
14: ; preds = %28, %3
%15 = load i32, i32* %8
%16 = load i32, i32* %9
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %31
18: ; preds = %14
%19 = load i8*, i8** @MakeAlphaString.alphanum
%20 = load i32, i32* %7
%21 = call i64 @RandomNumber(i32 0, i32 %20)
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = load i8*, i8** %6
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
store i8 %23, i8* %27
br label %28
28: ; preds = %18
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
store i32 %30, i32* %8
br label %14
31: ; preds = %14
%32 = load i32, i32* %9
ret i32 %32
}

LLVM IR (-O2):
@.str = [63 x i8] c"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\00"
define i32 @MakeAlphaString(i32 %0, i32 %1, i8* nocapture writeonly %2) {
%4 = tail call i64 @RandomNumber(i32 %0, i32 %1)
%5 = trunc i64 %4 to i32
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %17
7: ; preds = %3
%8 = and i64 %4, 4294967295
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %15, %9 ]
%11 = tail call i64 @RandomNumber(i32 0, i32 61)
%12 = getelementptr inbounds [63 x i8], [63 x i8]* @.str, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = getelementptr inbounds i8, i8* %2, i64 %10
store i8 %13, i8* %14
%15 = add nuw nsw i64 %10, 1
%16 = icmp eq i64 %15, %8
br i1 %16, label %17, label %9
17: ; preds = %9, %3
ret i32 %5
}