// File: /workspace/github_c_makefile_star2_O0/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
subq $0x850, %rsp            # imm = 0x850
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rdi
callq 0x11a0
leaq -0x820(%rbp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x10e0
leaq -0x420(%rbp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x10e0
movl -0x14(%rbp), %edi
leaq -0x420(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x1200
movl %eax, -0x824(%rbp)
movslq -0x824(%rbp), %rax
movb $0x0, -0x420(%rbp,%rax)
leaq -0x420(%rbp), %rsi
movl -0x824(%rbp), %edx
leaq 0x3b74(%rip), %rdi      # 0x5230
movb $0x0, %al
callq 0x1040
movsbl -0x420(%rbp), %eax
cmpl $0x70, %eax
jne 0x16f1
leaq 0x3b7c(%rip), %rdi      # 0x5252
movb $0x0, %al
callq 0x1040
leaq -0x420(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x1970
jmp 0x1941
movsbl -0x420(%rbp), %eax
cmpl $0x63, %eax
jne 0x171f
leaq 0x3b65(%rip), %rdi      # 0x5269
movb $0x0, %al
callq 0x1040
leaq -0x420(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x29f0
jmp 0x193f
movsbl -0x420(%rbp), %eax
cmpl $0x64, %eax
jne 0x174d
leaq 0x3b50(%rip), %rdi      # 0x5282
movb $0x0, %al
callq 0x1040
leaq -0x420(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x2e40
jmp 0x193d
movsbl -0x420(%rbp), %eax
cmpl $0x68, %eax
jne 0x177b
leaq 0x3b3c(%rip), %rdi      # 0x529c
movb $0x0, %al
callq 0x1040
leaq -0x420(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x3180
jmp 0x193b
movsbl -0x420(%rbp), %eax
cmpl $0x75, %eax
jne 0x17a9
leaq 0x3b29(%rip), %rdi      # 0x52b7
movb $0x0, %al
callq 0x1040
leaq -0x420(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x38e0
jmp 0x1939
movsbl -0x420(%rbp), %eax
cmpl $0x67, %eax
jne 0x17d7
leaq 0x3b14(%rip), %rdi      # 0x52d0
movb $0x0, %al
callq 0x1040
leaq -0x420(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x3180
jmp 0x1937
movsbl -0x420(%rbp), %eax
cmpl $0x6f, %eax
jne 0x1805
leaq 0x3b00(%rip), %rdi      # 0x52ea
movb $0x0, %al
callq 0x1040
leaq -0x420(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x3c20
jmp 0x1935
movsbl -0x420(%rbp), %eax
cmpl $0x76, %eax
jne 0x1833
leaq 0x3aeb(%rip), %rdi      # 0x5303
movb $0x0, %al
callq 0x1040
leaq -0x420(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x3f60
jmp 0x1933
movsbl -0x420(%rbp), %eax
cmpl $0x68, %eax
jne 0x189d
leaq 0x3ade(%rip), %rdi      # 0x5324
movb $0x0, %al
callq 0x1040
leaq -0x820(%rbp), %rdi
leaq 0x3ae3(%rip), %rsi      # 0x533e
callq 0x1160
movl -0x14(%rbp), %eax
movl %eax, -0x834(%rbp)
leaq -0x820(%rbp), %rax
movq %rax, -0x830(%rbp)
leaq -0x820(%rbp), %rdi
callq 0x10c0
movl -0x834(%rbp), %edi
movq -0x830(%rbp), %rsi
movq %rax, %rdx
callq 0x10b0
jmp 0x1931
movsbl -0x420(%rbp), %eax
cmpl $0x72, %eax
jne 0x1904
leaq 0x3a98(%rip), %rdi      # 0x5348
movb $0x0, %al
callq 0x1040
leaq -0x820(%rbp), %rdi
leaq 0x3a79(%rip), %rsi      # 0x533e
callq 0x1160
movl -0x14(%rbp), %eax
movl %eax, -0x844(%rbp)
leaq -0x820(%rbp), %rax
movq %rax, -0x840(%rbp)
leaq -0x820(%rbp), %rdi
callq 0x10c0
movl -0x844(%rbp), %edi
movq -0x840(%rbp), %rsi
movq %rax, %rdx
callq 0x10b0
jmp 0x192f
movsbl -0x420(%rbp), %eax
cmpl $0x7a, %eax
jne 0x192d
leaq 0x3a4c(%rip), %rdi      # 0x5363
movb $0x0, %al
callq 0x1040
leaq -0x420(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x4530
jmp 0x192f
jmp 0x1931
jmp 0x1933
jmp 0x1935
jmp 0x1937
jmp 0x1939
jmp 0x193b
jmp 0x193d
jmp 0x193f
jmp 0x1941
movl -0x14(%rbp), %edi
callq 0x12b0
leaq 0x3a2d(%rip), %rdi      # 0x537d
movb $0x0, %al
callq 0x1040
xorl %eax, %eax
addq $0x850, %rsp            # imm = 0x850
popq %rbp
retq
nopw %cs:(%rax,%rax)