#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 rand();
void next_rnd(char *out) {
  for (int i = 0; i < 10; i++) {
    out[i] = rand() % (90 - 65 + 1) + 65;
  }
  out[10] = '\0';
}


x86 assembly (clang, -O0):
<next_rnd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    1158 <next_rnd+0x48>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x41,%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <next_rnd+0x13>
mov    -0x8(%rbp),%rax
movb   $0x0,0xa(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_rnd>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,(%rbx)
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,0x1(%rbx)
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,0x2(%rbx)
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,0x3(%rbx)
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,0x4(%rbx)
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,0x5(%rbx)
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,0x6(%rbx)
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,0x7(%rbx)
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,0x8(%rbx)
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,0x9(%rbx)
movb   $0x0,0xa(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @next_rnd(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %16, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 10
br i1 %6, label %7, label %19
7: ; preds = %4
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 26
%10 = add nsw i32 %9, 65
%11 = trunc i32 %10 to i8
%12 = load i8*, i8** %2
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
store i8 %11, i8* %15
br label %16
16: ; preds = %7
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %4
19: ; preds = %4
%20 = load i8*, i8** %2
%21 = getelementptr inbounds i8, i8* %20, i64 10
store i8 0, i8* %21
ret void
}

LLVM IR (-O2):
define void @next_rnd(i8* nocapture writeonly %0) {
%2 = tail call i32 (...) @rand()
%3 = srem i32 %2, 26
%4 = trunc i32 %3 to i8
%5 = add nsw i8 %4, 65
store i8 %5, i8* %0
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 26
%8 = trunc i32 %7 to i8
%9 = add nsw i8 %8, 65
%10 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %9, i8* %10
%11 = tail call i32 (...) @rand()
%12 = srem i32 %11, 26
%13 = trunc i32 %12 to i8
%14 = add nsw i8 %13, 65
%15 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %14, i8* %15
%16 = tail call i32 (...) @rand()
%17 = srem i32 %16, 26
%18 = trunc i32 %17 to i8
%19 = add nsw i8 %18, 65
%20 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %19, i8* %20
%21 = tail call i32 (...) @rand()
%22 = srem i32 %21, 26
%23 = trunc i32 %22 to i8
%24 = add nsw i8 %23, 65
%25 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %24, i8* %25
%26 = tail call i32 (...) @rand()
%27 = srem i32 %26, 26
%28 = trunc i32 %27 to i8
%29 = add nsw i8 %28, 65
%30 = getelementptr inbounds i8, i8* %0, i64 5
store i8 %29, i8* %30
%31 = tail call i32 (...) @rand()
%32 = srem i32 %31, 26
%33 = trunc i32 %32 to i8
%34 = add nsw i8 %33, 65
%35 = getelementptr inbounds i8, i8* %0, i64 6
store i8 %34, i8* %35
%36 = tail call i32 (...) @rand()
%37 = srem i32 %36, 26
%38 = trunc i32 %37 to i8
%39 = add nsw i8 %38, 65
%40 = getelementptr inbounds i8, i8* %0, i64 7
store i8 %39, i8* %40
%41 = tail call i32 (...) @rand()
%42 = srem i32 %41, 26
%43 = trunc i32 %42 to i8
%44 = add nsw i8 %43, 65
%45 = getelementptr inbounds i8, i8* %0, i64 8
store i8 %44, i8* %45
%46 = tail call i32 (...) @rand()
%47 = srem i32 %46, 26
%48 = trunc i32 %47 to i8
%49 = add nsw i8 %48, 65
%50 = getelementptr inbounds i8, i8* %0, i64 9
store i8 %49, i8* %50
%51 = getelementptr inbounds i8, i8* %0, i64 10
store i8 0, i8* %51
ret void
}