#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*/ ILibStun_ComputeIntegrityKey(char *, char *, char *);
int /*<<< orphan*/ util_random(int, char *);
int /*<<< orphan*/ util_tohex(char *, int, char *);
void ILibStun_GenerateUserAndKey(int iceSlot, char *secret, char *result) {
  char rand[4];
  util_random(4, rand);
  result[0] = 8;
  util_tohex(rand, 4, result + 1);
  result[1] = (char)(iceSlot > 26 ? (iceSlot + 97) : (iceSlot + 65));
  result[9] = 32;
  ILibStun_ComputeIntegrityKey(result + 1, secret, result + 10);
}


x86 assembly (clang, -O0):
<ILibStun_GenerateUserAndKey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x1c(%rbp),%rsi
mov    $0x4,%edi
call   1050 <util_random@plt>
mov    -0x18(%rbp),%rax
movb   $0x8,(%rax)
lea    -0x1c(%rbp),%rdi
mov    -0x18(%rbp),%rdx
add    $0x1,%rdx
mov    $0x4,%esi
call   1030 <util_tohex@plt>
cmpl   $0x1a,-0x4(%rbp)
jle    1186 <ILibStun_GenerateUserAndKey+0x56>
mov    -0x4(%rbp),%eax
add    $0x61,%eax
mov    %eax,-0x20(%rbp)
jmp    118f <ILibStun_GenerateUserAndKey+0x5f>
mov    -0x4(%rbp),%eax
add    $0x41,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x18(%rbp),%rax
movb   $0x20,0x9(%rax)
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
add    $0xa,%rdx
call   1040 <ILibStun_ComputeIntegrityKey@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ILibStun_GenerateUserAndKey>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xc(%rsp),%r15
mov    $0x4,%edi
mov    %r15,%rsi
call   1050 <util_random@plt>
movb   $0x8,(%rbx)
lea    0x1(%rbx),%r12
mov    %r15,%rdi
mov    $0x4,%esi
mov    %r12,%rdx
call   1030 <util_tohex@plt>
xor    %eax,%eax
cmp    $0x1b,%ebp
setge  %al
shl    $0x5,%eax
add    %ebp,%eax
add    $0x41,%al
mov    %al,0x1(%rbx)
movb   $0x20,0x9(%rbx)
add    $0xa,%rbx
mov    %r12,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <ILibStun_ComputeIntegrityKey@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ILibStun_GenerateUserAndKey(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [4 x i8]
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%9 = call i32 @util_random(i32 4, i8* %8)
%10 = load i8*, i8** %6
%11 = getelementptr inbounds i8, i8* %10, i64 0
store i8 8, i8* %11
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%13 = load i8*, i8** %6
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = call i32 @util_tohex(i8* %12, i32 4, i8* %14)
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 26
br i1 %17, label %18, label %21
18: ; preds = %3
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 97
br label %24
21: ; preds = %3
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 65
br label %24
24: ; preds = %21, %18
%25 = phi i32 [ %20, %18 ], [ %23, %21 ]
%26 = trunc i32 %25 to i8
%27 = load i8*, i8** %6
%28 = getelementptr inbounds i8, i8* %27, i64 1
store i8 %26, i8* %28
%29 = load i8*, i8** %6
%30 = getelementptr inbounds i8, i8* %29, i64 9
store i8 32, i8* %30
%31 = load i8*, i8** %6
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = load i8*, i8** %5
%34 = load i8*, i8** %6
%35 = getelementptr inbounds i8, i8* %34, i64 10
%36 = call i32 @ILibStun_ComputeIntegrityKey(i8* %32, i8* %33, i8* %35)
ret void
}

LLVM IR (-O2):
define void @ILibStun_GenerateUserAndKey(i32 %0, i8* %1, i8* %2) {
%4 = alloca [4 x i8]
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%6 = call i32 @util_random(i32 4, i8* %5)
store i8 8, i8* %2
%7 = getelementptr inbounds i8, i8* %2, i64 1
%8 = call i32 @util_tohex(i8* %5, i32 4, i8* %7)
%9 = icmp sgt i32 %0, 26
%10 = select i1 %9, i32 97, i32 65
%11 = add nsw i32 %10, %0
%12 = trunc i32 %11 to i8
store i8 %12, i8* %7
%13 = getelementptr inbounds i8, i8* %2, i64 9
store i8 32, i8* %13
%14 = getelementptr inbounds i8, i8* %2, i64 10
%15 = call i32 @ILibStun_ComputeIntegrityKey(i8* %7, i8* %1, i8* %14)
ret void
}