#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();
char *strdup(char *);
char *rand_name() {
  char fname[20];
  int i;
  for (i = 0; i < 20; i++) {
    if (i != 16) {
      fname[i] = 'A' + (rand() % 26);
    } else {
      fname[i] = '.';
    }
  }
  fname[i] = '\0';
  return (strdup(fname));
}


x86 assembly (clang, -O0):
<rand_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x24(%rbp)
cmpl   $0x14,-0x24(%rbp)
jge    1180 <rand_name+0x60>
cmpl   $0x10,-0x24(%rbp)
je     1164 <rand_name+0x44>
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x41,%edx
mov    %dl,%cl
movslq -0x24(%rbp),%rax
mov    %cl,-0x20(%rbp,%rax,1)
jmp    116d <rand_name+0x4d>
movslq -0x24(%rbp),%rax
movb   $0x2e,-0x20(%rbp,%rax,1)
jmp    1172 <rand_name+0x52>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    112f <rand_name+0xf>
movslq -0x24(%rbp),%rax
movb   $0x0,-0x20(%rbp,%rax,1)
lea    -0x20(%rbp),%rdi
call   1030 <strdup@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rand_name>:
push   %rbx
sub    $0x20,%rsp
mov    $0xffffffffffffffec,%rbx
jmp    113a <rand_name+0x1a>
xchg   %ax,%ax
movb   $0x2e,0x10(%rsp)
inc    %rbx
je     1172 <rand_name+0x52>
cmp    $0xfffffffffffffffc,%rbx
je     1130 <rand_name+0x10>
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,0x14(%rsp,%rbx,1)
inc    %rbx
jne    113a <rand_name+0x1a>
movb   $0x0,0x14(%rsp)
mov    %rsp,%rdi
call   1030 <strdup@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i8* @rand_name() {
%1 = alloca [20 x i8]
%2 = alloca i32
store i32 0, i32* %2
br label %3
3: ; preds = %22, %0
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 20
br i1 %5, label %6, label %25
6: ; preds = %3
%7 = load i32, i32* %2
%8 = icmp ne i32 %7, 16
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 26
%12 = add nsw i32 65, %11
%13 = trunc i32 %12 to i8
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %15
store i8 %13, i8* %16
br label %21
17: ; preds = %6
%18 = load i32, i32* %2
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %19
store i8 46, i8* %20
br label %21
21: ; preds = %17, %9
br label %22
22: ; preds = %21
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
br label %3
25: ; preds = %3
%26 = load i32, i32* %2
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %27
store i8 0, i8* %28
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%30 = call i8* @strdup(i8* %29)
ret i8* %30
}

LLVM IR (-O2):
define noalias i8* @rand_name() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 16
br label %4
4: ; preds = %0, %14
%5 = phi i64 [ 0, %0 ], [ %15, %14 ]
%6 = icmp eq i64 %5, 16
br i1 %6, label %13, label %7
7: ; preds = %4
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 26
%10 = trunc i32 %9 to i8
%11 = add nsw i8 %10, 65
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %5
store i8 %11, i8* %12
br label %14
13: ; preds = %4
store i8 46, i8* %3
br label %14
14: ; preds = %7, %13
%15 = add nuw nsw i64 %5, 1
%16 = icmp eq i64 %15, 20
br i1 %16, label %17, label %4
17: ; preds = %14
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 20
store i8 0, i8* %18
%19 = call i8* @strdup(i8* %2)
ret i8* %19
}