#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int login();
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ msg_recv(int, char *, int);
int /*<<< orphan*/ msg_send(int, char *, scalar_t__);
int /*<<< orphan*/ stdin;
scalar_t__ strlen(char *);
int main(int argc, char **argv) {
  int fd_socket;
  char buf_send[128];
  char buf_recv[128];
  fd_socket = login();
  while (1) {
    msg_recv(fd_socket, buf_recv, 128);
    memset(buf_send, 0, 128);
    fgets(buf_send, 128 - 1, stdin);
    msg_send(fd_socket, buf_send, strlen(buf_send) + 1);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <login@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    $0x80,%edx
call   1030 <msg_recv@plt>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1050 <memset@plt>
lea    -0xa0(%rbp),%rdi
mov    0x2e30(%rip),%rax
mov    (%rax),%edx
mov    $0x7f,%esi
call   1060 <fgets@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x134(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0x130(%rbp)
lea    -0xa0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x134(%rbp),%edi
mov    -0x130(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x128(%rbp)
call   1080 <msg_send@plt>
jmp    1183 <main+0x23>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
xor    %eax,%eax
call   1070 <login@plt>
mov    %eax,%ebp
mov    %rsp,%r14
lea    0x80(%rsp),%rbx
mov    0x2e60(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x80,%edx
call   1030 <msg_recv@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1050 <memset@plt>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x7f,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <msg_send@plt>
jmp    1190 <main+0x30>

LLVM IR (-O0):
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [128 x i8]
%8 = alloca [128 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (...) @login()
store i32 %9, i32* %6
br label %10
10: ; preds = %2, %10
%11 = load i32, i32* %6
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%13 = call i32 @msg_recv(i32 %11, i8* %12, i32 128)
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%15 = call i32 @memset(i8* %14, i32 0, i32 128)
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%17 = load i32, i32* @stdin
%18 = call i32 @fgets(i8* %16, i32 127, i32 %17)
%19 = load i32, i32* %6
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%22 = call i64 @strlen(i8* %21)
%23 = add nsw i64 %22, 1
%24 = call i32 @msg_send(i32 %19, i8* %20, i64 %23)
br label %10
}

LLVM IR (-O2):
@stdin = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [128 x i8]
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%7 = tail call i32 (...) @login()
br label %8
8: ; preds = %8, %2
%9 = call i32 @msg_recv(i32 %7, i8* %6, i32 128)
%10 = call i32 @memset(i8* %5, i32 0, i32 128)
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %5, i32 127, i32 %11)
%13 = call i64 @strlen(i8* %5)
%14 = add nsw i64 %13, 1
%15 = call i32 @msg_send(i32 %7, i8* %5, i64 %14)
br label %8
}