#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 rand();
int /*<<< orphan*/ snprintf(char *, int, char *, char);
int /*<<< orphan*/ srand(unsigned int);
int /*<<< orphan*/ strcat(char *, char *);
char *strdup(char *);
unsigned long time(int /*<<< orphan*/);
char *frand(void) {
  char str[64] =
      "t00uAv1wB2xCy3Dz4EF5Gs6HaIb7cJdK8eLf9gMhNOiPjQkRmSnTUoVWqXYpZr";
  int i, start, end;
  char tmp[2];
  unsigned long l;
  char str_rand[9], *p;
  l = time(0);
  start = l % 50 + 1;
  end = start + 9;
  str_rand[0] = '\0';
  srand((unsigned int)(l % 50));
  for (i = start; i < end; i++) {
    snprintf(tmp, 2, "%c", str[(rand() % i) + 1]);
    strcat(str_rand, tmp);
  }
  p = strdup(str_rand);
  return p;
}


x86 assembly (clang, -O0):
<frand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
lea    -0x40(%rbp),%rdi
lea    0xe7a(%rip),%rsi
mov    $0x40,%edx
call   1050 <memcpy@plt>
xor    %edi,%edi
call   1060 <time@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    $0x32,%ecx
xor    %edx,%edx
div    %rcx
add    $0x1,%rdx
mov    %edx,%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
add    $0x9,%eax
mov    %eax,-0x4c(%rbp)
movb   $0x0,-0x61(%rbp)
mov    -0x58(%rbp),%rax
mov    $0x32,%ecx
xor    %edx,%edx
div    %rcx
mov    %edx,%edi
call   1040 <srand@plt>
mov    -0x48(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    1234 <frand+0xc4>
lea    -0x4e(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    -0x78(%rbp),%rdi
cltd
idivl  -0x44(%rbp)
add    $0x1,%edx
movslq %edx,%rax
mov    $0x2,%esi
lea    0xe31(%rip),%rdx
movsbl -0x40(%rbp,%rax,1),%ecx
call   1030 <snprintf@plt>
lea    -0x61(%rbp),%rdi
lea    -0x4e(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11da <frand+0x6a>
lea    -0x61(%rbp),%rdi
call   1080 <strdup@plt>
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<frand>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %edi,%edi
call   1050 <time@plt>
mov    %rax,%rbx
shr    %rax
movabs $0xa3d70a3d70a3d70b,%rcx
0a d7 a3
mul    %rcx
shr    $0x4,%rdx
imul   $0x32,%edx,%eax
sub    %eax,%ebx
lea    0xa(%rbx),%ebp
movb   $0x0,0xf(%rsp)
mov    %ebx,%edi
call   1040 <srand@plt>
add    $0x1,%ebx
lea    0xe56(%rip),%r13
lea    0xe8f(%rip),%r14
lea    0xd(%rsp),%r15
lea    0xf(%rsp),%r12
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <rand@plt>
cltd
idiv   %ebx
movslq %edx,%rax
movsbl 0x1(%rax,%r13,1),%ecx
mov    %r15,%rdi
mov    $0x2,%esi
mov    %r14,%rdx
call   1030 <snprintf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
add    $0x1,%ebx
cmp    %ebp,%ebx
jb     11c0 <frand+0x60>
lea    0xf(%rsp),%rdi
call   1070 <strdup@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.frand.str = [64 x i8] c"t00uAv1wB2xCy3Dz4EF5Gs6HaIb7cJdK8eLf9gMhNOiPjQkRmSnTUoVWqXYpZr\00\00"
@.str = [3 x i8] c"%c\00"
define i8* @frand() {
%1 = alloca [64 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [2 x i8]
%6 = alloca i64
%7 = alloca [9 x i8]
%8 = alloca i8*
%9 = bitcast [64 x i8]* %1 to i8*
%10 = call i64 @time(i32 0)
store i64 %10, i64* %6
%11 = load i64, i64* %6
%12 = urem i64 %11, 50
%13 = add i64 %12, 1
%14 = trunc i64 %13 to i32
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 9
store i32 %16, i32* %4
%17 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
store i8 0, i8* %17
%18 = load i64, i64* %6
%19 = urem i64 %18, 50
%20 = trunc i64 %19 to i32
%21 = call i32 @srand(i32 %20)
%22 = load i32, i32* %3
store i32 %22, i32* %2
br label %23
23: ; preds = %40, %0
%24 = load i32, i32* %2
%25 = load i32, i32* %4
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %43
27: ; preds = %23
%28 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%29 = call i32 (...) @rand()
%30 = load i32, i32* %2
%31 = srem i32 %29, %30
%32 = add nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = call i32 @snprintf(i8* %28, i32 2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %35)
%37 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
%38 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%39 = call i32 @strcat(i8* %37, i8* %38)
br label %40
40: ; preds = %27
%41 = load i32, i32* %2
%42 = add nsw i32 %41, 1
store i32 %42, i32* %2
br label %23
43: ; preds = %23
%44 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
%45 = call i8* @strdup(i8* %44)
store i8* %45, i8** %8
%46 = load i8*, i8** %8
ret i8* %46
}

LLVM IR (-O2):
@__const.frand.str = [64 x i8] c"t00uAv1wB2xCy3Dz4EF5Gs6HaIb7cJdK8eLf9gMhNOiPjQkRmSnTUoVWqXYpZr\00\00"
@.str = [3 x i8] c"%c\00"
define noalias i8* @frand() {
%1 = alloca [2 x i8]
%2 = alloca [9 x i8]
%3 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%5 = tail call i64 @time(i32 0)
%6 = urem i64 %5, 50
%7 = trunc i64 %6 to i32
%8 = add nuw nsw i32 %7, 10
store i8 0, i8* %4
%9 = tail call i32 @srand(i32 %7)
%10 = add nuw nsw i32 %7, 1
br label %11
11: ; preds = %0, %11
%12 = phi i32 [ %10, %0 ], [ %21, %11 ]
%13 = call i32 (...) @rand()
%14 = srem i32 %13, %12
%15 = add nsw i32 %14, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [64 x i8], [64 x i8]* @__const.frand.str, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = call i32 @snprintf(i8* %3, i32 2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %18)
%20 = call i32 @strcat(i8* %4, i8* %3)
%21 = add nuw nsw i32 %12, 1
%22 = icmp ult i32 %21, %8
br i1 %22, label %11, label %23
23: ; preds = %11
%24 = call i8* @strdup(i8* %4)
ret i8* %24
}