user: What is the c source code of the assembly code below:

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x678,%rsp
  mov    $0x7f,%ecx
  pxor   %xmm0,%xmm0
  xor    %ebx,%ebx
  lea    D267(%rip),%rsi
  mov    %fs:0x28,%rax
  mov    %rax,0x2668(%rsp)
  xor    %eax,%eax
  lea    0x260(%rsp),%r12
  lea    0xe60(%rsp),%r14
  movl   $0x0,0x130(%rsp)
  mov    %r12,%rdi
  lea    0x1260(%rsp),%rbp
  movaps %xmm0,0xf0(%rsp)
  lea    0x2260(%rsp),%r13
  movaps %xmm0,0x100(%rsp)
  movaps %xmm0,0x110(%rsp)
  movaps %xmm0,0x120(%rsp)
  rep stos %rax,%es:(%rdi)
  mov    $0x11,%ecx
  movl   $0x0,(%rdi)
  lea    0x1d0(%rsp),%rdi
  mov    %rdi,0x28(%rsp)
  rep stos %rax,%es:(%rdi)
  mov    $0x7f,%ecx
  mov    %r14,%rdi
  rep stos %rax,%es:(%rdi)
  mov    $0x7f,%ecx
  movl   $0x0,(%rdi)
  mov    %rbp,%rdi
  rep stos %rax,%es:(%rdi)
  mov    $0x7f,%ecx
  movl   $0x0,(%rdi)
  lea    0x1660(%rsp),%rdi
  mov    %rdi,0x10(%rsp)
  rep stos %rax,%es:(%rdi)
  mov    $0x7f,%ecx
  movl   $0x0,(%rdi)
  lea    0x1a60(%rsp),%rdi
  mov    %rdi,0x8(%rsp)
  rep stos %rax,%es:(%rdi)
  mov    $0x7f,%ecx
  movl   $0x0,(%rdi)
  lea    0x1e60(%rsp),%rdi
  mov    %rdi,0x18(%rsp)
  rep stos %rax,%es:(%rdi)
  movl   $0x0,(%rdi)
  lea    D171(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%r15
  test   %rax,%rax
  jne    L426
  jmp    L204
  nopw   0x0(%rax,%rax,1)
L280:
  cmpl   $0x23,0x2260(%rsp)
  jne    L478
L426:
  mov    %r15,%rdx
  mov    $0xff,%esi
  mov    %r13,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  jne    L280
  mov    %r15,%rdi
  call   <fclose@plt>
  cmp    $0x4,%ebx
  jle    L26
  xor    %edi,%edi
  call   <mysql_init@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L460
  push   $0x0
  mov    %rbp,%rsi
  mov    %rax,%rdi
  xor    %r8d,%r8d
  push   $0x0
  mov    0x40(%rsp),%r9d
  mov    0x18(%rsp),%rcx
  mov    0x20(%rsp),%rdx
  call   <mysql_real_connect@plt>
  pop    %rsi
  pop    %rdi
  test   %rax,%rax
  je     L460
  mov    0x18(%rsp),%rsi
  mov    %r15,%rdi
  call   <mysql_select_db@plt>
  test   %rax,%rax
  js     L41
  lea    D4(%rip),%rdi
  lea    D253(%rip),%rbp
  call   <puts@plt>
  lea    D122(%rip),%rdi
  call   <puts@plt>
  mov    %r13,0x10(%rsp)
  nopl   (%rax)
L107:
  lea    D152(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    %rbp,%rdi
  mov    %r12,%rsi
  call   <scanf@plt>
  mov    %r12,%rdi
  call   <strlen@plt>
  cmp    $0x10,%eax
  jg     L361
  lea    D42(%rip),%rsi
  mov    %r14,%rdi
  xor    %eax,%eax
  mov    %r12,%rdx
  call   <sprintf@plt>
  mov    %r14,%rsi
  mov    %r15,%rdi
  call   <mysql_query@plt>
  test   %eax,%eax
  jne    L259
  mov    %r15,%rdi
  call   <mysql_store_result@plt>
  mov    %rax,%rdi
  mov    %rax,0x8(%rsp)
  call   <mysql_num_rows@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  jne    L515
  mov    0x8(%rsp),%rdi
  mov    0x10(%rsp),%r13
  call   <mysql_free_result@plt>
  mov    %r12,%rdi
  call   <strlen@plt>
  lea    0x50(%rsp),%rdi
  mov    %r12,%rsi
  lea    0x1(%rax),%edx
  mov    %rdi,0x20(%rsp)
  call   <memcpy@plt>
  xor    %edi,%edi
  call   <time@plt>
  mov    %rax,0x30(%rsp)
  lea    0x140(%rsp),%rax
  mov    %rax,0x18(%rsp)
  lea    0xa0(%rsp),%rax
  mov    %rax,0x8(%rsp)
L125:
  lea    D215(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    %rbp,%rdi
  mov    %r12,%rsi
  call   <scanf@plt>
  mov    %r12,%rdi
  call   <strlen@plt>
  cmp    $0x10,%eax
  jg     L367
L411:
  mov    0x18(%rsp),%rdi
  mov    $0x11,%edx
  mov    %r12,%rsi
  call   <memcpy@plt>
  lea    D204(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <scanf@plt>
  mov    0x8(%rsp),%rdi
  mov    $0x11,%edx
  mov    %r12,%rsi
  call   <memcpy@plt>
  mov    0x140(%rsp),%ecx
  mov    0xa0(%rsp),%edx
  mov    %ebx,%eax
  mov    0xa4(%rsp),%esi
  cmp    %esi,0x144(%rsp)
  jne    L91
  xor    %eax,%eax
  cmp    %edx,%ecx
  sete   %al
L91:
  mov    0xa8(%rsp),%ecx
  cmp    %ecx,0x148(%rsp)
  cmovne %ebx,%eax
  mov    0xac(%rsp),%ecx
  cmp    %ecx,0x14c(%rsp)
  mov    0xb0(%rsp),%ecx
  mov    0xc8(%rsp),%edx
  cmovne %ebx,%eax
  cmp    %ecx,0x150(%rsp)
  mov    0xb4(%rsp),%ecx
  mov    0xd4(%rsp),%esi
  cmovne %ebx,%eax
  cmp    %ecx,0x154(%rsp)
  mov    0xb8(%rsp),%ecx
  cmovne %ebx,%eax
  cmp    %ecx,0x158(%rsp)
  mov    0xbc(%rsp),%ecx
  cmovne %ebx,%eax
  cmp    %ecx,0x15c(%rsp)
  mov    0xc0(%rsp),%ecx
  cmovne %ebx,%eax
  cmp    %ecx,0x160(%rsp)
  mov    0xc4(%rsp),%ecx
  cmovne %ebx,%eax
  cmp    %ecx,0x164(%rsp)
  mov    0xcc(%rsp),%ecx
  cmovne %ebx,%eax
  cmp    %edx,0x168(%rsp)
  mov    0xd0(%rsp),%edx
  cmovne %ebx,%eax
  cmp    %ecx,0x16c(%rsp)
  mov    0x178(%rsp),%ecx
  cmovne %ebx,%eax
  cmp    %edx,0x170(%rsp)
  mov    0xd8(%rsp),%edx
  cmovne %ebx,%eax
  cmp    %esi,0x174(%rsp)
  je     L175
L183:
  lea    D99(%rip),%rdi
  call   <puts@plt>
  jmp    L125
  xchg   %ax,%ax
L478:
  cmp    $0x3,%ebx
  jle    L142
L366:
  cmp    $0x4,%ebx
  ja     L152
  lea    D246(%rip),%rcx
  mov    %ebx,%eax
  movslq (%rcx,%rax,4),%rax
  add    %rcx,%rax
  notrack jmp *%rax
  mov    0x20(%rsp),%eax
  mov    %r13,%rsi
  mov    %rbp,%rdi
  lea    0x1(%rax),%edx
  call   <memcpy@plt>
L152:
  add    $0x1,%ebx
  jmp    L426
L460:
  mov    %r15,%rdi
  mov    $0x1,%r12d
  call   <mysql_error@plt>
  mov    0x30(%rsp),%edx
  mov    %rbp,%rsi
  lea    D210(%rip),%rdi
  mov    %rax,%rcx
  xor    %eax,%eax
  call   <printf@plt>
  mov    %r15,%rdi
  call   <mysql_close@plt>
L253:
  mov    0x2668(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L198
  add    $0x2678,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L26:
  lea    D82(%rip),%rdi
  mov    $0x1,%r12d
  call   <puts@plt>
  jmp    L253
L142:
  mov    %r13,%rdi
  call   <strlen@plt>
  mov    %eax,0x20(%rsp)
  sub    $0x1,%eax
  movslq %eax,%rdx
  cmpl   $0xa,0x2260(%rsp,%rdx,4)
  je     L40
L445:
  movslq 0x20(%rsp),%rax
  movl   $0x0,0x2260(%rsp,%rax,4)
  jmp    L366
  mov    %r13,%rdi
  call   <atoi@plt>
  mov    %eax,0x30(%rsp)
  jmp    L152
  mov    0x20(%rsp),%eax
  mov    0x10(%rsp),%rdi
  mov    %r13,%rsi
  lea    0x1(%rax),%edx
  call   <memcpy@plt>
  jmp    L152
  mov    0x20(%rsp),%eax
  mov    0x8(%rsp),%rdi
  mov    %r13,%rsi
  lea    0x1(%rax),%edx
  call   <memcpy@plt>
  jmp    L152
  mov    0x20(%rsp),%eax
  mov    0x18(%rsp),%rdi
  mov    %r13,%rsi
  lea    0x1(%rax),%edx
  call   <memcpy@plt>
  jmp    L152
L40:
  movslq 0x20(%rsp),%rdx
  mov    %eax,0x20(%rsp)
  movl   $0x0,0x2260(%rsp,%rdx,4)
  jmp    L445
  nop
L361:
  lea    D334(%rip),%rdi
  call   <puts@plt>
  jmp    L107
L367:
  mov    %r12,%rdi
  call   <strlen@plt>
  cmp    $0x7,%eax
  jle    L411
  lea    D3(%rip),%rdi
  call   <puts@plt>
  jmp    L125
L175:
  cmp    %edx,%ecx
  jne    L183
  mov    0xdc(%rsp),%ecx
  cmp    %ecx,0x17c(%rsp)
  jne    L183
  test   $0x1,%al
  je     L183
  mov    %r13,0x48(%rsp)
  lea    0x660(%rsp),%rbx
  nopl   0x0(%rax)
L87:
  lea    D257(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <scanf@plt>
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    %r12,%rsi
  mov    %rbx,%rdi
  lea    0x1(%rax),%edx
  call   <memcpy@plt>
  mov    %r14,%rdi
  xor    %eax,%eax
  mov    %rbx,%rdx
  lea    D32(%rip),%rsi
  call   <sprintf@plt>
  mov    %r14,%rsi
  mov    %r15,%rdi
  call   <mysql_query@plt>
  test   %eax,%eax
  jne    L259
  mov    %r15,%rdi
  call   <mysql_store_result@plt>
  mov    %rax,%rdi
  mov    %rax,0x8(%rsp)
  call   <mysql_num_rows@plt>
  mov    0x8(%rsp),%rdi
  mov    %rax,%r13
  mov    %eax,0x10(%rsp)
  call   <mysql_free_result@plt>
  test   %r13d,%r13d
  jne    L17
  lea    D9(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <scanf@plt>
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    %r12,%rsi
  lea    0x1(%rax),%edx
  lea    0xa60(%rsp),%rax
  mov    %rax,%rdi
  mov    %rax,0x8(%rsp)
  call   <memcpy@plt>
  xor    %edx,%edx
  mov    $0x1,%ecx
  mov    %r15,0x38(%rsp)
  mov    %r14,0x40(%rsp)
  mov    0x10(%rsp),%r13d
  mov    %rbx,%r15
  mov    %rdx,%r14
  mov    %r12,0x10(%rsp)
  mov    0x8(%rsp),%rbx
  mov    %ecx,%r12d
  jmp    L99
  nopl   0x0(%rax)
L228:
  mov    (%rbx,%r14,4),%eax
  cmp    %eax,(%r15,%r14,4)
  cmovne %r13d,%r12d
  add    $0x1,%r14
L99:
  mov    %r15,%rdi
  call   <strlen@plt>
  cmp    %r14d,%eax
  jg     L228
  mov    %r12d,%ecx
  mov    %r15,%rbx
  mov    0x10(%rsp),%r12
  mov    0x40(%rsp),%r14
  mov    0x38(%rsp),%r15
  test   %ecx,%ecx
  jne    L141
  lea    D343(%rip),%rdi
  call   <puts@plt>
  jmp    L87
  nopl   0x0(%rax,%rax,1)
L17:
  lea    D218(%rip),%rdi
  call   <puts@plt>
  jmp    L87
L259:
  lea    D270(%rip),%rdi
  mov    $0x1,%r12d
  call   <puts@plt>
  jmp    L253
L515:
  lea    D128(%rip),%rdi
  call   <puts@plt>
  mov    0x8(%rsp),%rbx
  mov    %rbx,%rdi
  call   <mysql_fetch_row@plt>
  mov    %rbx,%rdi
  mov    %rax,%r13
  call   <mysql_num_fields@plt>
  lea    D311(%rip),%rdi
  mov    %eax,%ebx
  call   <puts@plt>
  lea    D250(%rip),%rdi
  call   <puts@plt>
  test   %ebx,%ebx
  jle    L503
  movslq %ebx,%rax
  mov    %r12,0x18(%rsp)
  xor    %ebx,%ebx
  mov    %r13,%r12
  mov    %rax,%r13
  nopw   0x0(%rax,%rax,1)
L473:
  mov    (%r12,%rbx,8),%rdx
  mov    %ebx,%esi
  lea    D26(%rip),%rdi
  xor    %eax,%eax
  add    $0x1,%rbx
  call   <printf@plt>
  cmp    %rbx,%r13
  jne    L473
  mov    0x18(%rsp),%r12
L503:
  mov    0x8(%rsp),%rdi
  call   <mysql_free_result@plt>
  jmp    L107
L204:
  lea    D292(%rip),%rdi
  mov    $0x1,%r12d
  call   <puts@plt>
  jmp    L253
L41:
  mov    0x18(%rsp),%rsi
  lea    D259(%rip),%rdi
  xor    %eax,%eax
  mov    $0x2,%r12d
  call   <printf@plt>
  mov    %r15,%rdi
  call   <mysql_close@plt>
  jmp    L253
L141:
  lea    D183(%rip),%rsi
  mov    %r14,%rdi
  xor    %eax,%eax
  mov    0x48(%rsp),%r13
  call   <sprintf@plt>
  mov    %r14,%rsi
  mov    %r15,%rdi
  call   <mysql_query@plt>
  test   %eax,%eax
  jne    L259
  mov    %r15,%rdi
  call   <mysql_store_result@plt>
  mov    %rax,%rdi
  mov    %rax,%r12
  call   <mysql_num_rows@plt>
  mov    %r12,%rdi
  mov    %eax,%ebp
  mov    %rax,0x10(%rsp)
  call   <mysql_free_result@plt>
  mov    %ebp,%esi
  lea    D190(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    0x30(%rsp),%eax
  mov    $0xe10,%ecx
  xor    %edx,%edx
  mov    0x18(%rsp),%r12
  div    %ecx
  mov    %r12,%rdi
  mov    %eax,0x8(%rsp)
  call   <strlen@plt>
  mov    0x8(%rsp),%edx
  mov    %r13,%rdi
  lea    D38(%rip),%rsi
  mov    %eax,%ebp
  xor    %eax,%eax
  call   <sprintf@plt>
  movslq %ebp,%rax
  mov    %r13,%rdx
  lea    D117(%rip),%rsi
  lea    (%r12,%rax,4),%rdi
  lea    0xf0(%rsp),%rbp
  xor    %eax,%eax
  xor    %r13d,%r13d
  call   <sprintf@plt>
  mov    %r12,%rdi
  mov    %rbp,%rsi
  call   <MDString@plt>
  mov    0x28(%rsp),%r12
  lea    D106(%rip),%rcx
L251:
  mov    0x0(%rbp,%r13,4),%edx
  mov    %rcx,%rsi
  mov    %r12,%rdi
  xor    %eax,%eax
  add    $0x1,%r13
  add    $0x8,%r12
  call   <sprintf@plt>
  cmp    $0x10,%r13
  lea    D106(%rip),%rcx
  jne    L251
  movl   $0x0,0x250(%rsp)
  cmpl   $0x0,0x10(%rsp)
  jne    L103
  push   %rax
  mov    %rbx,%r8
  lea    D148(%rip),%rsi
  mov    %r14,%rdi
  push   $0x280de81
  mov    0x18(%rsp),%r9d
  xor    %eax,%eax
  mov    0x38(%rsp),%rcx
  mov    0x30(%rsp),%rdx
  call   <sprintf@plt>
  pop    %rdx
  pop    %rcx
L437:
  mov    %r14,%rsi
  mov    %r15,%rdi
  call   <mysql_query@plt>
  mov    %eax,%r12d
  test   %eax,%eax
  jne    L259
  lea    D349(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    %r15,%rdi
  call   <mysql_close@plt>
  jmp    L253
L103:
  mov    0x8(%rsp),%r9d
  mov    0x28(%rsp),%rcx
  mov    %rbx,%r8
  mov    %r14,%rdi
  mov    0x20(%rsp),%rdx
  lea    D193(%rip),%rsi
  xor    %eax,%eax
  call   <sprintf@plt>
  jmp    L437
L198:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_tag: D267
type_guessed: string
name: retrieve_data
arguments: data_tag: D171
type_guessed: string
name: retrieve_data
arguments: data_tag: D4
type_guessed: string
name: retrieve_data
arguments: data_tag: D253
type_guessed: string
name: retrieve_data
arguments: data_tag: D122
type_guessed: string
name: retrieve_data
arguments: data_tag: D152
type_guessed: string
name: retrieve_data
arguments: data_tag: D42
type_guessed: string
name: retrieve_data
arguments: data_tag: D215
type_guessed: string
name: retrieve_data
arguments: data_tag: D204
type_guessed: string
name: retrieve_data
arguments: data_tag: D99
type_guessed: string
name: retrieve_data
arguments: data_tag: D210
type_guessed: string
name: retrieve_data
arguments: data_tag: D82
type_guessed: string
name: retrieve_data
arguments: data_tag: D334
type_guessed: string
name: retrieve_data
arguments: data_tag: D3
type_guessed: string
name: retrieve_data
arguments: data_tag: D257
type_guessed: string
name: retrieve_data
arguments: data_tag: D32
type_guessed: string
name: retrieve_data
arguments: data_tag: D9
type_guessed: string
name: retrieve_data
arguments: data_tag: D343
type_guessed: string
name: retrieve_data
arguments: data_tag: D218
type_guessed: string
name: retrieve_data
arguments: data_tag: D270
type_guessed: string
name: retrieve_data
arguments: data_tag: D128
type_guessed: string
name: retrieve_data
arguments: data_tag: D311
type_guessed: string
name: retrieve_data
arguments: data_tag: D250
type_guessed: string
name: retrieve_data
arguments: data_tag: D26
type_guessed: string
name: retrieve_data
arguments: data_tag: D292
type_guessed: string
name: retrieve_data
arguments: data_tag: D259
type_guessed: string
name: retrieve_data
arguments: data_tag: D183
type_guessed: string
name: retrieve_data
arguments: data_tag: D190
type_guessed: string
name: retrieve_data
arguments: data_tag: D38
type_guessed: string
name: retrieve_data
arguments: data_tag: D117
type_guessed: string
name: retrieve_data
arguments: data_tag: D106
type_guessed: string
name: retrieve_data
arguments: data_tag: D148
type_guessed: string
name: retrieve_data
arguments: data_tag: D349
type_guessed: string
name: retrieve_data
arguments: data_tag: D193
type_guessed: string

tool: D267: r

tool: D171: tethealla.ini

tool: D4: Tethealla Server Account Addition

tool: D253: %s

tool: D122: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

tool: D152: New account's username: 

tool: D42: SELECT * from account_data WHERE username='%s'

tool: D215: New account's password: 

tool: D204: Verify password: 

tool: D99: The input passwords did not match.

tool: D210: Can't connect to the mysql server (%s) on port %d !
mysql_error = %s


tool: D82: tethealla.ini seems to be corrupted.

tool: D334: Desired account name length should be 16 characters or less.

tool: D3: Desired password length should be 16 characters or less.

tool: D257: New account's e-mail address: 

tool: D32: SELECT * from account_data WHERE email='%s'

tool: D9: Verify e-mail address: 

tool: D343: The input e-mail addresses did not match.

tool: D218: That e-mail address has already been registered to an account.

tool: D270: Couldn't query the MySQL server.

tool: D128: There is already an account by that name on the server.

tool: D311: Row data:

tool: D250: -=-=-=-=-

tool: D26: column %u = %s


tool: D292: The configuration file tethealla.ini appears to be missing.

tool: D259: Can't select the %s database !


tool: D183: SELECT * from account_data

tool: D190: There are %i accounts already registered on the server.


tool: D38: %d

tool: D117: _%s_salt

tool: D106: %02x

tool: D148: INSERT into account_data (username,password,email,regtime,guildcard,isgm,isactive) VALUES ('%s','%s','%s','%u','%u','1','1')

tool: D349: Account successfully added to the database!

tool: D193: INSERT into account_data (username,password,email,regtime,isactive) VALUES ('%s','%s','%s','%u','1')

assistant: ```c
int main(int32_t argc, int8_t *argv[]) {
  int8_t inputstr[255] = {0};
  int8_t username[17];
  int8_t password[34];
  int8_t password_check[17];
  int8_t md5password[34] = {0};
  int8_t email[255];
  int8_t email_check[255];
  uint8_t ch;
  time_t regtime;
  uint32_t reg_seconds;
  uint8_t max_fields;
  MYSQL *myData;
  int8_t myQuery[255] = {0};
  MYSQL_ROW myRow;
  MYSQL_RES *myResult;
  int32_t num_rows, pw_ok, pw_same;
  uint32_t guildcard_number;
  int8_t mySQL_Host[255] = {0};
  int8_t mySQL_Username[255] = {0};
  int8_t mySQL_Password[255] = {0};
  int8_t mySQL_Database[255] = {0};
  uint32_t mySQL_Port;
  int32_t config_index = 0;
  int8_t config_data[255];
  uint8_t MDBuffer[17] = {0};
  FILE *fp;
  if ((fp = fopen("tethealla.ini", "r")) == NULL) {
    printf("The configuration file tethealla.ini appears to be missing.\n");
    return 1;
  } else
    while (fgets(&config_data[0], 255, fp) != NULL) {
      if (config_data[0] != 0x23) {
        if (config_index < 0x04) {
          ch = strlen(&config_data[0]);
          if (config_data[ch - 1] == 0x0A)
            config_data[ch--] = 0x00;
          config_data[ch] = 0;
        }
        switch (config_index) {
        case 0x00:
          memcpy(&mySQL_Host[0], &config_data[0], ch + 1);
          break;
        case 0x01:
          memcpy(&mySQL_Username[0], &config_data[0], ch + 1);
          break;
        case 0x02:
          memcpy(&mySQL_Password[0], &config_data[0], ch + 1);
          break;
        case 0x03:
          memcpy(&mySQL_Database[0], &config_data[0], ch + 1);
          break;
        case 0x04:
          mySQL_Port = atoi(&config_data[0]);
          break;
        default:
          break;
        }
        config_index++;
      }
    }
  fclose(fp);
  if (config_index < 5) {
    printf("tethealla.ini seems to be corrupted.\n");
    return 1;
  }
  if ((myData = mysql_init((MYSQL *)0)) && mysql_real_connect(myData, &mySQL_Host[0], &mySQL_Username[0], &mySQL_Password[0], NULL, mySQL_Port, NULL, 0)) {
    if (mysql_select_db(myData, &mySQL_Database[0]) < 0) {
      printf("Can't select the %s database !\n", mySQL_Database);
      mysql_close(myData);
      return 2;
    }
  } else {
    printf("Can't connect to the mysql server (%s) on port %d !\nmysql_error = %s\n", mySQL_Host, mySQL_Port, mysql_error(myData));
    mysql_close(myData);
    return 1;
  }
  printf("Tethealla Server Account Addition\n");
  printf("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
  pw_ok = 0;
  while (!pw_ok) {
    printf("New account's username: ");
    scanf("%s", inputstr);
    if (strlen(inputstr) < 17) {
      sprintf(&myQuery[0], "SELECT * from account_data WHERE username='%s'", inputstr);
      if (!mysql_query(myData, &myQuery[0])) {
        myResult = mysql_store_result(myData);
        num_rows = (int)mysql_num_rows(myResult);
        if (num_rows) {
          printf("There is already an account by that name on the server.\n");
          myRow = mysql_fetch_row(myResult);
          max_fields = mysql_num_fields(myResult);
          printf("Row data:\n");
          printf("-=-=-=-=-\n");
          for (ch = 0; ch < max_fields; ch++)
            printf("column %u = %s\n", ch, myRow[ch]);
        } else
          pw_ok = 1;
        mysql_free_result(myResult);
      } else {
        printf("Couldn't query the MySQL server.\n");
        return 1;
      }
    } else
      printf("Desired account name length should be 16 characters or less.\n");
  }
  memcpy(&username[0], &inputstr[0], strlen(inputstr) + 1);
  regtime = time(NULL);
  pw_ok = 0;
  while (!pw_ok) {
    printf("New account's password: ");
    scanf("%s", inputstr);
    if ((strlen(inputstr) < 17) || (strlen(inputstr) < 8)) {
      memcpy(&password[0], &inputstr[0], 17);
      printf("Verify password: ");
      scanf("%s", inputstr);
      memcpy(&password_check[0], &inputstr[0], 17);
      pw_same = 1;
      for (ch = 0; ch < 16; ch++) {
        if (password[ch] != password_check[ch])
          pw_same = 0;
      }
      if (pw_same)
        pw_ok = 1;
      else
        printf("The input passwords did not match.\n");
    } else
      printf("Desired password length should be 16 characters or less.\n");
  }
  pw_ok = 0;
  while (!pw_ok) {
    printf("New account's e-mail address: ");
    scanf("%s", inputstr);
    memcpy(&email[0], &inputstr[0], strlen(inputstr) + 1);
    sprintf(&myQuery[0], "SELECT * from account_data WHERE email='%s'", email);
    if (!mysql_query(myData, &myQuery[0])) {
      myResult = mysql_store_result(myData);
      num_rows = (int)mysql_num_rows(myResult);
      mysql_free_result(myResult);
      if (num_rows)
        printf("That e-mail address has already been registered to an account.\n");
    } else {
      printf("Couldn't query the MySQL server.\n");
      return 1;
    }
    if (!num_rows) {
      printf("Verify e-mail address: ");
      scanf("%s", inputstr);
      memcpy(&email_check[0], &inputstr[0], strlen(inputstr) + 1);
      pw_same = 1;
      for (ch = 0; ch < strlen(email); ch++) {
        if (email[ch] != email_check[ch])
          pw_same = 0;
      }
      if (pw_same)
        pw_ok = 1;
      else
        printf("The input e-mail addresses did not match.\n");
    }
  }
  sprintf(&myQuery[0], "SELECT * from account_data");
  if (!mysql_query(myData, &myQuery[0])) {
    myResult = mysql_store_result(myData);
    num_rows = (int)mysql_num_rows(myResult);
    mysql_free_result(myResult);
    printf("There are %i accounts already registered on the server.\n", num_rows);
  } else {
    printf("Couldn't query the MySQL server.\n");
    return 1;
  }
  reg_seconds = (unsigned)regtime / 3600L;
  ch = strlen(&password[0]);
  sprintf(&config_data[0], "%d", reg_seconds);
  sprintf(&password[ch], "_%s_salt", &config_data[0]);
  MDString(&password[0], &MDBuffer[0]);
  for (ch = 0; ch < 16; ch++)
    sprintf(&md5password[ch * 2], "%02x", (uint8_t)MDBuffer[ch]);
  md5password[32] = 0;
  if (!num_rows) {
    guildcard_number = 42000001;
    sprintf(&myQuery[0], "INSERT into account_data (username,password,email,regtime,guildcard,isgm,isactive) VALUES ('%s','%s','%s','%u','%u','1','1')", username, md5password, email, reg_seconds, guildcard_number);
  } else {
    sprintf(&myQuery[0], "INSERT into account_data (username,password,email,regtime,isactive) VALUES ('%s','%s','%s','%u','1')", username, md5password, email, reg_seconds);
  }
  if (!mysql_query(myData, &myQuery[0]))
    printf("Account successfully added to the database!");
  else {
    printf("Couldn't query the MySQL server.\n");
    return 1;
  }
  mysql_close(myData);
  return 0;
}
```