#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 get_rnd(int);
void gen_city_name(char *name) {
  int length = 6 + get_rnd(32 - 6);
  name[0] = (char)(65 + get_rnd(25));
  for (int i = 1; i < length; i++) {
    name[i] = (char)(97 + get_rnd(25));
  }
  name[length + 1] = '\0';
}


x86 assembly (clang, -O0):
<gen_city_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x1a,%edi
call   1030 <get_rnd@plt>
add    $0x6,%eax
mov    %eax,-0xc(%rbp)
mov    $0x19,%edi
call   1030 <get_rnd@plt>
add    $0x41,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    117c <gen_city_name+0x6c>
mov    $0x19,%edi
call   1030 <get_rnd@plt>
add    $0x61,%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1148 <gen_city_name+0x38>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_city_name>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
mov    $0x1a,%edi
call   1030 <get_rnd@plt>
mov    %eax,%r14d
mov    $0x19,%edi
call   1030 <get_rnd@plt>
add    $0x41,%al
mov    %al,(%r15)
cmp    $0xfffffffc,%r14d
jl     116a <gen_city_name+0x5a>
lea    0x5(%r14),%eax
cmp    $0x2,%eax
mov    $0x1,%r12d
cmovge %eax,%r12d
xor    %ebx,%ebx
mov    $0x19,%edi
call   1030 <get_rnd@plt>
add    $0x61,%al
mov    %al,0x1(%r15,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1150 <gen_city_name+0x40>
movslq %r14d,%rax
movb   $0x0,0x7(%rax,%r15,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @gen_city_name(i8* nocapture writeonly %0) {
%2 = tail call i32 @get_rnd(i32 26)
%3 = tail call i32 @get_rnd(i32 25)
%4 = trunc i32 %3 to i8
%5 = add i8 %4, 65
store i8 %5, i8* %0
%6 = icmp sgt i32 %2, -5
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = add i32 %2, 5
%9 = call i32 @llvm.smax.i32(i32 %8, i32 1)
%10 = add nuw i32 %9, 1
%11 = zext i32 %10 to i64
br label %16
12: ; preds = %16, %1
%13 = add nsw i32 %2, 7
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
store i8 0, i8* %15
ret void
16: ; preds = %7, %16
%17 = phi i64 [ 1, %7 ], [ %22, %16 ]
%18 = tail call i32 @get_rnd(i32 25)
%19 = trunc i32 %18 to i8
%20 = add i8 %19, 97
%21 = getelementptr inbounds i8, i8* %0, i64 %17
store i8 %20, i8* %21
%22 = add nuw nsw i64 %17, 1
%23 = icmp eq i64 %22, %11
br i1 %23, label %12, label %16
}