// File: /workspace/github_c_makefile_star2_O1/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 0x2c6f(%rip), %rdi      # 0x4265
movq %r14, %rsi
xorl %eax, %eax
callq 0x1040
movzbl (%r14), %eax
addl $-0x63, %eax
cmpl $0x17, %eax
ja 0x1754
leaq 0x29ed(%rip), %rcx      # 0x4004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x2fd7(%rip), %rdi      # 0x45fe
callq 0x1230
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x2086
jmp 0x1754
leaq 0x2f54(%rip), %rdi      # 0x459a
jmp 0x16ed
leaq 0x2fc4(%rip), %rdi      # 0x4616
callq 0x1230
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x1775
jmp 0x1754
leaq 0x2f74(%rip), %rdi      # 0x45e5
callq 0x1230
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x22e0
jmp 0x1754
leaq 0x2eb8(%rip), %rdi      # 0x4548
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 0x1754
leaq 0x2ee2(%rip), %rdi      # 0x45b3
callq 0x1230
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x2928
jmp 0x1754
leaq 0x2ede(%rip), %rdi      # 0x45cb
callq 0x1230
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x2451
jmp 0x1754
leaq 0x2e79(%rip), %rdi      # 0x4582
callq 0x1230
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x2ad4
jmp 0x1754
leaq 0x2e0a(%rip), %rdi      # 0x452f
callq 0x1230
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x2f57
jmp 0x1754
leaq 0x2e21(%rip), %rdi      # 0x4562
callq 0x1230
leaq -0x410(%rbp), %rdi
movl %ebx, %esi
callq 0x2c2e
movl %ebx, %edi
callq 0x12b0
leaq 0x2eca(%rip), %rdi      # 0x462c
callq 0x1230
xorl %eax, %eax
addq $0x800, %rsp            # imm = 0x800
popq %rbx
popq %r14
popq %rbp
retq