#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 powf(float, float);
size_t rand_range(int, size_t);
float rand_uniform(int /*<<< orphan*/, double);
size_t strlen(char const *);
char toupper(int);
void rand_name(char *name, size_t max) {
  const char *vowels = "aeiou";
  const char *consonants = "bcdfghjklmnpqrstvwxyz";
  int length = rand_range(6, max);
  int spaces = 0;
  int letters = 0;
  for (int i = 0; i < length; i++) {
    float spacep = letters / 3.0f * powf(0.1f, 1.0f / (10 * spaces + 1));
    if (i > 0 && rand_uniform(0, 1.0) < spacep) {
      name[i] = ' ';
      letters = 0;
    } else {
      if (i % 2)
        name[i] = consonants[rand_range(0, strlen(consonants))];
      else
        name[i] = vowels[rand_range(0, strlen(vowels))];
      if (letters == 0)
        name[i] = toupper((int)name[i]);
      letters++;
    }
  }
  name[length] = '\0';
}


x86 assembly (clang, -O0):
<rand_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb1(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xeac(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rsi
mov    $0x6,%edi
call   1070 <rand_range@plt>
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12f3 <rand_name+0x1a3>
cvtsi2ssl -0x2c(%rbp),%xmm0
movss  0xe53(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x38(%rbp)
imul   $0xa,-0x28(%rbp),%eax
add    $0x1,%eax
cvtsi2ss %eax,%xmm0
movss  0xe33(%rip),%xmm1
divss  %xmm0,%xmm1
movss  0xe23(%rip),%xmm0
call   1040 <powf@plt>
movss  -0x38(%rbp),%xmm0
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x34(%rbp)
cmpl   $0x0,-0x30(%rbp)
jle    1236 <rand_name+0xe6>
xor    %edi,%edi
movsd  0xe08(%rip),%xmm0
call   1060 <rand_uniform@plt>
movaps %xmm0,%xmm1
movss  -0x34(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1236 <rand_name+0xe6>
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
movl   $0x0,-0x2c(%rbp)
jmp    12e0 <rand_name+0x190>
mov    -0x30(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     127f <rand_name+0x12f>
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rsi
xor    %edi,%edi
call   1070 <rand_range@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    12af <rand_name+0x15f>
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rsi
xor    %edi,%edi
call   1070 <rand_range@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
cmpl   $0x0,-0x2c(%rbp)
jne    12d7 <rand_name+0x187>
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12e5 <rand_name+0x195>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    119c <rand_name+0x4c>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rand_name>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r13
mov    $0x6,%edi
call   1060 <rand_range@plt>
mov    %rax,%r14
test   %r14d,%r14d
jle    11a3 <rand_name+0x63>
mov    %r14d,%r15d
movss  0xe95(%rip),%xmm0
movss  0xe91(%rip),%xmm1
call   1040 <powf@plt>
mov    $0x5,%esi
xor    %edi,%edi
call   1060 <rand_range@plt>
lea    0xe8d(%rip),%r12
movsbl (%rax,%r12,1),%edi
mov    %dil,0x0(%r13)
call   1030 <toupper@plt>
mov    %al,0x0(%r13)
cmp    $0x1,%r15
jne    11bb <rand_name+0x7b>
movslq %r14d,%rax
movb   $0x0,0x0(%r13,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%ebp
mov    $0x1,%ebx
jmp    11e1 <rand_name+0xa1>
nopw   0x0(%rax,%rax,1)
movb   $0x20,0x0(%r13,%rbx,1)
xor    %ebp,%ebp
add    $0x1,%rbx
cmp    %rbx,%r15
je     11a3 <rand_name+0x63>
movss  0xe17(%rip),%xmm0
movss  0xe13(%rip),%xmm1
call   1040 <powf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
divss  0xe03(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
xor    %edi,%edi
movsd  0xdf0(%rip),%xmm0
call   1050 <rand_uniform@plt>
movss  0x4(%rsp),%xmm1
ucomiss %xmm0,%xmm1
ja     11d0 <rand_name+0x90>
test   $0x1,%bl
jne    1250 <rand_name+0x110>
mov    $0x5,%esi
xor    %edi,%edi
call   1060 <rand_range@plt>
add    %r12,%rax
jmp    1266 <rand_name+0x126>
cs nopw 0x0(%rax,%rax,1)
mov    $0x15,%esi
xor    %edi,%edi
call   1060 <rand_range@plt>
lea    0xdbb(%rip),%rcx
add    %rcx,%rax
movsbl (%rax),%edi
mov    %dil,0x0(%r13,%rbx,1)
test   %ebp,%ebp
jne    127c <rand_name+0x13c>
call   1030 <toupper@plt>
mov    %al,0x0(%r13,%rbx,1)
add    $0x1,%ebp
jmp    11d8 <rand_name+0x98>

LLVM IR (-O0):
@.str = [6 x i8] c"aeiou\00"
@.str.1 = [22 x i8] c"bcdfghjklmnpqrstvwxyz\00"
define void @rand_name(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca float
store i8* %0, i8** %3
store i64 %1, i64* %4
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %5
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8** %6
%12 = load i64, i64* %4
%13 = call i64 @rand_range(i32 6, i64 %12)
%14 = trunc i64 %13 to i32
store i32 %14, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
br label %15
15: ; preds = %87, %2
%16 = load i32, i32* %10
%17 = load i32, i32* %7
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %90
19: ; preds = %15
%20 = load i32, i32* %9
%21 = sitofp i32 %20 to float
%22 = fdiv float %21, 3.000000e+00
%23 = load i32, i32* %8
%24 = mul nsw i32 10, %23
%25 = add nsw i32 %24, 1
%26 = sitofp i32 %25 to float
%27 = fdiv float 1.000000e+00, %26
%28 = call i32 @powf(float 0x3FB99999A0000000, float %27)
%29 = sitofp i32 %28 to float
%30 = fmul float %22, %29
store float %30, float* %11
%31 = load i32, i32* %10
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %42
33: ; preds = %19
%34 = call float @rand_uniform(i32 0, double 1.000000e+00)
%35 = load float, float* %11
%36 = fcmp olt float %34, %35
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = load i8*, i8** %3
%39 = load i32, i32* %10
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
store i8 32, i8* %41
store i32 0, i32* %9
br label %86
42: ; preds = %33, %19
%43 = load i32, i32* %10
%44 = srem i32 %43, 2
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %57
46: ; preds = %42
%47 = load i8*, i8** %6
%48 = load i8*, i8** %6
%49 = call i64 @strlen(i8* %48)
%50 = call i64 @rand_range(i32 0, i64 %49)
%51 = getelementptr inbounds i8, i8* %47, i64 %50
%52 = load i8, i8* %51
%53 = load i8*, i8** %3
%54 = load i32, i32* %10
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
store i8 %52, i8* %56
br label %68
57: ; preds = %42
%58 = load i8*, i8** %5
%59 = load i8*, i8** %5
%60 = call i64 @strlen(i8* %59)
%61 = call i64 @rand_range(i32 0, i64 %60)
%62 = getelementptr inbounds i8, i8* %58, i64 %61
%63 = load i8, i8* %62
%64 = load i8*, i8** %3
%65 = load i32, i32* %10
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %64, i64 %66
store i8 %63, i8* %67
br label %68
68: ; preds = %57, %46
%69 = load i32, i32* %9
%70 = icmp eq i32 %69, 0
br i1 %70, label %71, label %83
71: ; preds = %68
%72 = load i8*, i8** %3
%73 = load i32, i32* %10
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8, i8* %72, i64 %74
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = call signext i8 @toupper(i32 %77)
%79 = load i8*, i8** %3
%80 = load i32, i32* %10
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8, i8* %79, i64 %81
store i8 %78, i8* %82
br label %83
83: ; preds = %71, %68
%84 = load i32, i32* %9
%85 = add nsw i32 %84, 1
store i32 %85, i32* %9
br label %86
86: ; preds = %83, %37
br label %87
87: ; preds = %86
%88 = load i32, i32* %10
%89 = add nsw i32 %88, 1
store i32 %89, i32* %10
br label %15
90: ; preds = %15
%91 = load i8*, i8** %3
%92 = load i32, i32* %7
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i8, i8* %91, i64 %93
store i8 0, i8* %94
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"aeiou\00"
@.str.1 = [22 x i8] c"bcdfghjklmnpqrstvwxyz\00"
define void @rand_name(i8* nocapture %0, i64 %1) {
%3 = tail call i64 @rand_range(i32 6, i64 %1)
%4 = trunc i64 %3 to i32
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %2
%7 = and i64 %3, 4294967295
%8 = tail call i32 @powf(float 0x3FB99999A0000000, float 1.000000e+00)
%9 = tail call i64 @rand_range(i32 0, i64 5)
%10 = getelementptr inbounds [6 x i8], [6 x i8]* @.str, i64 0, i64 %9
%11 = load i8, i8* %10
store i8 %11, i8* %0
%12 = sext i8 %11 to i32
%13 = tail call signext i8 @toupper(i32 %12)
store i8 %13, i8* %0
%14 = icmp eq i64 %7, 1
br i1 %14, label %15, label %19
15: ; preds = %51, %6, %2
%16 = shl i64 %3, 32
%17 = ashr exact i64 %16, 32
%18 = getelementptr inbounds i8, i8* %0, i64 %17
store i8 0, i8* %18
ret void
19: ; preds = %6, %51
%20 = phi i64 [ %53, %51 ], [ 1, %6 ]
%21 = phi i32 [ %52, %51 ], [ 1, %6 ]
%22 = tail call i32 @powf(float 0x3FB99999A0000000, float 1.000000e+00)
%23 = sitofp i32 %21 to float
%24 = fdiv float %23, 3.000000e+00
%25 = sitofp i32 %22 to float
%26 = fmul float %24, %25
%27 = tail call float @rand_uniform(i32 0, double 1.000000e+00)
%28 = fcmp olt float %27, %26
br i1 %28, label %29, label %31
29: ; preds = %19
%30 = getelementptr inbounds i8, i8* %0, i64 %20
store i8 32, i8* %30
br label %51
31: ; preds = %19
%32 = and i64 %20, 1
%33 = icmp eq i64 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = tail call i64 @rand_range(i32 0, i64 21)
%36 = getelementptr inbounds [22 x i8], [22 x i8]* @.str.1, i64 0, i64 %35
br label %40
37: ; preds = %31
%38 = tail call i64 @rand_range(i32 0, i64 5)
%39 = getelementptr inbounds [6 x i8], [6 x i8]* @.str, i64 0, i64 %38
br label %40
40: ; preds = %37, %34
%41 = phi i8* [ %39, %37 ], [ %36, %34 ]
%42 = load i8, i8* %41
%43 = getelementptr inbounds i8, i8* %0, i64 %20
store i8 %42, i8* %43
%44 = icmp eq i32 %21, 0
br i1 %44, label %45, label %49
45: ; preds = %40
%46 = getelementptr inbounds i8, i8* %0, i64 %20
%47 = sext i8 %42 to i32
%48 = tail call signext i8 @toupper(i32 %47)
store i8 %48, i8* %46
br label %49
49: ; preds = %45, %40
%50 = add nsw i32 %21, 1
br label %51
51: ; preds = %49, %29
%52 = phi i32 [ 0, %29 ], [ %50, %49 ]
%53 = add nuw nsw i64 %20, 1
%54 = icmp eq i64 %53, %7
br i1 %54, label %15, label %19
}