#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 /*<<< orphan*/ f_getrandom(char *, size_t, int /*<<< orphan*/);
void random_name(char *buf, size_t len) {
  f_getrandom(buf, len, 0);
  for (size_t i = 0; i < len; i++)
    buf[i] = (unsigned char)buf[i] % 26 + 'a';
}


x86 assembly (clang, -O0):
<random_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1030 <f_getrandom@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1178 <random_name+0x68>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x61,%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1137 <random_name+0x27>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_name>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edx,%edx
call   1030 <f_getrandom@plt>
test   %r14,%r14
je     13d4 <random_name+0x2c4>
cmp    $0x8,%r14
jae    1137 <random_name+0x27>
xor    %eax,%eax
jmp    13b0 <random_name+0x2a0>
cmp    $0x10,%r14
jae    11d7 <random_name+0xc7>
xor    %eax,%eax
mov    %rax,%rcx
mov    %r14,%rax
and    $0xfffffffffffffff8,%rax
pxor   %xmm0,%xmm0
movdqa 0xea7(%rip),%xmm1
movdqa 0xeaf(%rip),%xmm2
movdqa 0xeb7(%rip),%xmm3
movdqa 0xebf(%rip),%xmm4
movdqa 0xed7(%rip),%xmm5
nopl   0x0(%rax)
movq   (%rbx,%rcx,1),%xmm6
movdqa %xmm6,%xmm7
punpcklbw %xmm0,%xmm7
pmullw %xmm1,%xmm7
psrlw  $0x8,%xmm7
packuswb %xmm7,%xmm7
psrlw  $0x3,%xmm7
pand   %xmm2,%xmm7
punpcklbw %xmm7,%xmm7
pmullw %xmm3,%xmm7
pand   %xmm4,%xmm7
packuswb %xmm7,%xmm7
psubb  %xmm7,%xmm6
paddb  %xmm5,%xmm6
movq   %xmm6,(%rbx,%rcx,1)
add    $0x8,%rcx
cmp    %rcx,%rax
jne    1180 <random_name+0x70>
cmp    %r14,%rax
jne    13b0 <random_name+0x2a0>
jmp    13d4 <random_name+0x2c4>
mov    %r14,%rax
and    $0xfffffffffffffff0,%rax
lea    -0x10(%rax),%rcx
mov    %rcx,%rdx
shr    $0x4,%rdx
add    $0x1,%rdx
test   %rcx,%rcx
je     13dc <random_name+0x2cc>
mov    %rdx,%rsi
and    $0xfffffffffffffffe,%rsi
xor    %ecx,%ecx
pxor   %xmm0,%xmm0
movdqa 0xdf5(%rip),%xmm1
movdqa 0xdfc(%rip),%xmm8
movdqa 0xe04(%rip),%xmm3
movdqa 0xe0c(%rip),%xmm4
movdqa 0xe13(%rip),%xmm9
nopl   (%rax)
movdqu (%rbx,%rcx,1),%xmm5
movdqu 0x10(%rbx,%rcx,1),%xmm6
movdqa %xmm5,%xmm7
punpckhbw %xmm0,%xmm7
pmullw %xmm1,%xmm7
psrlw  $0x8,%xmm7
movdqa %xmm5,%xmm2
punpcklbw %xmm0,%xmm2
pmullw %xmm1,%xmm2
psrlw  $0x8,%xmm2
packuswb %xmm7,%xmm2
psrlw  $0x3,%xmm2
pand   %xmm8,%xmm2
movdqa %xmm2,%xmm7
punpckhbw %xmm7,%xmm7
pmullw %xmm3,%xmm7
pand   %xmm4,%xmm7
punpcklbw %xmm2,%xmm2
pmullw %xmm3,%xmm2
pand   %xmm4,%xmm2
packuswb %xmm7,%xmm2
psubb  %xmm2,%xmm5
paddb  %xmm9,%xmm5
movdqu %xmm5,(%rbx,%rcx,1)
movdqa %xmm6,%xmm2
punpckhbw %xmm0,%xmm2
pmullw %xmm1,%xmm2
psrlw  $0x8,%xmm2
movdqa %xmm6,%xmm5
punpcklbw %xmm0,%xmm5
pmullw %xmm1,%xmm5
psrlw  $0x8,%xmm5
packuswb %xmm2,%xmm5
psrlw  $0x3,%xmm5
pand   %xmm8,%xmm5
movdqa %xmm5,%xmm2
punpckhbw %xmm2,%xmm2
pmullw %xmm3,%xmm2
pand   %xmm4,%xmm2
punpcklbw %xmm5,%xmm5
pmullw %xmm3,%xmm5
pand   %xmm4,%xmm5
packuswb %xmm2,%xmm5
psubb  %xmm5,%xmm6
paddb  %xmm9,%xmm6
movdqu %xmm6,0x10(%rbx,%rcx,1)
add    $0x20,%rcx
add    $0xfffffffffffffffe,%rsi
jne    1230 <random_name+0x120>
test   $0x1,%dl
je     1394 <random_name+0x284>
movdqu (%rbx,%rcx,1),%xmm0
pxor   %xmm1,%xmm1
movdqa %xmm0,%xmm2
punpckhbw %xmm1,%xmm2
movdqa 0xcd8(%rip),%xmm3
pmullw %xmm3,%xmm2
psrlw  $0x8,%xmm2
movdqa %xmm0,%xmm4
punpcklbw %xmm1,%xmm4
pmullw %xmm3,%xmm4
psrlw  $0x8,%xmm4
packuswb %xmm2,%xmm4
psrlw  $0x3,%xmm4
pand   0xcbd(%rip),%xmm4
movdqa %xmm4,%xmm1
punpckhbw %xmm1,%xmm1
movdqa 0xcbd(%rip),%xmm2
pmullw %xmm2,%xmm1
movdqa 0xcc1(%rip),%xmm3
pand   %xmm3,%xmm1
punpcklbw %xmm4,%xmm4
pmullw %xmm2,%xmm4
pand   %xmm3,%xmm4
packuswb %xmm1,%xmm4
psubb  %xmm4,%xmm0
paddb  0xcb1(%rip),%xmm0
movdqu %xmm0,(%rbx,%rcx,1)
cmp    %r14,%rax
je     13d4 <random_name+0x2c4>
test   $0x8,%r14b
jne    1143 <random_name+0x33>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rbx,%rax,1),%ecx
imul   $0x4f,%ecx,%edx
shr    $0xb,%edx
lea    (%rdx,%rdx,4),%esi
lea    (%rsi,%rsi,4),%esi
add    %edx,%esi
sub    %sil,%cl
add    $0x61,%cl
mov    %cl,(%rbx,%rax,1)
add    $0x1,%rax
cmp    %rax,%r14
jne    13b0 <random_name+0x2a0>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %ecx,%ecx
test   $0x1,%dl
jne    130f <random_name+0x1ff>
jmp    1394 <random_name+0x284>

LLVM IR (-O0):
define void @random_name(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%6 = load i8*, i8** %3
%7 = load i64, i64* %4
%8 = call i32 @f_getrandom(i8* %6, i64 %7, i32 0)
store i64 0, i64* %5
br label %9
9: ; preds = %25, %2
%10 = load i64, i64* %5
%11 = load i64, i64* %4
%12 = icmp ult i64 %10, %11
br i1 %12, label %13, label %28
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = load i64, i64* %5
%16 = getelementptr inbounds i8, i8* %14, i64 %15
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = srem i32 %18, 26
%20 = add nsw i32 %19, 97
%21 = trunc i32 %20 to i8
%22 = load i8*, i8** %3
%23 = load i64, i64* %5
%24 = getelementptr inbounds i8, i8* %22, i64 %23
store i8 %21, i8* %24
br label %25
25: ; preds = %13
%26 = load i64, i64* %5
%27 = add i64 %26, 1
store i64 %27, i64* %5
br label %9
28: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @random_name(i8* %0, i64 %1) {
%3 = tail call i32 @f_getrandom(i8* %0, i64 %1, i32 0)
%4 = icmp eq i64 %1, 0
br i1 %4, label %69, label %5
5: ; preds = %2
%6 = icmp ult i64 %1, 8
br i1 %6, label %67, label %7
7: ; preds = %5
%8 = icmp ult i64 %1, 16
br i1 %8, label %52, label %9
9: ; preds = %7
%10 = and i64 %1, -16
%11 = add i64 %10, -16
%12 = lshr exact i64 %11, 4
%13 = add nuw nsw i64 %12, 1
%14 = and i64 %13, 1
%15 = icmp eq i64 %11, 0
br i1 %15, label %37, label %16
16: ; preds = %9
%17 = and i64 %13, 2305843009213693950
br label %18
18: ; preds = %18, %16
%19 = phi i64 [ 0, %16 ], [ %34, %18 ]
%20 = phi i64 [ 0, %16 ], [ %35, %18 ]
%21 = getelementptr inbounds i8, i8* %0, i64 %19
%22 = bitcast i8* %21 to <16 x i8>*
%23 = load <16 x i8>, <16 x i8>* %22
%24 = urem <16 x i8> %23, <i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26>
%25 = add nuw nsw <16 x i8> %24, <i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97>
%26 = bitcast i8* %21 to <16 x i8>*
store <16 x i8> %25, <16 x i8>* %26
%27 = or i64 %19, 16
%28 = getelementptr inbounds i8, i8* %0, i64 %27
%29 = bitcast i8* %28 to <16 x i8>*
%30 = load <16 x i8>, <16 x i8>* %29
%31 = urem <16 x i8> %30, <i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26>
%32 = add nuw nsw <16 x i8> %31, <i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97>
%33 = bitcast i8* %28 to <16 x i8>*
store <16 x i8> %32, <16 x i8>* %33
%34 = add nuw i64 %19, 32
%35 = add i64 %20, 2
%36 = icmp eq i64 %35, %17
br i1 %36, label %37, label %18
37: ; preds = %18, %9
%38 = phi i64 [ 0, %9 ], [ %34, %18 ]
%39 = icmp eq i64 %14, 0
br i1 %39, label %47, label %40
40: ; preds = %37
%41 = getelementptr inbounds i8, i8* %0, i64 %38
%42 = bitcast i8* %41 to <16 x i8>*
%43 = load <16 x i8>, <16 x i8>* %42
%44 = urem <16 x i8> %43, <i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26>
%45 = add nuw nsw <16 x i8> %44, <i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97>
%46 = bitcast i8* %41 to <16 x i8>*
store <16 x i8> %45, <16 x i8>* %46
br label %47
47: ; preds = %37, %40
%48 = icmp eq i64 %10, %1
br i1 %48, label %69, label %49
49: ; preds = %47
%50 = and i64 %1, 8
%51 = icmp eq i64 %50, 0
br i1 %51, label %67, label %52
52: ; preds = %7, %49
%53 = phi i64 [ %10, %49 ], [ 0, %7 ]
%54 = and i64 %1, -8
br label %55
55: ; preds = %55, %52
%56 = phi i64 [ %53, %52 ], [ %63, %55 ]
%57 = getelementptr inbounds i8, i8* %0, i64 %56
%58 = bitcast i8* %57 to <8 x i8>*
%59 = load <8 x i8>, <8 x i8>* %58
%60 = urem <8 x i8> %59, <i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26, i8 26>
%61 = add nuw nsw <8 x i8> %60, <i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97, i8 97>
%62 = bitcast i8* %57 to <8 x i8>*
store <8 x i8> %61, <8 x i8>* %62
%63 = add nuw i64 %56, 8
%64 = icmp eq i64 %63, %54
br i1 %64, label %65, label %55
65: ; preds = %55
%66 = icmp eq i64 %54, %1
br i1 %66, label %69, label %67
67: ; preds = %5, %49, %65
%68 = phi i64 [ 0, %5 ], [ %10, %49 ], [ %54, %65 ]
br label %70
69: ; preds = %70, %47, %65, %2
ret void
70: ; preds = %67, %70
%71 = phi i64 [ %76, %70 ], [ %68, %67 ]
%72 = getelementptr inbounds i8, i8* %0, i64 %71
%73 = load i8, i8* %72
%74 = urem i8 %73, 26
%75 = add nuw nsw i8 %74, 97
store i8 %75, i8* %72
%76 = add nuw i64 %71, 1
%77 = icmp eq i64 %76, %1
br i1 %77, label %69, label %70
}