#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*/ allowable_chars;

/* Variables and functions */
scalar_t__ RAND_MAX;
scalar_t__ clock();
int rand();
scalar_t__ random();
int /*<<< orphan*/ srandom(scalar_t__);
scalar_t__ time(int /*<<< orphan*/);
char *random_chars(char *dst, int start, int end) {
  srandom(time(0) + clock() + random());
  static const char allowable_chars[] = "1234567890abcdefhijklnmopqrstuwxyz";
  int i, r;
  int size = rand() % (end - start + 1) + start;
  for (i = 0; i < size; i++) {
    r = (int)((double)rand() / ((double)RAND_MAX + 1) *
              (sizeof(allowable_chars) - 1));
    dst[i] = allowable_chars[r];
  }
  dst[i] = '\0';
  return dst;
}


x86 assembly (clang, -O0):
<random_chars>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
xor    %edi,%edi
call   1050 <time@plt>
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1060 <random@plt>
mov    -0x28(%rbp),%rdi
add    %rax,%rdi
call   1030 <srandom@plt>
mov    $0x0,%al
call   1070 <rand@plt>
mov    -0x10(%rbp),%ecx
sub    -0xc(%rbp),%ecx
add    $0x1,%ecx
cltd
idiv   %ecx
add    -0xc(%rbp),%edx
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1222 <random_chars+0xd2>
mov    $0x0,%al
call   1070 <rand@plt>
cvtsi2sd %eax,%xmm0
mov    0x2e15(%rip),%rax
cvtsi2sdq (%rax),%xmm1
movsd  0xe28(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  0xe10(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
movslq -0x18(%rbp),%rcx
lea    0xe0a(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b5 <random_chars+0x65>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_chars>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%r14d
mov    %rdi,%r13
xor    %ebp,%ebp
xor    %edi,%edi
call   1050 <time@plt>
mov    %rax,%r12
xor    %eax,%eax
call   1040 <clock@plt>
add    %rax,%r12
xor    %eax,%eax
call   1060 <random@plt>
add    %rax,%r12
mov    %r12,%rdi
call   1030 <srandom@plt>
xor    %eax,%eax
call   1070 <rand@plt>
sub    %r14d,%r15d
add    $0x1,%r15d
cltd
idiv   %r15d
add    %r14d,%edx
test   %edx,%edx
jle    1203 <random_chars+0xb3>
mov    %edx,%ebp
mov    0x2e3a(%rip),%r14
lea    0xe5b(%rip),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq (%r14),%xmm1
addsd  0xe22(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  0xe1e(%rip),%xmm0
cvttsd2si %xmm0,%eax
cltq
movzbl (%rax,%r15,1),%eax
mov    %al,0x0(%r13,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11c0 <random_chars+0x70>
movb   $0x0,0x0(%r13,%rbp,1)
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@random_chars.allowable_chars = internal constant [35 x i8] c"1234567890abcdefhijklnmopqrstuwxyz\00"
@RAND_MAX = global i64 0
define i8* @random_chars(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = call i64 @time(i32 0)
%11 = call i64 (...) @clock()
%12 = add nsw i64 %10, %11
%13 = call i64 (...) @random()
%14 = add nsw i64 %12, %13
%15 = call i32 @srandom(i64 %14)
%16 = call i32 (...) @rand()
%17 = load i32, i32* %6
%18 = load i32, i32* %5
%19 = sub nsw i32 %17, %18
%20 = add nsw i32 %19, 1
%21 = srem i32 %16, %20
%22 = load i32, i32* %5
%23 = add nsw i32 %21, %22
store i32 %23, i32* %9
store i32 0, i32* %7
br label %24
24: ; preds = %45, %3
%25 = load i32, i32* %7
%26 = load i32, i32* %9
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %48
28: ; preds = %24
%29 = call i32 (...) @rand()
%30 = sitofp i32 %29 to double
%31 = load i64, i64* @RAND_MAX
%32 = sitofp i64 %31 to double
%33 = fadd double %32, 1.000000e+00
%34 = fdiv double %30, %33
%35 = fmul double %34, 3.400000e+01
%36 = fptosi double %35 to i32
store i32 %36, i32* %8
%37 = load i32, i32* %8
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [35 x i8], [35 x i8]* @random_chars.allowable_chars, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = load i8*, i8** %4
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
store i8 %40, i8* %44
br label %45
45: ; preds = %28
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %24
48: ; preds = %24
%49 = load i8*, i8** %4
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
store i8 0, i8* %52
%53 = load i8*, i8** %4
ret i8* %53
}

LLVM IR (-O2):
@random_chars.allowable_chars = internal unnamed_addr constant [35 x i8] c"1234567890abcdefhijklnmopqrstuwxyz\00"
@RAND_MAX = global i64 0
define i8* @random_chars(i8* returned writeonly %0, i32 %1, i32 %2) {
%4 = tail call i64 @time(i32 0)
%5 = tail call i64 (...) @clock()
%6 = add nsw i64 %5, %4
%7 = tail call i64 (...) @random()
%8 = add nsw i64 %6, %7
%9 = tail call i32 @srandom(i64 %8)
%10 = tail call i32 (...) @rand()
%11 = sub i32 1, %1
%12 = add i32 %11, %2
%13 = srem i32 %10, %12
%14 = add i32 %13, %1
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %36
16: ; preds = %3
%17 = zext i32 %14 to i64
br label %18
18: ; preds = %16, %18
%19 = phi i64 [ 0, %16 ], [ %32, %18 ]
%20 = tail call i32 (...) @rand()
%21 = sitofp i32 %20 to double
%22 = load i64, i64* @RAND_MAX
%23 = sitofp i64 %22 to double
%24 = fadd double %23, 1.000000e+00
%25 = fdiv double %21, %24
%26 = fmul double %25, 3.400000e+01
%27 = fptosi double %26 to i32
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [35 x i8], [35 x i8]* @random_chars.allowable_chars, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = getelementptr inbounds i8, i8* %0, i64 %19
store i8 %30, i8* %31
%32 = add nuw nsw i64 %19, 1
%33 = icmp eq i64 %32, %17
br i1 %33, label %34, label %18
34: ; preds = %18
%35 = zext i32 %14 to i64
br label %36
36: ; preds = %3, %34
%37 = phi i64 [ %35, %34 ], [ 0, %3 ]
%38 = getelementptr inbounds i8, i8* %0, i64 %37
store i8 0, i8* %38
ret i8* %0
}