#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 */
char *alloc_string(char *);
int rand();
int strlen(char *);
char *rand_password(void) {
  char pwdchars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  char password[17];
  int charslen = strlen(pwdchars);
  for (int loop = 0; loop < 16; loop++) {
    password[loop] = pwdchars[(rand() >> 8) % charslen];
  }
  password[16] = 0;
  return alloc_string(password);
}


x86 assembly (clang, -O0):
<rand_password>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    -0x40(%rbp),%rdi
lea    0xead(%rip),%rsi
mov    $0x35,%edx
call   1040 <memcpy@plt>
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x64(%rbp)
movl   $0x0,-0x68(%rbp)
cmpl   $0x10,-0x68(%rbp)
jge    11a5 <rand_password+0x65>
mov    $0x0,%al
call   1060 <rand@plt>
sar    $0x8,%eax
cltd
idivl  -0x64(%rbp)
movslq %edx,%rax
mov    -0x40(%rbp,%rax,1),%cl
movslq -0x68(%rbp),%rax
mov    %cl,-0x60(%rbp,%rax,1)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1170 <rand_password+0x30>
movb   $0x0,-0x50(%rbp)
lea    -0x60(%rbp),%rdi
call   1050 <alloc_string@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rand_password>:
push   %rbp
push   %rbx
sub    $0x58,%rsp
movaps 0xee3(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xec7(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeab(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movabs $0x5a595857565554,%rax
mov    %rax,0x4d(%rsp)
lea    0x20(%rsp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <rand@plt>
sar    $0x8,%eax
cltd
idiv   %ebp
movslq %edx,%rax
movzbl 0x20(%rsp,%rax,1),%eax
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x10,%rbx
jne    1180 <rand_password+0x50>
movb   $0x0,0x10(%rsp)
mov    %rsp,%rdi
call   1040 <alloc_string@plt>
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.rand_password.pwdchars = [53 x i8] c"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\00"
define i8* @rand_password() {
%1 = alloca [53 x i8]
%2 = alloca [17 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = bitcast [53 x i8]* %1 to i8*
%6 = getelementptr inbounds [53 x i8], [53 x i8]* %1, i64 0, i64 0
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %3
store i32 0, i32* %4
br label %8
8: ; preds = %22, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 16
br i1 %10, label %11, label %25
11: ; preds = %8
%12 = call i32 (...) @rand()
%13 = ashr i32 %12, 8
%14 = load i32, i32* %3
%15 = srem i32 %13, %14
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [53 x i8], [53 x i8]* %1, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 %20
store i8 %18, i8* %21
br label %22
22: ; preds = %11
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %8
25: ; preds = %8
%26 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 16
store i8 0, i8* %26
%27 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%28 = call i8* @alloc_string(i8* %27)
ret i8* %28
}

LLVM IR (-O2):
@__const.rand_password.pwdchars = [53 x i8] c"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\00"
define i8* @rand_password() {
%1 = alloca [53 x i8]
%2 = alloca [17 x i8]
%3 = getelementptr inbounds [53 x i8], [53 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%5 = call i32 @strlen(i8* %3)
br label %9
6: ; preds = %9
%7 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 16
store i8 0, i8* %7
%8 = call i8* @alloc_string(i8* %4)
ret i8* %8
9: ; preds = %0, %9
%10 = phi i64 [ 0, %0 ], [ %18, %9 ]
%11 = call i32 (...) @rand()
%12 = ashr i32 %11, 8
%13 = srem i32 %12, %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [53 x i8], [53 x i8]* %1, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 %10
store i8 %16, i8* %17
%18 = add nuw nsw i64 %10, 1
%19 = icmp eq i64 %18, 16
br i1 %19, label %6, label %9
}