#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*/ string;

/* Variables and functions */
int /*<<< orphan*/ F_SETFL;
int O_NONBLOCK;
size_t Writen(int, char *, size_t);
int /*<<< orphan*/ fcntl(int, int /*<<< orphan*/, int);
scalar_t__ readn(int, char *, int);
size_t sendServer(int fd, char *s_buf, size_t len) {
  char string[256];
  fcntl(fd, F_SETFL, O_NONBLOCK);
  while (readn(fd, string, sizeof(string)) > 0)
    ;
  fcntl(fd, F_SETFL, !O_NONBLOCK);
  return (Writen(fd, s_buf, len));
}


x86 assembly (clang, -O0):
<sendServer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e88(%rip),%rax
mov    (%rax),%esi
mov    0x2e8f(%rip),%rax
mov    (%rax),%edx
call   1030 <fcntl@plt>
mov    -0x4(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    $0x100,%edx
call   1040 <readn@plt>
cmp    $0x0,%rax
jle    1183 <sendServer+0x53>
jmp    1160 <sendServer+0x30>
mov    -0x4(%rbp),%edi
mov    0x2e4b(%rip),%rax
mov    (%rax),%esi
mov    0x2e52(%rip),%rax
cmpl   $0x0,(%rax)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edx
call   1030 <fcntl@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <Writen@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendServer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%ebp
mov    0x2e88(%rip),%r12
mov    (%r12),%esi
mov    0x2e8d(%rip),%r13
mov    0x0(%r13),%edx
call   1030 <fcntl@plt>
mov    %rsp,%rbx
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x100,%edx
call   1040 <readn@plt>
test   %rax,%rax
jg     1170 <sendServer+0x40>
mov    (%r12),%esi
xor    %edx,%edx
cmpl   $0x0,0x0(%r13)
sete   %dl
mov    %ebp,%edi
call   1030 <fcntl@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r14,%rdx
call   1050 <Writen@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
define i64 @sendServer(i32 %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca [256 x i8]
store i32 %0, i32* %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%8 = load i32, i32* %4
%9 = load i32, i32* @F_SETFL
%10 = load i32, i32* @O_NONBLOCK
%11 = call i32 @fcntl(i32 %8, i32 %9, i32 %10)
br label %12
12: ; preds = %17, %3
%13 = load i32, i32* %4
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%15 = call i64 @readn(i32 %13, i8* %14, i32 256)
%16 = icmp sgt i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
br label %12
18: ; preds = %12
%19 = load i32, i32* %4
%20 = load i32, i32* @F_SETFL
%21 = load i32, i32* @O_NONBLOCK
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
%24 = zext i1 %23 to i32
%25 = call i32 @fcntl(i32 %19, i32 %20, i32 %24)
%26 = load i32, i32* %4
%27 = load i8*, i8** %5
%28 = load i64, i64* %6
%29 = call i64 @Writen(i32 %26, i8* %27, i64 %28)
ret i64 %29
}

LLVM IR (-O2):
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
define i64 @sendServer(i32 %0, i8* %1, i64 %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = load i32, i32* @F_SETFL
%7 = load i32, i32* @O_NONBLOCK
%8 = tail call i32 @fcntl(i32 %0, i32 %6, i32 %7)
br label %9
9: ; preds = %9, %3
%10 = call i64 @readn(i32 %0, i8* %5, i32 256)
%11 = icmp sgt i64 %10, 0
br i1 %11, label %9, label %12
12: ; preds = %9
%13 = load i32, i32* @F_SETFL
%14 = load i32, i32* @O_NONBLOCK
%15 = icmp eq i32 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @fcntl(i32 %0, i32 %13, i32 %16)
%18 = call i64 @Writen(i32 %0, i8* %1, i64 %2)
ret i64 %18
}