// File: /workspace/github_c_makefile_star2_O0/orestonce[P]udphole/clientA.c
// Function: clientB
void clientB()
{
    int fd ;

    fd = socket(AF_INET, SOCK_DGRAM, 0);
    struct sockaddr_in remoteAddr;
    socklen_t remoteAddrLen = sizeof(struct sockaddr_in);
    char bufferRecive[BUFSIZ]="";
    char bufferSend[BUFSIZ]="Hello , this is a test package.";

    remoteAddr.sin_family = AF_INET;
    int ret ;

    ret = inet_aton(SERVER_ADDR, &remoteAddr.sin_addr);
    assert(ret !=0);

    remoteAddr.sin_port = htons(SERVER_PORT);

    ssize_t sz = sendto(fd, bufferSend, BUFSIZ, 0,
             (struct sockaddr *)&remoteAddr,remoteAddrLen);
    assert(sz >0);

    sz = recvfrom(fd, bufferRecive, BUFSIZ, 0,
                  (struct sockaddr *)&remoteAddr,&remoteAddrLen);

    char ip[BUFSIZ];
    int  port ;

    sscanf(bufferRecive, "%s %d", ip, &port);
    ret = inet_aton( ip, &remoteAddr.sin_addr);
    assert(ret !=0);

    remoteAddr.sin_port = htons(port);

//    strcpy(bufferSend, "Hello , this package is from B.");

//    sz = sendto(fd, bufferSend, BUFSIZ, 0,
//             (struct sockaddr *)&remoteAddr,remoteAddrLen);
    while ( 1 )
    {
        fd_set fds;
        FD_ZERO(&fds);
        FD_SET(STDIN_FILENO, &fds);
        FD_SET(fd, &fds);

        ret = select(fd+1, &fds, 0, 0, 0);

        assert(ret >=0 );

        if ( FD_ISSET(fd, &fds) ) {
            sz = recvfrom(fd, bufferRecive, BUFSIZ, 0,
                  (struct sockaddr *)&remoteAddr,&remoteAddrLen);
            assert(sz >0);
            sz = write(STDIN_FILENO, bufferRecive, sz);
            assert(sz >0);
        }
        if ( FD_ISSET(STDIN_FILENO, &fds) ) {
            sz = read(STDIN_FILENO, &bufferSend, BUFSIZ);
            assert(sz >0);
            sz = sendto(fd, bufferSend, sz , 0,
                   (const struct sockaddr *)&remoteAddr, remoteAddrLen);
            assert(sz >0);
        }
    }
    assert(sz >0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60d0, %rsp           # imm = 0x60D0
movl $0x2, %esi
xorl %edx, %edx
movl %esi, %edi
callq 0x1130
movl %eax, -0x4(%rbp)
movl $0x10, -0x18(%rbp)
leaq -0x2020(%rbp), %rdi
xorl %esi, %esi
movl $0x2000, %edx           # imm = 0x2000
callq 0x1070
leaq -0x4020(%rbp), %rdi
leaq 0x287c(%rip), %rsi      # 0x4080
movl $0x2000, %edx           # imm = 0x2000
callq 0x10a0
movw $0x2, -0x14(%rbp)
leaq -0x14(%rbp), %rsi
addq $0x4, %rsi
leaq 0x81e(%rip), %rdi       # 0x2041
callq 0x10c0
movl %eax, -0x4024(%rbp)
cmpl $0x0, -0x4024(%rbp)
je 0x1839
jmp 0x1858
leaq 0x80b(%rip), %rdi       # 0x204b
leaq 0x7c5(%rip), %rsi       # 0x200c
movl $0x6f, %edx
leaq 0x817(%rip), %rcx       # 0x206a
callq 0x1060
movl $0x6f7, %edi            # imm = 0x6F7
callq 0x1050
movw %ax, -0x12(%rbp)
movl -0x4(%rbp), %edi
leaq -0x4020(%rbp), %rsi
movl -0x18(%rbp), %r9d
movl $0x2000, %edx           # imm = 0x2000
xorl %ecx, %ecx
leaq -0x14(%rbp), %r8
callq 0x1080
movq %rax, -0x4030(%rbp)
cmpq $0x0, -0x4030(%rbp)
jle 0x1897
jmp 0x18b6
leaq 0x79d(%rip), %rdi       # 0x203b
leaq 0x767(%rip), %rsi       # 0x200c
movl $0x75, %edx
leaq 0x7b9(%rip), %rcx       # 0x206a
callq 0x1060
movl -0x4(%rbp), %edi
leaq -0x2020(%rbp), %rsi
movl $0x2000, %edx           # imm = 0x2000
xorl %ecx, %ecx
leaq -0x14(%rbp), %r8
leaq -0x18(%rbp), %r9
callq 0x10e0
movq %rax, -0x4030(%rbp)
leaq -0x2020(%rbp), %rdi
leaq -0x6030(%rbp), %rdx
leaq 0x789(%rip), %rsi       # 0x2079
leaq -0x6034(%rbp), %rcx
movb $0x0, %al
callq 0x10d0
leaq -0x6030(%rbp), %rdi
leaq -0x14(%rbp), %rsi
addq $0x4, %rsi
callq 0x10c0
movl %eax, -0x4024(%rbp)
cmpl $0x0, -0x4024(%rbp)
je 0x1923
jmp 0x1942
leaq 0x721(%rip), %rdi       # 0x204b
leaq 0x6db(%rip), %rsi       # 0x200c
movl $0x7f, %edx
leaq 0x72d(%rip), %rcx       # 0x206a
callq 0x1060
movl -0x6034(%rbp), %eax
movzwl %ax, %edi
callq 0x1050
movw %ax, -0x12(%rbp)
jmp 0x1956
leaq -0x60b8(%rbp), %rax
movq %rax, -0x60c8(%rbp)
movl $0x0, -0x60bc(%rbp)
movl -0x60bc(%rbp), %eax
cmpq $0x10, %rax
jae 0x19a0
movq -0x60c8(%rbp), %rax
movl -0x60bc(%rbp), %ecx
movq $0x0, (%rax,%rcx,8)
movl -0x60bc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60bc(%rbp)
jmp 0x196e
jmp 0x19a2
movq -0x60b8(%rbp), %rax
orq $0x1, %rax
movq %rax, -0x60b8(%rbp)
movl -0x4(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
movl -0x4(%rbp), %eax
movl $0x40, %esi
cltd
idivl %esi
cltq
orq -0x60b8(%rbp,%rax,8), %rcx
movq %rcx, -0x60b8(%rbp,%rax,8)
movl -0x4(%rbp), %edi
addl $0x1, %edi
leaq -0x60b8(%rbp), %rsi
xorl %eax, %eax
movl %eax, %r8d
movq %r8, %rdx
movq %r8, %rcx
callq 0x10b0
movl %eax, -0x4024(%rbp)
cmpl $0x0, -0x4024(%rbp)
jl 0x1a19
jmp 0x1a38
leaq 0x642(%rip), %rdi       # 0x2062
leaq 0x5e5(%rip), %rsi       # 0x200c
movl $0x90, %edx
leaq 0x637(%rip), %rcx       # 0x206a
callq 0x1060
movl -0x4(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
cltq
movq -0x60b8(%rbp,%rax,8), %rax
movq %rax, -0x60d0(%rbp)
movl -0x4(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x60d0(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x1b19
movl -0x4(%rbp), %edi
leaq -0x2020(%rbp), %rsi
movl $0x2000, %edx           # imm = 0x2000
xorl %ecx, %ecx
leaq -0x14(%rbp), %r8
leaq -0x18(%rbp), %r9
callq 0x10e0
movq %rax, -0x4030(%rbp)
cmpq $0x0, -0x4030(%rbp)
jle 0x1ab1
jmp 0x1ad0
leaq 0x583(%rip), %rdi       # 0x203b
leaq 0x54d(%rip), %rsi       # 0x200c
movl $0x95, %edx
leaq 0x59f(%rip), %rcx       # 0x206a
callq 0x1060
leaq -0x2020(%rbp), %rsi
movq -0x4030(%rbp), %rdx
xorl %edi, %edi
callq 0x1030
movq %rax, -0x4030(%rbp)
cmpq $0x0, -0x4030(%rbp)
jle 0x1af8
jmp 0x1b17
leaq 0x53c(%rip), %rdi       # 0x203b
leaq 0x506(%rip), %rsi       # 0x200c
movl $0x97, %edx
leaq 0x558(%rip), %rcx       # 0x206a
callq 0x1060
jmp 0x1b19
movq -0x60b8(%rbp), %rax
andq $0x1, %rax
cmpq $0x0, %rax
je 0x1bc7
xorl %edi, %edi
leaq -0x4020(%rbp), %rsi
movl $0x2000, %edx           # imm = 0x2000
callq 0x1090
movq %rax, -0x4030(%rbp)
cmpq $0x0, -0x4030(%rbp)
jle 0x1b54
jmp 0x1b73
leaq 0x4e0(%rip), %rdi       # 0x203b
leaq 0x4aa(%rip), %rsi       # 0x200c
movl $0x9b, %edx
leaq 0x4fc(%rip), %rcx       # 0x206a
callq 0x1060
movl -0x4(%rbp), %edi
leaq -0x4020(%rbp), %rsi
movq -0x4030(%rbp), %rdx
movl -0x18(%rbp), %r9d
xorl %ecx, %ecx
leaq -0x14(%rbp), %r8
callq 0x1080
movq %rax, -0x4030(%rbp)
cmpq $0x0, -0x4030(%rbp)
jle 0x1ba6
jmp 0x1bc5
leaq 0x48e(%rip), %rdi       # 0x203b
leaq 0x458(%rip), %rsi       # 0x200c
movl $0x9e, %edx
leaq 0x4aa(%rip), %rcx       # 0x206a
callq 0x1060
jmp 0x1bc7
jmp 0x1954