// File: /workspace/github_cpp_makefile_star2_O1/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 0x2270
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 0x4b17
leaq 0x4d94(%rip), %rsi      # 0x996c
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 0x4ca0
cmpq $0xd7, %rax
jae 0x4cbf
xorl %eax, %eax
leaq 0x5758(%rip), %rcx      # 0xa370
leaq 0x5771(%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 0x4c1f
xorl %ecx, %ecx
movb %cl, (%rsp,%rax,2)
movq %rsp, %rsi
movb %cl, 0x28(%rsi)
leaq 0x30(%rsp), %r14
movq %r14, %rdi
callq 0x22b0
movq %r14, %rdi
callq 0x20c0
cmpl $0xff, %eax
jge 0x4cde
testb $0x3, %al
jne 0x4cfd
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 0x4cd5(%rip), %rdi      # 0x997c
leaq 0x4aa7(%rip), %rsi      # 0x9755
leaq 0x4cdd(%rip), %rcx      # 0x9992
movl $0x308, %edx            # imm = 0x308
callq 0x2120
leaq 0x4d0b(%rip), %rdi      # 0x99d1
leaq 0x4a88(%rip), %rsi      # 0x9755
leaq 0x4cbe(%rip), %rcx      # 0x9992
movl $0x30a, %edx            # imm = 0x30A
callq 0x2120
leaq 0x4d12(%rip), %rdi      # 0x99f7
leaq 0x4a69(%rip), %rsi      # 0x9755
leaq 0x4c9f(%rip), %rcx      # 0x9992
movl $0x316, %edx            # imm = 0x316
callq 0x2120
leaq 0x4d09(%rip), %rdi      # 0x9a0d
leaq 0x4a4a(%rip), %rsi      # 0x9755
leaq 0x4c80(%rip), %rcx      # 0x9992
movl $0x317, %edx            # imm = 0x317
callq 0x2120