// File: /workspace/github_c_makefile_star2_O2/Ziddykins[P]Dawn/src/player.c
// Function: init_new_character
void init_new_character(struct Message *message) {
    //Check if user exists
    char out[MAX_MESSAGE_BUFFER];
    char tmp_pwd[] = "temp";

    if (get_pindex(message->sender_nick) != -1) {
        sprintf(out, "PRIVMSG %s :You already have an account!\r\n", dawn->active_room);
        add_msg(out, strlen(out));
        return;
    }

    struct Player np;
    bzero(&np, sizeof np);

    np.pos_x = 0;
    np.pos_y = 1;

    strncpy(np.username, message->sender_nick, MAX_NICK_LENGTH);
    gen_salt(np.salt, 16);
    hash_pwd(np.pwd, np.salt, tmp_pwd);
    strcpy(np.hostmask, message->sender_hostmask);
    strncpy(np.first_class, "None\0", 5);
    strncpy(np.second_class, "None\0", 5);
    strncpy(np.title, "Newbie\0", 7);

    bzero(np.materials, sizeof np.materials);

    np.health       = 100;
    np.fullness     = 100;
    np.alignment    = 0;
    np.alive        = 1;
    np.available    = 1;
    np.level        = 1;
    np.contribution = 0;
    np.max_health   = 100;
    np.max_mana     = 100;
    np.kills        = 0;
    np.deaths       = 0;
    np.gold         = 100;
    np.experience   = 0;
    np.mana         = 100;
    np.strength     = 5;
    np.intelligence = 5;
    np.defense      = 5;
    np.m_def        = 5;
    np.attr_pts     = 1;
    np.available_slots = 23;
    np.available_capacity = 70;
    np.travel_timer.active = 0;
    np.bounty = 0;
    np.auth_level = AL_USER;
    np.max_auth = AL_USER;
    np.cheese = 1;
    memset(np.inventory, 0, sizeof np.inventory);
    //Name, hp, def, int, str, mdef, reqlvl, weight, soc1,2,3, type, mana, rarity
    struct Inventory sword  = {"Wooden Sword", 0, 0, 0, 5, 0, 1, 15, 0, 0, 0, 0, 0, 0, 1};
    struct Inventory shield = {"Wooden Shield", 5, 5, 5, 5, 5, 1, 15, 0, 0, 0, 1, 5, 0, 1};
    //see inventory.h
    sword.bitfield  &= ~(1 << RUSTED);
    sword.bitfield  &= ~(1 << EQUIPPED);
    sword.bitfield  |=  (1 << EQUIPPABLE);
    shield.bitfield &= ~(1 << RUSTED);
    shield.bitfield &= ~(1 << EQUIPPED);
    shield.bitfield |=  (1 << EQUIPPABLE);
    np.inventory[0] = sword;
    np.inventory[1] = shield;

    dawn->players[dawn->player_count] = np;
    dawn->player_count++;

    sprintf(out, "PRIVMSG %s :Account created for user %s@%s, please set your password by sending me "
                    "a private message containing: ;set password <your_password>\r\n", dawn->active_room,
            message->sender_nick, message->sender_hostmask);
    save_players();
    add_msg(out, strlen(out));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2848, %rsp           # imm = 0x2848
movq %rdi, %rbx
movb $0x0, 0xc(%rsp)
movl $0x706d6574, 0x8(%rsp)  # imm = 0x706D6574
callq 0xc860
cmpl $-0x1, %eax
je 0xc97b
leaq 0x13133(%rip), %rax     # 0x1fa80
movl $0x100, %edx            # imm = 0x100
addq (%rax), %rdx
leaq 0x4fdd(%rip), %rsi      # 0x11939
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2050
movq %rbx, %rdi
callq 0x20c0
movq %rbx, %rdi
jmp 0xcbec
leaq 0x1a0(%rsp), %r15
xorl %ebp, %ebp
movl $0x26a8, %edx           # imm = 0x26A8
movq %r15, %rdi
xorl %esi, %esi
callq 0x20f0
pushq $0x1
popq %r14
movl %r14d, 0x25f0(%r15)
leaq 0x108be(%rip), %rax     # 0x1d264
movl (%rax), %edx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x20e0
leaq 0x21f(%rsp), %r15
pushq $0x10
popq %rsi
movq %r15, %rdi
callq 0xc039
leaq 0x22f(%rsp), %r13
leaq 0x8(%rsp), %rdx
movq %r13, %rdi
movq %r15, %rsi
callq 0xc06f
leaq 0x1e0(%rsp), %r12
leaq 0x80(%rbx), %r15
movq %r12, %rdi
movq %r15, %rsi
callq 0x21c0
movl $0x656e6f4e, %eax       # imm = 0x656E6F4E
movl %eax, 0x40(%r13)
movb %bpl, 0x44(%r13)
movl %eax, 0xcf(%r12)
movb %bpl, 0xd3(%r12)
movl $0x6277654e, 0x10f(%r12) # imm = 0x6277654E
movl $0x656962, 0x112(%r12) # imm = 0x656962
xorps %xmm0, %xmm0
movups %xmm0, 0x25b8(%r12)
movups %xmm0, 0x25c8(%r12)
movups %xmm0, 0x25d8(%r12)
movups %xmm0, 0x25e8(%r12)
pushq $0x64
popq %rax
movq %rax, 0x2610(%r12)
movw $0x64, 0x2662(%r12)
movaps 0x9c3f(%rip), %xmm1     # 0x166b0
movups %xmm1, 0x2620(%r12)
movabsq $0x6400000064, %rcx     # imm = 0x6400000064
movq %rcx, 0x2630(%r12)
movups %xmm0, 0x25f8(%r12)
movq %rax, 0x2608(%r12)
andq $0x0, 0x2618(%r12)
movabsq $0x500000005, %rax      # imm = 0x500000005
movq %rax, 0x2648(%r12)
movq $0x5, 0x2650(%r12)
movl %r14d, 0x2658(%r12)
movaps 0x9bed(%rip), %xmm0     # 0x166c0
movups %xmm0, 0x2638(%r12)
andl $0x0, 0x110c(%r12)
andl $0x0, 0x25b4(%r12)
movw $0x101, 0x2660(%r12) # imm = 0x101
movl %r14d, 0x265c(%r12)
leaq 0x330(%rsp), %r13
leaq 0x468(%rsp), %r12
movl $0xe04, %edx            # imm = 0xE04
movq %r12, %rdi
xorl %esi, %esi
callq 0x20f0
leaq 0xa0f1(%rip), %rsi      # 0x16c18
movl $0x98, %edx
movq %r13, %rdi
callq 0x2170
movb $0x9, %r14b
movb %r14b, -0xa0(%r12)
movb %bpl, -0x9d(%r12)
andw $0x0, -0x9f(%r12)
leaq 0x3cc(%rsp), %rdi
leaq 0xa158(%rip), %rsi      # 0x16cb8
movl $0x98, %edx
callq 0x2170
movb %r14b, -0x4(%r12)
movb %bpl, -0x1(%r12)
andw $0x0, -0x3(%r12)
leaq 0x12efe(%rip), %r14     # 0x1fa80
movq (%r14), %rax
movslq 0x148(%rax), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
leaq (%rax,%rcx), %rdi
addq $0x1a0, %rdi            # imm = 0x1A0
movl $0x26a8, %edx           # imm = 0x26A8
leaq 0x1a0(%rsp), %rsi
callq 0x2170
movq (%r14), %rdx
incl 0x148(%rdx)
addq $0x100, %rdx            # imm = 0x100
leaq 0x9b21(%rip), %rsi      # 0x166e8
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0x2050
callq 0xcc06
movq %r14, %rdi
callq 0x20c0
movq %r14, %rdi
movq %rax, %rsi
callq 0xbd04
addq $0x2848, %rsp           # imm = 0x2848
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq