#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 HTTPWrapperGetRandomeNumber();
int /*<<< orphan*/ HTTPWrapperInitRandomeNumber();
void HTTPDigestGenerateCNonce(char *outbuff) {
  int i, num;
  HTTPWrapperInitRandomeNumber();
  for (i = 0; i < 32; i++) {
    num = HTTPWrapperGetRandomeNumber();
    switch (num) {
    case 0:
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    case 7:
    case 8:
    case 9:
      outbuff[i] = '0' + num;
      break;
    case 10:
    case 11:
    case 12:
    case 13:
    case 14:
    case 15:
      outbuff[i] = 'a' + (num - 10);
      break;
    default:
      outbuff[i] = 'f';
    }
  }
  outbuff[32] = 0;
}


x86 assembly (clang, -O0):
<HTTPDigestGenerateCNonce>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <HTTPWrapperInitRandomeNumber@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x20,-0xc(%rbp)
jge    11c8 <HTTPDigestGenerateCNonce+0xa8>
xor    %eax,%eax
call   1040 <HTTPWrapperGetRandomeNumber@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0xa,%eax
jb     1176 <HTTPDigestGenerateCNonce+0x56>
jmp    1162 <HTTPDigestGenerateCNonce+0x42>
mov    -0x14(%rbp),%eax
add    $0xfffffff6,%eax
sub    $0x6,%eax
jb     118e <HTTPDigestGenerateCNonce+0x6e>
jmp    11a9 <HTTPDigestGenerateCNonce+0x89>
mov    -0x10(%rbp),%eax
add    $0x30,%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11b5 <HTTPDigestGenerateCNonce+0x95>
mov    -0x10(%rbp),%eax
sub    $0xa,%eax
add    $0x61,%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11b5 <HTTPDigestGenerateCNonce+0x95>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x66,(%rax,%rcx,1)
jmp    11ba <HTTPDigestGenerateCNonce+0x9a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113a <HTTPDigestGenerateCNonce+0x1a>
mov    -0x8(%rbp),%rax
movb   $0x0,0x20(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HTTPDigestGenerateCNonce>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
xor    %eax,%eax
call   1030 <HTTPWrapperInitRandomeNumber@plt>
lea    0xeca(%rip),%r14
xor    %ebx,%ebx
jmp    114e <HTTPDigestGenerateCNonce+0x2e>
nopw   0x0(%rax,%rax,1)
mov    %cl,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    $0x20,%rbx
je     1165 <HTTPDigestGenerateCNonce+0x45>
xor    %eax,%eax
call   1040 <HTTPWrapperGetRandomeNumber@plt>
mov    $0x66,%cl
cmp    $0xf,%eax
ja     1140 <HTTPDigestGenerateCNonce+0x20>
cltq
movzbl (%rax,%r14,1),%ecx
jmp    1140 <HTTPDigestGenerateCNonce+0x20>
movb   $0x0,0x20(%r15)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @HTTPDigestGenerateCNonce(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i32 (...) @HTTPWrapperInitRandomeNumber()
store i32 0, i32* %3
br label %6
6: ; preds = %35, %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 32
br i1 %8, label %9, label %38
9: ; preds = %6
%10 = call i32 (...) @HTTPWrapperGetRandomeNumber()
store i32 %10, i32* %4
%11 = load i32, i32* %4
switch i32 %11, label %29 [
i32 0, label %12
i32 1, label %12
i32 2, label %12
i32 3, label %12
i32 4, label %12
i32 5, label %12
i32 6, label %12
i32 7, label %12
i32 8, label %12
i32 9, label %12
i32 10, label %20
i32 11, label %20
i32 12, label %20
i32 13, label %20
i32 14, label %20
i32 15, label %20
]
12: ; preds = %9, %9, %9, %9, %9, %9, %9, %9, %9, %9
%13 = load i32, i32* %4
%14 = add nsw i32 48, %13
%15 = trunc i32 %14 to i8
%16 = load i8*, i8** %2
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
store i8 %15, i8* %19
br label %34
20: ; preds = %9, %9, %9, %9, %9, %9
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, 10
%23 = add nsw i32 97, %22
%24 = trunc i32 %23 to i8
%25 = load i8*, i8** %2
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
store i8 %24, i8* %28
br label %34
29: ; preds = %9
%30 = load i8*, i8** %2
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
store i8 102, i8* %33
br label %34
34: ; preds = %29, %20, %12
br label %35
35: ; preds = %34
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
store i32 %37, i32* %3
br label %6
38: ; preds = %6
%39 = load i8*, i8** %2
%40 = getelementptr inbounds i8, i8* %39, i64 32
store i8 0, i8* %40
ret void
}

LLVM IR (-O2):
@switch.table.HTTPDigestGenerateCNonce = [16 x i8] c"0123456789abcdef"
define void @HTTPDigestGenerateCNonce(i8* nocapture writeonly %0) {
%2 = tail call i32 (...) @HTTPWrapperInitRandomeNumber()
br label %3
3: ; preds = %1, %11
%4 = phi i64 [ 0, %1 ], [ %14, %11 ]
%5 = tail call i32 (...) @HTTPWrapperGetRandomeNumber()
%6 = icmp ult i32 %5, 16
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = sext i32 %5 to i64
%9 = getelementptr inbounds [16 x i8], [16 x i8]* @switch.table.HTTPDigestGenerateCNonce, i64 0, i64 %8
%10 = load i8, i8* %9
br label %11
11: ; preds = %7, %3
%12 = phi i8 [ 102, %3 ], [ %10, %7 ]
%13 = getelementptr inbounds i8, i8* %0, i64 %4
store i8 %12, i8* %13
%14 = add nuw nsw i64 %4, 1
%15 = icmp eq i64 %14, 32
br i1 %15, label %16, label %3
16: ; preds = %11
%17 = getelementptr inbounds i8, i8* %0, i64 32
store i8 0, i8* %17
ret void
}