// File: /workspace/github_cpp_makefile_star2_O3/Distrotech[P]stund/stun.cxx
// Function: stunCreateUserName(StunAddress4 const&, StunAtrString*)
void
stunCreateUserName(const StunAddress4& source, StunAtrString* username)
{
   UInt64 time = stunGetSystemTimeSecs();
   time -= (time % 20*60);
   //UInt64 hitime = time >> 32;
   UInt64 lotime = time & 0xFFFFFFFF;
	
   char buffer[1024];
   sprintf(buffer,
           "%08x:%08x:%08x:", 
           UInt32(source.addr),
           UInt32(stunRand()),
           UInt32(lotime));
   assert( strlen(buffer) < 1024 );
	
   assert(strlen(buffer) + 41 < STUN_MAX_STRING);
	
   char hmac[20];
   char key[] = "Jason";
   computeHmac(hmac, buffer, strlen(buffer), key, strlen(key) );
   char hmacHex[41];
   toHex(hmac, 20, hmacHex );
   hmacHex[40] =0;
	
   strcat(buffer,hmacHex);
	
   int l = strlen(buffer);
   assert( l+1 < STUN_MAX_STRING );
   assert( l%4 == 0 );
   
   username->sizeValue = l;
   memcpy(username->value,buffer,l);
   username->value[l]=0;
	
   //if (verbose) clog << "computed username=" << username.value << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x438, %rsp            # imm = 0x438
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x30(%rsp), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x2260
movq (%r15), %rcx
movabsq $-0x3333333333333333, %rdx # imm = 0xCCCCCCCCCCCCCCCD
movq %rcx, %rax
mulq %rdx
shrq $0x4, %rdx
shll $0x2, %edx
leal (%rdx,%rdx,4), %eax
movl %ecx, %edx
subl %eax, %edx
imull $-0x3c, %edx, %ebp
addl %ecx, %ebp
movl 0x4(%r14), %r14d
callq 0x4b28
leaq 0x4d7b(%rip), %rsi      # 0x9964
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movl %r14d, %edx
movl %eax, %ecx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x2070
movq %r15, %rdi
callq 0x20c0
cmpq $0x400, %rax            # imm = 0x400
jae 0x4cb1
cmpq $0xd7, %rax
jae 0x4cd0
xorl %eax, %eax
leaq 0x5747(%rip), %rcx      # 0xa370
leaq 0x5760(%rip), %rdx      # 0xa390
movzbl (%rax,%rcx), %esi
movl %esi, %edi
shrl $0x4, %edi
andl $0xf, %esi
movb (%rdi,%rdx), %dil
movb %dil, (%rsp,%rax,2)
movb (%rsi,%rdx), %sil
movb %sil, 0x1(%rsp,%rax,2)
incq %rax
cmpl $0x14, %eax
jne 0x4c30
xorl %ecx, %ecx
movb %cl, (%rsp,%rax,2)
movq %rsp, %rsi
movb %cl, 0x28(%rsi)
leaq 0x30(%rsp), %r14
movq %r14, %rdi
callq 0x22a0
movq %r14, %rdi
callq 0x20c0
cmpl $0xff, %eax
jge 0x4cef
testb $0x3, %al
jne 0x4d0e
movw %ax, 0x100(%rbx)
movslq %eax, %r14
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x2170
movb $0x0, (%rbx,%r14)
addq $0x438, %rsp            # imm = 0x438
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4cbc(%rip), %rdi      # 0x9974
leaq 0x4a8e(%rip), %rsi      # 0x974d
leaq 0x4cc4(%rip), %rcx      # 0x998a
movl $0x308, %edx            # imm = 0x308
callq 0x2120
leaq 0x4cf2(%rip), %rdi      # 0x99c9
leaq 0x4a6f(%rip), %rsi      # 0x974d
leaq 0x4ca5(%rip), %rcx      # 0x998a
movl $0x30a, %edx            # imm = 0x30A
callq 0x2120
leaq 0x4cf9(%rip), %rdi      # 0x99ef
leaq 0x4a50(%rip), %rsi      # 0x974d
leaq 0x4c86(%rip), %rcx      # 0x998a
movl $0x316, %edx            # imm = 0x316
callq 0x2120
leaq 0x4cf0(%rip), %rdi      # 0x9a05
leaq 0x4a31(%rip), %rsi      # 0x974d
leaq 0x4c67(%rip), %rcx      # 0x998a
movl $0x317, %edx            # imm = 0x317
callq 0x2120