#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 /*<<< orphan*/ assert(char *);
int /*<<< orphan*/ bzero(char *, int);
int rand();
void create_random_msg(char *msg) {
  assert(msg);
  bzero(msg, 1024);
  int i, count = rand() % 20;
  char chaos[] = {'a', 'A'};
  for (i = 0; i < count; i++) {
    msg[i] = chaos[rand() % 2] + rand() % 26;
  }
  msg[i] = '\n';
}


x86 assembly (clang, -O0):
<create_random_msg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    $0x400,%esi
call   1040 <bzero@plt>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    0xe94(%rip),%ax
mov    %ax,-0x12(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11cc <create_random_msg+0x9c>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
movsbl -0x12(%rbp,%rax,1),%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%eax
add    %edx,%eax
mov    %al,%dl
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    1177 <create_random_msg+0x47>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0xa,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_random_msg>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r14
call   1030 <assert@plt>
mov    %r14,%rdi
mov    $0x400,%esi
call   1040 <bzero@plt>
xor    %r12d,%r12d
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
shl    $0x2,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
test   %eax,%eax
jle    11df <create_random_msg+0xaf>
mov    %eax,%r12d
lea    0xe7c(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
movslq %eax,%r13
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    0x0(%r13,%r15,1),%al
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1190 <create_random_msg+0x60>
movb   $0xa,(%r14,%r12,1)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.create_random_msg.chaos = [2 x i8] c"aA"
define void @create_random_msg(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [2 x i8]
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @assert(i8* %6)
%8 = load i8*, i8** %2
%9 = call i32 @bzero(i8* %8, i32 1024)
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 20
store i32 %11, i32* %4
%12 = bitcast [2 x i8]* %5 to i8*
store i32 0, i32* %3
br label %13
13: ; preds = %32, %1
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %35
17: ; preds = %13
%18 = call i32 (...) @rand()
%19 = srem i32 %18, 2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = call i32 (...) @rand()
%25 = srem i32 %24, 26
%26 = add nsw i32 %23, %25
%27 = trunc i32 %26 to i8
%28 = load i8*, i8** %2
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
store i8 %27, i8* %31
br label %32
32: ; preds = %17
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %13
35: ; preds = %13
%36 = load i8*, i8** %2
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
store i8 10, i8* %39
ret void
}

LLVM IR (-O2):
@__const.create_random_msg.chaos = [2 x i8] c"aA"
define void @create_random_msg(i8* %0) {
%2 = tail call i32 @assert(i8* %0)
%3 = tail call i32 @bzero(i8* %0, i32 1024)
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 20
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %25
7: ; preds = %1
%8 = zext i32 %5 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %21, %9 ]
%11 = tail call i32 (...) @rand()
%12 = srem i32 %11, 2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [2 x i8], [2 x i8]* @__const.create_random_msg.chaos, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = tail call i32 (...) @rand()
%17 = srem i32 %16, 26
%18 = trunc i32 %17 to i8
%19 = add i8 %15, %18
%20 = getelementptr inbounds i8, i8* %0, i64 %10
store i8 %19, i8* %20
%21 = add nuw nsw i64 %10, 1
%22 = icmp eq i64 %21, %8
br i1 %22, label %23, label %9
23: ; preds = %9
%24 = zext i32 %5 to i64
br label %25
25: ; preds = %1, %23
%26 = phi i64 [ %24, %23 ], [ 0, %1 ]
%27 = getelementptr inbounds i8, i8* %0, i64 %26
store i8 10, i8* %27
ret void
}