#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 random();
void randomString(char *buf) {
  char *choices = "abcd efgh ijkl mnop qrst uvw xyz";
  int i, n;
  n = random() % 49;
  for (i = 0; i < n; i++)
    *buf++ = choices[random() % 32];
  *buf = '\0';
}


x86 assembly (clang, -O0):
<randomString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xedd(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <random@plt>
mov    $0x31,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    118c <randomString+0x7c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <random@plt>
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    -0x20(%rbp),%rax
movslq %edx,%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1140 <randomString+0x30>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randomString>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <random@plt>
movslq %eax,%rbx
imul   $0x5397829d,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x24,%rax
add    %ecx,%eax
imul   $0x31,%eax,%eax
sub    %eax,%ebx
test   %ebx,%ebx
jle    1177 <randomString+0x67>
lea    0xeba(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <random@plt>
lea    0x1f(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffffe0,%ecx
sub    %ecx,%eax
cltq
movzbl (%rax,%r15,1),%eax
mov    %al,(%r14)
add    $0x1,%r14
add    $0xffffffff,%ebx
jne    1150 <randomString+0x40>
movb   $0x0,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [33 x i8] c"abcd efgh ijkl mnop qrst uvw xyz\00"
define void @randomString(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
store i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8** %3
%6 = call i32 (...) @random()
%7 = srem i32 %6, 49
store i32 %7, i32* %5
store i32 0, i32* %4
br label %8
8: ; preds = %21, %1
%9 = load i32, i32* %4
%10 = load i32, i32* %5
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %24
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = call i32 (...) @random()
%15 = srem i32 %14, 32
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %13, i64 %16
%18 = load i8, i8* %17
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %2
store i8 %18, i8* %19
br label %21
21: ; preds = %12
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %8
24: ; preds = %8
%25 = load i8*, i8** %2
store i8 0, i8* %25
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"abcd efgh ijkl mnop qrst uvw xyz\00"
define void @randomString(i8* nocapture writeonly %0) {
%2 = tail call i32 (...) @random()
%3 = srem i32 %2, 49
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %16
5: ; preds = %1, %5
%6 = phi i8* [ %13, %5 ], [ %0, %1 ]
%7 = phi i32 [ %14, %5 ], [ 0, %1 ]
%8 = tail call i32 (...) @random()
%9 = srem i32 %8, 32
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [33 x i8], [33 x i8]* @.str, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %12, i8* %6
%14 = add nuw nsw i32 %7, 1
%15 = icmp eq i32 %14, %3
br i1 %15, label %16, label %5
16: ; preds = %5, %1
%17 = phi i8* [ %0, %1 ], [ %13, %5 ]
store i8 0, i8* %17
ret void
}