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

/* Variables and functions */
char *malloc(int);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *buff_name(size_t size) {
  static char charset[] =
      "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  char *_buff_name = malloc(sizeof(char) * (size + 1));
  if (_buff_name) {
    int i, key;
    srand(time(NULL));
    _buff_name[0] = '.';
    for (i = 1; i < size; i++) {
      key = rand() % (int)(sizeof(charset) - 1);
      _buff_name[i] = charset[key];
    }
    _buff_name[size] = '\0';
  }
  return _buff_name;
}


x86 assembly (clang, -O0):
<buff_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11df <buff_name+0x9f>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
mov    -0x10(%rbp),%rax
movb   $0x2e,(%rax)
movl   $0x1,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    11d3 <buff_name+0x93>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x3e,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
movslq -0x18(%rbp),%rcx
lea    0x2e99(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118c <buff_name+0x4c>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buff_name>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
add    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
test   %rax,%rax
je     11c7 <buff_name+0x87>
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movb   $0x2e,(%r15)
cmp    $0x2,%r14
jb     11c2 <buff_name+0x82>
mov    $0x1,%ebx
lea    0xe81(%rip),%r12
nop
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0xffffffff84210843,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x5,%ecx
add    %edx,%ecx
mov    %ecx,%edx
shl    $0x6,%edx
mov    %ecx,%esi
sub    %edx,%esi
add    %ecx,%esi
add    %eax,%esi
movslq %esi,%rax
movzbl (%rax,%r12,1),%eax
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1180 <buff_name+0x40>
movb   $0x0,(%r15,%r14,1)
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@buff_name.charset = internal global [63 x i8] c"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\00"
define i8* @buff_name(i64 %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i64 %0, i64* %2
%6 = load i64, i64* %2
%7 = add i64 %6, 1
%8 = mul i64 1, %7
%9 = trunc i64 %8 to i32
%10 = call i8* @malloc(i32 %9)
store i8* %10, i8** %3
%11 = load i8*, i8** %3
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %41
13: ; preds = %1
%14 = call i32 @time(i32* null)
%15 = call i32 @srand(i32 %14)
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 0
store i8 46, i8* %17
store i32 1, i32* %4
br label %18
18: ; preds = %34, %13
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = load i64, i64* %2
%22 = icmp ult i64 %20, %21
br i1 %22, label %23, label %37
23: ; preds = %18
%24 = call i32 (...) @rand()
%25 = srem i32 %24, 62
store i32 %25, i32* %5
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [63 x i8], [63 x i8]* @buff_name.charset, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = load i8*, i8** %3
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
store i8 %29, i8* %33
br label %34
34: ; preds = %23
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %18
37: ; preds = %18
%38 = load i8*, i8** %3
%39 = load i64, i64* %2
%40 = getelementptr inbounds i8, i8* %38, i64 %39
store i8 0, i8* %40
br label %41
41: ; preds = %37, %1
%42 = load i8*, i8** %3
ret i8* %42
}

LLVM IR (-O2):
@buff_name.charset = internal unnamed_addr constant [63 x i8] c"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\00"
define noalias i8* @buff_name(i64 %0) {
%2 = trunc i64 %0 to i32
%3 = add i32 %2, 1
%4 = tail call i8* @malloc(i32 %3)
%5 = icmp eq i8* %4, null
br i1 %5, label %22, label %6
6: ; preds = %1
%7 = tail call i32 @time(i32* null)
%8 = tail call i32 @srand(i32 %7)
store i8 46, i8* %4
%9 = icmp ugt i64 %0, 1
br i1 %9, label %10, label %20
10: ; preds = %6, %10
%11 = phi i64 [ %18, %10 ], [ 1, %6 ]
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, 62
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [63 x i8], [63 x i8]* @buff_name.charset, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = getelementptr inbounds i8, i8* %4, i64 %11
store i8 %16, i8* %17
%18 = add nuw i64 %11, 1
%19 = icmp eq i64 %18, %0
br i1 %19, label %20, label %10
20: ; preds = %10, %6
%21 = getelementptr inbounds i8, i8* %4, i64 %0
store i8 0, i8* %21
br label %22
22: ; preds = %20, %1
ret i8* %4
}