#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 random_key(char *key) {
  int i, len = 10 + rand() % (128 - 10);
  for (i = len; i-- > 0;)
    key[i] = '!' + rand() % 94;
  key[len] = 0;
}


x86 assembly (clang, -O0):
<random_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x76,%ecx
cltd
idiv   %ecx
add    $0xa,%edx
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
jle    116d <random_key+0x5d>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x5e,%ecx
cltd
idiv   %ecx
add    $0x21,%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1137 <random_key+0x27>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_key>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <rand@plt>
movslq %eax,%r15
imul   $0x22b63cbf,%r15,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x24,%rax
add    %ecx,%eax
imul   $0x76,%eax,%eax
sub    %eax,%r15d
cmp    $0xfffffff7,%r15d
jl     1182 <random_key+0x72>
lea    0x9(%r15),%ebx
lea    0xa(%r15),%ebp
add    %r14,%rbx
nop
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0xffffffffae4c415d,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
shr    $0x6,%ecx
add    %edx,%ecx
imul   $0x5e,%ecx,%ecx
sub    %ecx,%eax
add    $0x21,%al
mov    %al,(%rbx)
add    $0xffffffffffffffff,%rbx
add    $0xffffffff,%ebp
jg     1150 <random_key+0x40>
movslq %r15d,%rax
movb   $0x0,0xa(%rax,%r14,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @random_key(i8* nocapture writeonly %0) {
%2 = tail call i32 (...) @rand()
%3 = srem i32 %2, 118
%4 = icmp sgt i32 %3, -10
br i1 %4, label %5, label %18
5: ; preds = %1
%6 = add nsw i32 %3, 9
%7 = zext i32 %6 to i64
br label %8
8: ; preds = %5, %8
%9 = phi i64 [ %7, %5 ], [ %15, %8 ]
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 94
%12 = trunc i32 %11 to i8
%13 = add nsw i8 %12, 33
%14 = getelementptr inbounds i8, i8* %0, i64 %9
store i8 %13, i8* %14
%15 = add nsw i64 %9, -1
%16 = trunc i64 %9 to i32
%17 = icmp sgt i32 %16, 0
br i1 %17, label %8, label %18
18: ; preds = %8, %1
%19 = add nsw i32 %3, 10
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %0, i64 %20
store i8 0, i8* %21
ret void
}