#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 */
typedef int /*<<< orphan*/ alphanum;

/* Variables and functions */
char *malloc(int);
int rand();
char *random_message(int len) {
  char *msg = malloc(sizeof(char) * len);
  static const char alphanum[] =
      "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz(){}<>., ";
  int i = 0;
  for (i = 0; i < (len - 1); i++) {
    msg[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
  }
  msg[len - 1] = '\0';
  return msg;
}


x86 assembly (clang, -O0):
<random_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1193 <random_message+0x73>
mov    $0x0,%al
call   1040 <rand@plt>
cltq
mov    $0x47,%ecx
xor    %edx,%edx
div    %rcx
lea    0xe89(%rip),%rax
mov    (%rax,%rdx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114c <random_message+0x2c>
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_message>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r14d
call   1030 <malloc@plt>
mov    %rax,%r13
lea    -0x1(%r14),%r15d
cmp    $0x2,%r14d
jl     119a <random_message+0x7a>
mov    %r15d,%ebp
movabs $0xcd85689039b0ad13,%r14
68 85 cd
lea    0xeac(%rip),%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rcx
mov    %rcx,%rax
mul    %r14
mov    %rcx,%rax
sub    %rdx,%rax
shr    %rax
add    %rdx,%rax
shr    $0x6,%rax
imul   $0x47,%rax,%rax
sub    %rax,%rcx
movzbl (%r12,%rcx,1),%eax
mov    %al,0x0(%r13,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <random_message+0x40>
movslq %r15d,%rax
movb   $0x0,0x0(%r13,%rax,1)
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@random_message.alphanum = internal constant [72 x i8] c"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz(){}<>., \00"
define i8* @random_message(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = sext i32 %5 to i64
%7 = mul i64 1, %6
%8 = trunc i64 %7 to i32
%9 = call i8* @malloc(i32 %8)
store i8* %9, i8** %3
store i32 0, i32* %4
store i32 0, i32* %4
br label %10
10: ; preds = %25, %1
%11 = load i32, i32* %4
%12 = load i32, i32* %2
%13 = sub nsw i32 %12, 1
%14 = icmp slt i32 %11, %13
br i1 %14, label %15, label %28
15: ; preds = %10
%16 = call i32 (...) @rand()
%17 = sext i32 %16 to i64
%18 = urem i64 %17, 71
%19 = getelementptr inbounds [72 x i8], [72 x i8]* @random_message.alphanum, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = load i8*, i8** %3
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
store i8 %20, i8* %24
br label %25
25: ; preds = %15
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %10
28: ; preds = %10
%29 = load i8*, i8** %3
%30 = load i32, i32* %2
%31 = sub nsw i32 %30, 1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %29, i64 %32
store i8 0, i8* %33
%34 = load i8*, i8** %3
ret i8* %34
}

LLVM IR (-O2):
@random_message.alphanum = internal unnamed_addr constant [72 x i8] c"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz(){}<>., \00"
define noalias i8* @random_message(i32 %0) {
%2 = tail call i8* @malloc(i32 %0)
%3 = add i32 %0, -1
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %17
5: ; preds = %1
%6 = zext i32 %3 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %15, %7 ]
%9 = tail call i32 (...) @rand()
%10 = sext i32 %9 to i64
%11 = urem i64 %10, 71
%12 = getelementptr inbounds [72 x i8], [72 x i8]* @random_message.alphanum, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = getelementptr inbounds i8, i8* %2, i64 %8
store i8 %13, i8* %14
%15 = add nuw nsw i64 %8, 1
%16 = icmp eq i64 %15, %6
br i1 %16, label %17, label %7
17: ; preds = %7, %1
%18 = sext i32 %3 to i64
%19 = getelementptr inbounds i8, i8* %2, i64 %18
store i8 0, i8* %19
ret i8* %2
}