#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*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
void *threadsend(void *vargp) {
  int connfd = *((int *)vargp);
  int idata;
  char temp[100];
  while (1) {
    if (connfd = *((int *)vargp)) {
      fgets(temp, 100, stdin);
      send(connfd, temp, 100, 0);
    } else {
      close(connfd);
      exit(0);
    }
    return NULL;
  }
}


x86 assembly (clang, -O0):
<threadsend>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
je     1199 <threadsend+0x59>
lea    -0x80(%rbp),%rdi
mov    0x2e73(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1050 <fgets@plt>
mov    -0xc(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
call   1030 <send@plt>
jmp    11a8 <threadsend+0x68>
mov    -0xc(%rbp),%edi
call   1040 <close@plt>
xor    %edi,%edi
call   1060 <exit@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<threadsend>:
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    (%rdi),%ebx
test   %ebx,%ebx
je     1181 <threadsend+0x41>
mov    0x2e94(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x64,%esi
call   1050 <fgets@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
call   1030 <send@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret
xor    %edi,%edi
call   1040 <close@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
define i8* @threadsend(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x i8]
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = bitcast i8* %6 to i32*
%8 = load i32, i32* %7
store i32 %8, i32* %3
br label %9
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = bitcast i8* %10 to i32*
%12 = load i32, i32* %11
store i32 %12, i32* %3
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %9
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%16 = load i32, i32* @stdin
%17 = call i32 @fgets(i8* %15, i32 100, i32 %16)
%18 = load i32, i32* %3
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%20 = call i32 @send(i32 %18, i8* %19, i32 100, i32 0)
br label %25
21: ; preds = %9
%22 = load i32, i32* %3
%23 = call i32 @close(i32 %22)
%24 = call i32 @exit(i32 0)
unreachable
25: ; preds = %14
ret i8* null
}

LLVM IR (-O2):
@stdin = global i32 0
define noalias i8* @threadsend(i8* nocapture %0) {
%2 = alloca [100 x i8]
%3 = bitcast i8* %0 to i32*
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %1
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %4, i32 100, i32 %8)
%10 = call i32 @send(i32 %5, i8* %4, i32 100, i32 0)
ret i8* null
11: ; preds = %1
%12 = tail call i32 @close(i32 0)
%13 = tail call i32 @exit(i32 0)
unreachable
}