#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 random();
void make_random_msg(unsigned char *len, char *buf) {
  int size, i, r;
  size = (random() % 130) + 1;
  *len = (unsigned char)size;
  for (i = 0; i <= size; i++) {
    r = random() % 57;
    if (r > 25 && r < 32) {
      if (r < 29)
        r = 25;
      else
        r = 32;
    }
    *(buf++) = (char)(r + 65);
  }
}


x86 assembly (clang, -O0):
<make_random_msg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <random@plt>
mov    $0x82,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11c2 <make_random_msg+0xb2>
mov    $0x0,%al
call   1030 <random@plt>
mov    $0x39,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
cmpl   $0x19,-0x1c(%rbp)
jle    119b <make_random_msg+0x8b>
cmpl   $0x20,-0x1c(%rbp)
jge    119b <make_random_msg+0x8b>
cmpl   $0x1d,-0x1c(%rbp)
jge    118f <make_random_msg+0x7f>
movl   $0x19,-0x1c(%rbp)
jmp    1196 <make_random_msg+0x86>
movl   $0x20,-0x1c(%rbp)
jmp    119b <make_random_msg+0x8b>
mov    -0x1c(%rbp),%eax
add    $0x41,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1147 <make_random_msg+0x37>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_random_msg>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <random@plt>
cltq
imul   $0x7e07e07f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
mov    %ecx,%edx
shl    $0x7,%edx
lea    (%rdx,%rcx,2),%ecx
sub    %ecx,%eax
lea    0x1(%rax),%ecx
mov    %cl,(%r14)
cmp    $0xffffffff,%eax
jge    1153 <make_random_msg+0x43>
pop    %rbx
pop    %r14
pop    %r15
ret
movslq %eax,%r14
add    $0x2,%r14
xor    %ebx,%ebx
jmp    117b <make_random_msg+0x6b>
xchg   %ax,%ax
add    %edx,%eax
add    $0xffffffe6,%eax
cmp    $0x6,%eax
cmovb  %esi,%ecx
add    $0x41,%cl
mov    %cl,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    %ebx,%r14d
je     114d <make_random_msg+0x3d>
xor    %eax,%eax
call   1030 <random@plt>
movslq %eax,%rcx
imul   $0xffffffff8fb823ef,%rcx,%rdx
shr    $0x20,%rdx
add    %eax,%edx
mov    %edx,%esi
shr    $0x1f,%esi
sar    $0x5,%edx
add    %esi,%edx
imul   $0x39,%edx,%edx
sub    %edx,%ecx
neg    %edx
mov    $0x19,%esi
cmp    $0x1d,%ecx
jl     1160 <make_random_msg+0x50>
mov    $0x20,%esi
jmp    1160 <make_random_msg+0x50>

LLVM IR (-O0):
define void @make_random_msg(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = call i32 (...) @random()
%9 = srem i32 %8, 130
%10 = add nsw i32 %9, 1
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = trunc i32 %11 to i8
%13 = load i8*, i8** %3
store i8 %12, i8* %13
store i32 0, i32* %6
br label %14
14: ; preds = %38, %2
%15 = load i32, i32* %6
%16 = load i32, i32* %5
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %41
18: ; preds = %14
%19 = call i32 (...) @random()
%20 = srem i32 %19, 57
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = icmp sgt i32 %21, 25
br i1 %22, label %23, label %32
23: ; preds = %18
%24 = load i32, i32* %7
%25 = icmp slt i32 %24, 32
br i1 %25, label %26, label %32
26: ; preds = %23
%27 = load i32, i32* %7
%28 = icmp slt i32 %27, 29
br i1 %28, label %29, label %30
29: ; preds = %26
store i32 25, i32* %7
br label %31
30: ; preds = %26
store i32 32, i32* %7
br label %31
31: ; preds = %30, %29
br label %32
32: ; preds = %31, %23, %18
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 65
%35 = trunc i32 %34 to i8
%36 = load i8*, i8** %4
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %4
store i8 %35, i8* %36
br label %38
38: ; preds = %32
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
br label %14
41: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @make_random_msg(i8* nocapture writeonly %0, i8* nocapture writeonly %1) {
%3 = tail call i32 (...) @random()
%4 = srem i32 %3, 130
%5 = trunc i32 %4 to i8
%6 = add i8 %5, 1
store i8 %6, i8* %0
%7 = icmp slt i32 %4, -1
br i1 %7, label %25, label %8
8: ; preds = %2
%9 = add nsw i32 %4, 1
br label %10
10: ; preds = %8, %10
%11 = phi i32 [ %23, %10 ], [ 0, %8 ]
%12 = phi i8* [ %22, %10 ], [ %1, %8 ]
%13 = tail call i32 (...) @random()
%14 = srem i32 %13, 57
%15 = add nsw i32 %14, -26
%16 = icmp ult i32 %15, 6
%17 = icmp slt i32 %14, 29
%18 = select i1 %17, i32 25, i32 32
%19 = select i1 %16, i32 %18, i32 %14
%20 = trunc i32 %19 to i8
%21 = add nsw i8 %20, 65
%22 = getelementptr inbounds i8, i8* %12, i64 1
store i8 %21, i8* %12
%23 = add nuw nsw i32 %11, 1
%24 = icmp eq i32 %11, %9
br i1 %24, label %25, label %10
25: ; preds = %10, %2
ret void
}