#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 */
char *base64_encode(char *, int);
int rand();
int /*<<< orphan*/ srand(scalar_t__);
scalar_t__ time(int /*<<< orphan*/ *);
char *digest_md5_getcnonce(void) {
  int entropy[8];
  int i;
  static int gencount = 0;
  static char *entropystr;
  srand(time(NULL) + (gencount++));
  for (i = 0; i < 8; i++)
    entropy[i] = rand();
  entropystr = base64_encode((char *)entropy, sizeof(int) * 8);
  return (entropystr);
}


x86 assembly (clang, -O0):
<digest_md5_getcnonce>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %rax,%rdi
mov    0x2eee(%rip),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0x2ee3(%rip)
cltq
add    %rax,%rdi
call   1030 <srand@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x8,-0x24(%rbp)
jge    119f <digest_md5_getcnonce+0x5f>
mov    $0x0,%al
call   1060 <rand@plt>
mov    %eax,%ecx
movslq -0x24(%rbp),%rax
mov    %ecx,-0x20(%rbp,%rax,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1176 <digest_md5_getcnonce+0x36>
lea    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1050 <base64_encode@plt>
mov    %rax,0x2e9c(%rip)
mov    0x2e95(%rip),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<digest_md5_getcnonce>:
sub    $0x28,%rsp
xor    %edi,%edi
call   1040 <time@plt>
movslq 0x2ef6(%rip),%rdi
lea    0x1(%rdi),%ecx
mov    %ecx,0x2eed(%rip)
add    %rax,%rdi
call   1030 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x4(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x8(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0xc(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x10(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x14(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x18(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,0x1c(%rsp)
mov    %rsp,%rdi
mov    $0x20,%esi
call   1050 <base64_encode@plt>
mov    %rax,0x2e82(%rip)
add    $0x28,%rsp
ret

LLVM IR (-O0):
@digest_md5_getcnonce.gencount = internal global i32 0
@digest_md5_getcnonce.entropystr = internal global i8* null
define i8* @digest_md5_getcnonce() {
%1 = alloca [8 x i32]
%2 = alloca i32
%3 = call i64 @time(i32* null)
%4 = load i32, i32* @digest_md5_getcnonce.gencount
%5 = add nsw i32 %4, 1
store i32 %5, i32* @digest_md5_getcnonce.gencount
%6 = sext i32 %4 to i64
%7 = add nsw i64 %3, %6
%8 = call i32 @srand(i64 %7)
store i32 0, i32* %2
br label %9
9: ; preds = %17, %0
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 8
br i1 %11, label %12, label %20
12: ; preds = %9
%13 = call i32 (...) @rand()
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 %15
store i32 %13, i32* %16
br label %17
17: ; preds = %12
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
br label %9
20: ; preds = %9
%21 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
%22 = bitcast i32* %21 to i8*
%23 = call i8* @base64_encode(i8* %22, i32 32)
store i8* %23, i8** @digest_md5_getcnonce.entropystr
%24 = load i8*, i8** @digest_md5_getcnonce.entropystr
ret i8* %24
}

LLVM IR (-O2):
@digest_md5_getcnonce.gencount = internal unnamed_addr global i32 0
@digest_md5_getcnonce.entropystr = internal unnamed_addr global i8* null
define i8* @digest_md5_getcnonce() {
%1 = alloca [8 x i32]
%2 = bitcast [8 x i32]* %1 to i8*
%3 = tail call i64 @time(i32* null)
%4 = load i32, i32* @digest_md5_getcnonce.gencount
%5 = add nsw i32 %4, 1
store i32 %5, i32* @digest_md5_getcnonce.gencount
%6 = sext i32 %4 to i64
%7 = add nsw i64 %3, %6
%8 = tail call i32 @srand(i64 %7)
%9 = tail call i32 (...) @rand()
%10 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
store i32 %9, i32* %10
%11 = tail call i32 (...) @rand()
%12 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 1
store i32 %11, i32* %12
%13 = tail call i32 (...) @rand()
%14 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 2
store i32 %13, i32* %14
%15 = tail call i32 (...) @rand()
%16 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 3
store i32 %15, i32* %16
%17 = tail call i32 (...) @rand()
%18 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 4
store i32 %17, i32* %18
%19 = tail call i32 (...) @rand()
%20 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 5
store i32 %19, i32* %20
%21 = tail call i32 (...) @rand()
%22 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 6
store i32 %21, i32* %22
%23 = tail call i32 (...) @rand()
%24 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 7
store i32 %23, i32* %24
%25 = call i8* @base64_encode(i8* %2, i32 32)
store i8* %25, i8** @digest_md5_getcnonce.entropystr
ret i8* %25
}