// File: NKUSec[P]Rethinking-Honeywords/gen.cpp
// Function: gen(char*, char*)
void gen(char* pwd, char* dst)
{
	anpair anp;
	BaseStructure bs;
	if (isDigit(pwd[0])) anp.a = 'D';
	else if (isAlpha(pwd[0])) anp.a = 'L';
	else anp.a = 'S';
	anp.n = 1;

	int ptr = 1;
	while (pwd[ptr] != '\0')
	{
		if (isDigit(pwd[ptr]))
		{
			if (anp.a == 'D') anp.n++;
			else
			{
				bs.add(anp);
				anp.a = 'D'; anp.n = 1;
			}
		}
		else if (isAlpha(pwd[ptr]))
		{
			if (anp.a == 'L') anp.n++;
			else
			{
				bs.add(anp);
				anp.a = 'L'; anp.n = 1;
			}
		}
		else
		{
			if (anp.a == 'S') anp.n++;
			else
			{
				bs.add(anp);
				anp.a = 'S'; anp.n = 1;
			}
		}
		ptr++;
	}
	bs.add(anp);

	dst[0] = '\0';
	for (int i = 0; i < bs.l; i++)
	{
		char a = bs.w[i].a;
		int n = bs.w[i].n;
		int r = 0;
		if (a == 'D')
		{
			if (DT[n].cnt == 0) return;
			r = get_random_int(0, DT[n].cnt);
			strcat(dst, DT[n].t[r].w);
		}
		else if (a == 'L')
		{
			if (LT[n].cnt == 0) return;
			r = get_random_int(0, LT[n].cnt);
			strcat(dst, LT[n].t[r].w);
		}
		else
		{
			if (ST[n].cnt == 0) return;
			r = get_random_int(0, ST[n].cnt);
			strcat(dst, ST[n].t[r].w);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x10c(%rbp), %rdi
callq 0x2800
movq -0x8(%rbp), %rax
movsbl (%rax), %edi
callq 0x1420
testb $0x1, %al
jne 0x1e51
jmp 0x1e57
movb $0x44, -0x18(%rbp)
jmp 0x1e75
movq -0x8(%rbp), %rax
movsbl (%rax), %edi
callq 0x1450
testb $0x1, %al
jne 0x1e69
jmp 0x1e6f
movb $0x4c, -0x18(%rbp)
jmp 0x1e73
movb $0x53, -0x18(%rbp)
jmp 0x1e75
movl $0x1, -0x14(%rbp)
movl $0x1, -0x110(%rbp)
movq -0x8(%rbp), %rax
movslq -0x110(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x1fa8
movq -0x8(%rbp), %rax
movslq -0x110(%rbp), %rcx
movsbl (%rax,%rcx), %edi
callq 0x1420
testb $0x1, %al
jne 0x1eb8
jmp 0x1efa
movsbl -0x18(%rbp), %eax
cmpl $0x44, %eax
jne 0x1ecc
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1ef5
movq -0x18(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rsi
leaq -0x10c(%rbp), %rdi
callq 0x2820
movb $0x44, -0x18(%rbp)
movl $0x1, -0x14(%rbp)
jmp 0x1f94
movq -0x8(%rbp), %rax
movslq -0x110(%rbp), %rcx
movsbl (%rax,%rcx), %edi
callq 0x1450
testb $0x1, %al
jne 0x1f14
jmp 0x1f53
movsbl -0x18(%rbp), %eax
cmpl $0x4c, %eax
jne 0x1f28
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1f51
movq -0x18(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x120(%rbp), %rsi
leaq -0x10c(%rbp), %rdi
callq 0x2820
movb $0x4c, -0x18(%rbp)
movl $0x1, -0x14(%rbp)
jmp 0x1f92
movsbl -0x18(%rbp), %eax
cmpl $0x53, %eax
jne 0x1f67
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1f90
movq -0x18(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rsi
leaq -0x10c(%rbp), %rdi
callq 0x2820
movb $0x53, -0x18(%rbp)
movl $0x1, -0x14(%rbp)
jmp 0x1f92
jmp 0x1f94
movl -0x110(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x110(%rbp)
jmp 0x1e86
movq -0x18(%rbp), %rax
movq %rax, -0x130(%rbp)
movq -0x130(%rbp), %rsi
leaq -0x10c(%rbp), %rdi
callq 0x2820
movq -0x10(%rbp), %rax
movb $0x0, (%rax)
movl $0x0, -0x134(%rbp)
movl -0x134(%rbp), %eax
cmpl -0x10c(%rbp), %eax
jge 0x21ba
movslq -0x134(%rbp), %rax
movb -0x108(%rbp,%rax,8), %al
movb %al, -0x135(%rbp)
movslq -0x134(%rbp), %rax
movl -0x104(%rbp,%rax,8), %eax
movl %eax, -0x13c(%rbp)
movl $0x0, -0x140(%rbp)
movsbl -0x135(%rbp), %eax
cmpl $0x44, %eax
jne 0x20a5
movslq -0x13c(%rbp), %rcx
leaq 0x40bb(%rip), %rax      # 0x60f0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x4(%rax)
jne 0x2047
jmp 0x21ba
movslq -0x13c(%rbp), %rcx
leaq 0x409b(%rip), %rax      # 0x60f0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %esi
xorl %edi, %edi
callq 0x13d0
movl %eax, -0x140(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x13c(%rbp), %rcx
leaq 0x4072(%rip), %rax      # 0x60f0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rsi
movslq -0x140(%rbp), %rax
imulq $0x28, %rax, %rax
addq %rax, %rsi
addq $0x8, %rsi
callq 0x1140
jmp 0x21a4
movsbl -0x135(%rbp), %eax
cmpl $0x4c, %eax
jne 0x212c
movslq -0x13c(%rbp), %rcx
leaq 0x4301(%rip), %rax      # 0x63c0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x4(%rax)
jne 0x20d1
jmp 0x21ba
movslq -0x13c(%rbp), %rcx
leaq 0x42e1(%rip), %rax      # 0x63c0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %esi
xorl %edi, %edi
callq 0x13d0
movl %eax, -0x140(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x13c(%rbp), %rcx
leaq 0x42b8(%rip), %rax      # 0x63c0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rsi
movslq -0x140(%rbp), %rax
imulq $0x28, %rax, %rax
addq %rax, %rsi
addq $0x8, %rsi
callq 0x1140
jmp 0x21a2
movslq -0x13c(%rbp), %rcx
leaq 0x4556(%rip), %rax      # 0x6690
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x4(%rax)
jne 0x2149
jmp 0x21ba
movslq -0x13c(%rbp), %rcx
leaq 0x4539(%rip), %rax      # 0x6690
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %esi
xorl %edi, %edi
callq 0x13d0
movl %eax, -0x140(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x13c(%rbp), %rcx
leaq 0x4510(%rip), %rax      # 0x6690
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rsi
movslq -0x140(%rbp), %rax
imulq $0x28, %rax, %rax
addq %rax, %rsi
addq $0x8, %rsi
callq 0x1140
jmp 0x21a4
jmp 0x21a6
movl -0x134(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x134(%rbp)
jmp 0x1fd7
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
nopw %cs:(%rax,%rax)