#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*/ BIO;

/* Variables and functions */
int /*<<< orphan*/ BIO_indent(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ BIO_printf(int /*<<< orphan*/ *, char *, unsigned int);
int /*<<< orphan*/ BIO_puts(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ ssl_print_hex(int /*<<< orphan*/ *, int, char *,
                                 unsigned char const *, int);
int ssl_print_random(BIO *bio, int indent, const unsigned char **pmsg,
                     size_t *pmsglen) {
  unsigned int tm;
  const unsigned char *p = *pmsg;
  if (*pmsglen < 32)
    return 0;
  tm = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
  p += 4;
  BIO_indent(bio, indent, 80);
  BIO_puts(bio, "Random:\n");
  BIO_indent(bio, indent + 2, 80);
  BIO_printf(bio, "gmt_unix_time=0x%08X\n", tm);
  ssl_print_hex(bio, indent + 2, "random_bytes", p, 28);
  *pmsg += 32;
  *pmsglen -= 32;
  return 1;
}


x86 assembly (clang, -O0):
<ssl_print_random>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
cmpq   $0x20,(%rax)
jae    117c <ssl_print_random+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    1244 <ssl_print_random+0x104>
mov    -0x38(%rbp),%rax
movzbl (%rax),%eax
shl    $0x18,%eax
mov    -0x38(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x38(%rbp),%rcx
movzbl 0x2(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x38(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
or     %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x38(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x50,%edx
call   1040 <BIO_indent@plt>
mov    -0x10(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1060 <BIO_puts@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x2,%esi
mov    $0x50,%edx
call   1040 <BIO_indent@plt>
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%edx
lea    0xe0d(%rip),%rsi
call   1050 <BIO_printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x2,%esi
mov    -0x38(%rbp),%rcx
lea    0xe09(%rip),%rdx
mov    $0x1c,%r8d
call   1030 <ssl_print_hex@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rcx
add    $0x20,%rcx
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%rcx
sub    $0x20,%rcx
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ssl_print_random>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
cmpq   $0x20,(%rcx)
jb     11d0 <ssl_print_random+0x90>
mov    %rcx,%r15
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
mov    (%rdx),%r12
mov    (%r12),%r13d
bswap  %r13d
add    $0x4,%r12
mov    $0x50,%edx
call   1040 <BIO_indent@plt>
lea    0xe83(%rip),%rsi
mov    %rbx,%rdi
call   1060 <BIO_puts@plt>
add    $0x2,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x50,%edx
call   1040 <BIO_indent@plt>
lea    0xe6b(%rip),%rsi
mov    %rbx,%rdi
mov    %r13d,%edx
call   1050 <BIO_printf@plt>
lea    0xe6f(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r12,%rcx
mov    $0x1c,%r8d
call   1030 <ssl_print_hex@plt>
addq   $0x20,(%r14)
addq   $0xffffffffffffffe0,(%r15)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Random:\0A\00"
@.str.1 = [22 x i8] c"gmt_unix_time=0x%08X\0A\00"
@.str.2 = [13 x i8] c"random_bytes\00"
define i32 @ssl_print_random(i32* %0, i32 %1, i8** %2, i64* %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i64*
%10 = alloca i32
%11 = alloca i8*
store i32* %0, i32** %6
store i32 %1, i32* %7
store i8** %2, i8*** %8
store i64* %3, i64** %9
%12 = load i8**, i8*** %8
%13 = load i8*, i8** %12
store i8* %13, i8** %11
%14 = load i64*, i64** %9
%15 = load i64, i64* %14
%16 = icmp ult i64 %15, 32
br i1 %16, label %17, label %18
17: ; preds = %4
store i32 0, i32* %5
br label %66
18: ; preds = %4
%19 = load i8*, i8** %11
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = shl i32 %22, 24
%24 = load i8*, i8** %11
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = shl i32 %27, 16
%29 = or i32 %23, %28
%30 = load i8*, i8** %11
%31 = getelementptr inbounds i8, i8* %30, i64 2
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = shl i32 %33, 8
%35 = or i32 %29, %34
%36 = load i8*, i8** %11
%37 = getelementptr inbounds i8, i8* %36, i64 3
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = or i32 %35, %39
store i32 %40, i32* %10
%41 = load i8*, i8** %11
%42 = getelementptr inbounds i8, i8* %41, i64 4
store i8* %42, i8** %11
%43 = load i32*, i32** %6
%44 = load i32, i32* %7
%45 = call i32 @BIO_indent(i32* %43, i32 %44, i32 80)
%46 = load i32*, i32** %6
%47 = call i32 @BIO_puts(i32* %46, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%48 = load i32*, i32** %6
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 2
%51 = call i32 @BIO_indent(i32* %48, i32 %50, i32 80)
%52 = load i32*, i32** %6
%53 = load i32, i32* %10
%54 = call i32 @BIO_printf(i32* %52, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %53)
%55 = load i32*, i32** %6
%56 = load i32, i32* %7
%57 = add nsw i32 %56, 2
%58 = load i8*, i8** %11
%59 = call i32 @ssl_print_hex(i32* %55, i32 %57, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %58, i32 28)
%60 = load i8**, i8*** %8
%61 = load i8*, i8** %60
%62 = getelementptr inbounds i8, i8* %61, i64 32
store i8* %62, i8** %60
%63 = load i64*, i64** %9
%64 = load i64, i64* %63
%65 = sub i64 %64, 32
store i64 %65, i64* %63
store i32 1, i32* %5
br label %66
66: ; preds = %18, %17
%67 = load i32, i32* %5
ret i32 %67
}

LLVM IR (-O2):
@.str = [9 x i8] c"Random:\0A\00"
@.str.1 = [22 x i8] c"gmt_unix_time=0x%08X\0A\00"
@.str.2 = [13 x i8] c"random_bytes\00"
define i32 @ssl_print_random(i32* %0, i32 %1, i8** nocapture %2, i64* nocapture %3) {
%5 = load i8*, i8** %2
%6 = load i64, i64* %3
%7 = icmp ult i64 %6, 32
br i1 %7, label %37, label %8
8: ; preds = %4
%9 = load i8, i8* %5
%10 = zext i8 %9 to i32
%11 = shl nuw i32 %10, 24
%12 = getelementptr inbounds i8, i8* %5, i64 1
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = shl nuw nsw i32 %14, 16
%16 = or i32 %15, %11
%17 = getelementptr inbounds i8, i8* %5, i64 2
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = shl nuw nsw i32 %19, 8
%21 = or i32 %16, %20
%22 = getelementptr inbounds i8, i8* %5, i64 3
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = or i32 %21, %24
%26 = getelementptr inbounds i8, i8* %5, i64 4
%27 = tail call i32 @BIO_indent(i32* %0, i32 %1, i32 80)
%28 = tail call i32 @BIO_puts(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%29 = add nsw i32 %1, 2
%30 = tail call i32 @BIO_indent(i32* %0, i32 %29, i32 80)
%31 = tail call i32 @BIO_printf(i32* %0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%32 = tail call i32 @ssl_print_hex(i32* %0, i32 %29, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %26, i32 28)
%33 = load i8*, i8** %2
%34 = getelementptr inbounds i8, i8* %33, i64 32
store i8* %34, i8** %2
%35 = load i64, i64* %3
%36 = add i64 %35, -32
store i64 %36, i64* %3
br label %37
37: ; preds = %4, %8
%38 = phi i32 [ 1, %8 ], [ 0, %4 ]
ret i32 %38
}