// File: /workspace/github_c_makefile_star2_O2/evanwire[P]GitClone/server.c
// Function: pthread_function
void *pthread_function(void *arg) {

    //Get values from the pthread argument
    pthread_arg_t *pthread_arguments = (pthread_arg_t *)arg;
    int connection_fd = pthread_arguments->connection_fd;
    free(arg);


    //Create and initialize buffers to read/write from/to client
    char recvBuff[1024];
    char sendBuff[1024];

    memset(sendBuff, 0, sizeof(sendBuff));
    memset(recvBuff, 0, sizeof(recvBuff));

    //Read message from client
    int n =read(connection_fd, recvBuff, sizeof(recvBuff));
    recvBuff[n] = '\0';
    printf("Message from client: -%s- size %d", recvBuff, n);

    //Handles push requests
    if(recvBuff[0] == 'p'){
        printf("Push request recieved\n");
        push(recvBuff, connection_fd);

    //Handles create requests
    }else if (recvBuff[0] == 'c'){
        printf("Create request recieved\n");
        create(recvBuff, connection_fd);


    //Handles destroy requests
    }else if (recvBuff[0] == 'd'){
        printf("Destroy request recieved\n");
        destroy(recvBuff, connection_fd);

    //Handles checkout requests
    }else if (recvBuff[0] == 'h'){
        printf("Checkout request recieved\n");
        checkout(recvBuff, connection_fd);

    //Handles update requests
    }else if (recvBuff[0] == 'u'){
        printf("Update request recieved\n");
        update(recvBuff, connection_fd);

    //Handles upgrade requests
    }else if (recvBuff[0] == 'g'){
        printf("Upgrade request recieved\n");
        checkout(recvBuff, connection_fd);

    //Handles commit requests
    }else if (recvBuff[0] == 'o'){
        printf("Commit request recieved\n");
        commit(recvBuff, connection_fd);

    //Handles currentversion requests
    }else if (recvBuff[0] == 'v'){
        printf("Currentversion request recieved\n");
        currentVersion(recvBuff, connection_fd);

    //Handles history requests
    }else if (recvBuff[0] == 'h'){
        printf("History request recieved\n");
        strcpy(sendBuff, "test2.txt");
        write(connection_fd, sendBuff, strlen(sendBuff));

    //Handles rollback requests
    }else if (recvBuff[0] == 'r'){
        printf("Rollback request recieved\n");
        strcpy(sendBuff, "test2.txt");
        write(connection_fd, sendBuff, strlen(sendBuff));
    }else if(recvBuff[0] == 'z'){
      printf("Receiving a .Commit file\n");
      recv_commit(recvBuff, connection_fd);
    }

    close(connection_fd);
    printf("\nSTATUS: Client disconnected froms server.\n");
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x800, %rsp            # imm = 0x800
movl (%rdi), %ebx
callq 0x1190
leaq -0x810(%rbp), %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x10d0
leaq -0x410(%rbp), %r14
movl $0x400, %edx            # imm = 0x400
movq %r14, %rdi
xorl %esi, %esi
callq 0x10d0
movl $0x400, %edx            # imm = 0x400
movl %ebx, %edi
movq %r14, %rsi
callq 0x11f0
movslq %eax, %rdx
movb $0x0, -0x410(%rbp,%rdx)
leaq 0x2c84(%rip), %rdi      # 0x4265
movq %r14, %rsi
xorl %eax, %eax
callq 0x1040
movzbl (%r14), %eax
addl $-0x63, %eax
cmpl $0x17, %eax
ja 0x173f
leaq 0x2a02(%rip), %rcx      # 0x4004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x2fe9(%rip), %rdi      # 0x45fb
callq 0x1230
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x1ffe
jmp 0x173f
leaq 0x2f66(%rip), %rdi      # 0x4597
jmp 0x16d8
leaq 0x2fd6(%rip), %rdi      # 0x4613
callq 0x1230
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x1760
jmp 0x173f
leaq 0x2f86(%rip), %rdi      # 0x45e2
callq 0x1230
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x224d
jmp 0x173f
leaq 0x2eca(%rip), %rdi      # 0x4545
callq 0x1230
movabsq $0x78742e3274736574, %rax # imm = 0x78742E3274736574
leaq -0x810(%rbp), %r14
movq %rax, (%r14)
movw $0x74, 0x8(%r14)
movq %r14, %rdi
callq 0x10b0
movl %ebx, %edi
movq %r14, %rsi
movq %rax, %rdx
callq 0x10a0
jmp 0x173f
leaq 0x2ef4(%rip), %rdi      # 0x45b0
callq 0x1230
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x2865
jmp 0x173f
leaq 0x2ef0(%rip), %rdi      # 0x45c8
callq 0x1230
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x23b7
jmp 0x173f
leaq 0x2e8b(%rip), %rdi      # 0x457f
callq 0x1230
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x2a08
jmp 0x173f
leaq 0x2e1c(%rip), %rdi      # 0x452c
callq 0x1230
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x2e51
jmp 0x173f
leaq 0x2e33(%rip), %rdi      # 0x455f
callq 0x1230
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x2b5b
movl %ebx, %edi
callq 0x12b0
leaq 0x2edc(%rip), %rdi      # 0x4629
callq 0x1230
xorl %eax, %eax
addq $0x800, %rsp            # imm = 0x800
popq %rbx
popq %r14
popq %rbp
retq