#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 get_filename(char name[]) {
  int i;
  long int rnd = random();
  for (i = 0; i < 4; ++i) {
    int index = rnd % 32;
    rnd /= 32;
    if (index < 26)
      name[i] = index + 'a';
    else
      name[i] = index + '0';
  }
  name[4] = 0;
}


x86 assembly (clang, -O0):
<get_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <random@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    11a5 <get_filename+0x95>
mov    -0x18(%rbp),%rax
mov    $0x20,%ecx
cqto
idiv   %rcx
mov    %edx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    $0x20,%ecx
cqto
idiv   %rcx
mov    %rax,-0x18(%rbp)
cmpl   $0x1a,-0x1c(%rbp)
jge    117f <get_filename+0x6f>
mov    -0x1c(%rbp),%eax
add    $0x61,%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1192 <get_filename+0x82>
mov    -0x1c(%rbp),%eax
add    $0x30,%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1197 <get_filename+0x87>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112e <get_filename+0x1e>
mov    -0x8(%rbp),%rax
movb   $0x0,0x4(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_filename>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <random@plt>
lea    0x7fff(%rax),%rcx
test   %rax,%rax
cmovns %rax,%rcx
lea    0x3ff(%rax),%rdx
test   %rax,%rax
cmovns %rax,%rdx
lea    0x1f(%rax),%rdi
test   %rax,%rax
cmovns %rax,%rdi
mov    %rdi,%rsi
and    $0xffffffffffffffe0,%rsi
sub    %rsi,%rax
sar    $0x5,%rdi
cmp    $0x1a,%eax
mov    $0x61,%r8d
mov    $0x30,%esi
cmovl  %r8d,%esi
add    %al,%sil
lea    0x1f(%rdi),%rbx
test   %rdi,%rdi
cmovns %rdi,%rbx
mov    $0x30,%eax
and    $0xffffffffffffffe0,%rbx
sub    %rbx,%rdi
sar    $0xa,%rdx
cmp    $0x1a,%edi
mov    $0x30,%ebx
cmovl  %r8d,%ebx
mov    %sil,(%r14)
add    %bl,%dil
mov    %dil,0x1(%r14)
lea    0x1f(%rdx),%rsi
test   %rdx,%rdx
cmovns %rdx,%rsi
and    $0xffffffffffffffe0,%rsi
sub    %rsi,%rdx
sar    $0xf,%rcx
cmp    $0x1a,%edx
mov    $0x30,%esi
cmovl  %r8d,%esi
add    %sil,%dl
lea    0x1f(%rcx),%rsi
test   %rcx,%rcx
cmovns %rcx,%rsi
and    $0xffffffffffffffe0,%rsi
sub    %rsi,%rcx
cmp    $0x1a,%ecx
cmovl  %r8d,%eax
mov    %dl,0x2(%r14)
add    %al,%cl
mov    %cl,0x3(%r14)
movb   $0x0,0x4(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @get_filename(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i64
%5 = alloca i32
store i8* %0, i8** %2
%6 = call i64 (...) @random()
store i64 %6, i64* %4
store i32 0, i32* %3
br label %7
7: ; preds = %35, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %38
10: ; preds = %7
%11 = load i64, i64* %4
%12 = srem i64 %11, 32
%13 = trunc i64 %12 to i32
store i32 %13, i32* %5
%14 = load i64, i64* %4
%15 = sdiv i64 %14, 32
store i64 %15, i64* %4
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 26
br i1 %17, label %18, label %26
18: ; preds = %10
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 97
%21 = trunc i32 %20 to i8
%22 = load i8*, i8** %2
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8 %21, i8* %25
br label %34
26: ; preds = %10
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 48
%29 = trunc i32 %28 to i8
%30 = load i8*, i8** %2
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
store i8 %29, i8* %33
br label %34
34: ; preds = %26, %18
br label %35
35: ; preds = %34
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
store i32 %37, i32* %3
br label %7
38: ; preds = %7
%39 = load i8*, i8** %2
%40 = getelementptr inbounds i8, i8* %39, i64 4
store i8 0, i8* %40
ret void
}

LLVM IR (-O2):
define void @get_filename(i8* nocapture writeonly %0) {
%2 = tail call i64 (...) @random()
%3 = srem i64 %2, 32
%4 = trunc i64 %3 to i32
%5 = sdiv i64 %2, 32
%6 = icmp slt i32 %4, 26
%7 = trunc i64 %3 to i8
%8 = select i1 %6, i8 97, i8 48
%9 = add i8 %8, %7
store i8 %9, i8* %0
%10 = srem i64 %5, 32
%11 = trunc i64 %10 to i32
%12 = sdiv i64 %2, 1024
%13 = icmp slt i32 %11, 26
%14 = select i1 %13, i8 97, i8 48
%15 = trunc i64 %10 to i8
%16 = add i8 %14, %15
%17 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %16, i8* %17
%18 = srem i64 %12, 32
%19 = trunc i64 %18 to i32
%20 = sdiv i64 %2, 32768
%21 = icmp slt i32 %19, 26
%22 = select i1 %21, i8 97, i8 48
%23 = trunc i64 %18 to i8
%24 = add i8 %22, %23
%25 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %24, i8* %25
%26 = srem i64 %20, 32
%27 = trunc i64 %26 to i32
%28 = icmp slt i32 %27, 26
%29 = select i1 %28, i8 97, i8 48
%30 = trunc i64 %26 to i8
%31 = add i8 %29, %30
%32 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %31, i8* %32
%33 = getelementptr inbounds i8, i8* %0, i64 4
store i8 0, i8* %33
ret void
}