#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 random();
int /*<<< orphan*/ srandom(unsigned int);
void create_password(char *dst, size_t len, unsigned int seed) {
  srandom(seed);
  for (size_t i = 0; i < len - 1; i++) {
    dst[i] = 'A' + random() % ('Z' - 'A');
  }
  dst[len - 1] = '\0';
}


x86 assembly (clang, -O0):
<create_password>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <srandom@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jae    1189 <create_password+0x69>
mov    $0x0,%al
call   1040 <random@plt>
movsbl %al,%eax
mov    $0x19,%ecx
cltd
idiv   %ecx
add    $0x41,%edx
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1143 <create_password+0x23>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_password>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %edx,%edi
call   1030 <srandom@plt>
add    $0xffffffffffffffff,%r15
je     1175 <create_password+0x55>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <random@plt>
movsbl %al,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rax,%rcx,8),%ecx
movzwl %cx,%edx
shr    $0xa,%ecx
shr    $0xf,%edx
add    %cl,%dl
movzbl %dl,%ecx
lea    (%rcx,%rcx,4),%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %cl,%al
add    $0x41,%al
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <create_password+0x20>
movb   $0x0,(%r14,%r15,1)
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @create_password(i8* nocapture writeonly %0, i64 %1, i32 %2) {
%4 = tail call i32 @srandom(i32 %2)
%5 = add i64 %1, -1
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %9, %3
%8 = getelementptr inbounds i8, i8* %0, i64 %5
store i8 0, i8* %8
ret void
9: ; preds = %3, %9
%10 = phi i64 [ %15, %9 ], [ 0, %3 ]
%11 = tail call signext i8 (...) @random()
%12 = srem i8 %11, 25
%13 = add nsw i8 %12, 65
%14 = getelementptr inbounds i8, i8* %0, i64 %10
store i8 %13, i8* %14
%15 = add nuw i64 %10, 1
%16 = icmp eq i64 %15, %5
br i1 %16, label %7, label %9
}