#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 */
typedef int /*<<< orphan*/ s;

/* Variables and functions */
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
void *sendsocket(void *arg) {
  int st = *(int *)arg;
  char s[1024];
  while (1) {
    memset(s, 0, sizeof(s));
    read(STDIN_FILENO, s, sizeof(s));
    send(st, s, strlen(s), 0);
  }
  return NULL;
}


x86 assembly (clang, -O0):
<sendsocket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1060 <read@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x41c(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x418(%rbp)
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x41c(%rbp),%edi
mov    -0x418(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
jmp    1158 <sendsocket+0x18>

x86 assembly (clang, -O2):
<sendsocket>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    (%rdi),%ebp
mov    %rsp,%rbx
mov    0x2e89(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    (%r14),%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1060 <read@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
jmp    1160 <sendsocket+0x20>

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
define i8* @sendsocket(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [1024 x i8]
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = bitcast i8* %5 to i32*
%7 = load i32, i32* %6
store i32 %7, i32* %3
br label %8
8: ; preds = %1, %8
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%10 = call i32 @memset(i8* %9, i32 0, i32 1024)
%11 = load i32, i32* @STDIN_FILENO
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%13 = call i32 @read(i32 %11, i8* %12, i32 1024)
%14 = load i32, i32* %3
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
%18 = call i32 @send(i32 %14, i8* %15, i32 %17, i32 0)
br label %8
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
define noalias i8* @sendsocket(i8* nocapture %0) {
%2 = alloca [1024 x i8]
%3 = bitcast i8* %0 to i32*
%4 = load i32, i32* %3
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
br label %6
6: ; preds = %6, %1
%7 = call i32 @memset(i8* %5, i32 0, i32 1024)
%8 = load i32, i32* @STDIN_FILENO
%9 = call i32 @read(i32 %8, i8* %5, i32 1024)
%10 = call i32 @strlen(i8* %5)
%11 = call i32 @send(i32 %4, i8* %5, i32 %10, i32 0)
br label %6
}