// File: /workspace/github_c_makefile_star2_O3/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 0x11a0
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 0x1200
movslq %eax, %rdx
movb $0x0, -0x410(%rbp,%rdx)
leaq 0x2c5e(%rip), %rdi      # 0x4265
movq %r14, %rsi
xorl %eax, %eax
callq 0x1040
movzbl (%r14), %eax
addl $-0x63, %eax
cmpl $0x17, %eax
ja 0x1765
leaq 0x29dc(%rip), %rcx      # 0x4004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x2fc3(%rip), %rdi      # 0x45fb
callq 0x1240
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x206d
jmp 0x1765
leaq 0x2f40(%rip), %rdi      # 0x4597
jmp 0x16fe
leaq 0x2fb0(%rip), %rdi      # 0x4613
callq 0x1240
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x1786
jmp 0x1765
leaq 0x2f60(%rip), %rdi      # 0x45e2
callq 0x1240
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x22c7
jmp 0x1765
leaq 0x2ea4(%rip), %rdi      # 0x4545
callq 0x1240
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 0x1765
leaq 0x2ece(%rip), %rdi      # 0x45b0
callq 0x1240
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x290f
jmp 0x1765
leaq 0x2eca(%rip), %rdi      # 0x45c8
callq 0x1240
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x2438
jmp 0x1765
leaq 0x2e65(%rip), %rdi      # 0x457f
callq 0x1240
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x2abb
jmp 0x1765
leaq 0x2df6(%rip), %rdi      # 0x452c
callq 0x1240
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x2f6e
jmp 0x1765
leaq 0x2e0d(%rip), %rdi      # 0x455f
callq 0x1240
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x2c15
movl %ebx, %edi
callq 0x12c0
leaq 0x2eb6(%rip), %rdi      # 0x4629
callq 0x1240
xorl %eax, %eax
addq $0x800, %rsp            # imm = 0x800
popq %rbx
popq %r14
popq %rbp
retq