#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*/ uint8_t;
typedef scalar_t__ int16_t;

/* Variables and functions */
scalar_t__ EAGAIN;
scalar_t__ EINTR;
int /*<<< orphan*/ MSG_NOSIGNAL;
scalar_t__ errno;
scalar_t__ send(scalar_t__, int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int16_t attoHTTPSetByte(void *write, uint8_t byte) {
  int16_t ret = 0;
  int16_t sock = *(int16_t *)write;
  while (ret <= 0) {
    ret = send(sock, &byte, 1, MSG_NOSIGNAL);
    if (ret < 0) {
      if ((errno != EINTR) && (errno != EAGAIN)) {
        break;
      }
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<attoHTTPSetByte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jg     11aa <attoHTTPSetByte+0x9a>
mov    -0x20(%rbp),%rdi
mov    0x2e88(%rip),%rax
mov    (%rax),%ecx
lea    -0xc(%rbp),%rsi
mov    $0x1,%edx
call   1030 <send@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jge    11a5 <attoHTTPSetByte+0x95>
mov    0x2e72(%rip),%rax
mov    (%rax),%rax
mov    0x2e60(%rip),%rcx
cmp    (%rcx),%rax
je     11a0 <attoHTTPSetByte+0x90>
mov    0x2e58(%rip),%rax
mov    (%rax),%rax
mov    0x2e2e(%rip),%rcx
cmp    (%rcx),%rax
je     11a0 <attoHTTPSetByte+0x90>
jmp    11aa <attoHTTPSetByte+0x9a>
jmp    11a5 <attoHTTPSetByte+0x95>
jmp    1132 <attoHTTPSetByte+0x22>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<attoHTTPSetByte>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,0x4(%rsp)
mov    (%rdi),%rbx
mov    0x2ea7(%rip),%r15
lea    0x4(%rsp),%r14
mov    0x2eab(%rip),%r12
mov    0x2e9c(%rip),%r13
mov    0x2e7d(%rip),%rbp
jmp    114b <attoHTTPSetByte+0x3b>
cmp    0x0(%rbp),%rcx
jne    116f <attoHTTPSetByte+0x5f>
mov    (%r15),%ecx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <send@plt>
test   %rax,%rax
jns    1149 <attoHTTPSetByte+0x39>
mov    (%r12),%rcx
cmp    0x0(%r13),%rcx
jne    1145 <attoHTTPSetByte+0x35>
jmp    114b <attoHTTPSetByte+0x3b>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@MSG_NOSIGNAL = global i32 0
@errno = global i64 0
@EINTR = global i64 0
@EAGAIN = global i64 0
define i64 @attoHTTPSetByte(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %3
store i32 %1, i32* %4
store i64 0, i64* %5
%7 = load i8*, i8** %3
%8 = bitcast i8* %7 to i64*
%9 = load i64, i64* %8
store i64 %9, i64* %6
br label %10
10: ; preds = %29, %2
%11 = load i64, i64* %5
%12 = icmp sle i64 %11, 0
br i1 %12, label %13, label %30
13: ; preds = %10
%14 = load i64, i64* %6
%15 = load i32, i32* @MSG_NOSIGNAL
%16 = call i64 @send(i64 %14, i32* %4, i32 1, i32 %15)
store i64 %16, i64* %5
%17 = load i64, i64* %5
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %29
19: ; preds = %13
%20 = load i64, i64* @errno
%21 = load i64, i64* @EINTR
%22 = icmp ne i64 %20, %21
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = load i64, i64* @errno
%25 = load i64, i64* @EAGAIN
%26 = icmp ne i64 %24, %25
br i1 %26, label %27, label %28
27: ; preds = %23
br label %30
28: ; preds = %23, %19
br label %29
29: ; preds = %28, %13
br label %10
30: ; preds = %27, %10
%31 = load i64, i64* %5
ret i64 %31
}

LLVM IR (-O2):
@MSG_NOSIGNAL = global i32 0
@errno = global i64 0
@EINTR = global i64 0
@EAGAIN = global i64 0
define i64 @attoHTTPSetByte(i8* nocapture %0, i32 %1) {
%3 = alloca i32
store i32 %1, i32* %3
%4 = bitcast i8* %0 to i64*
%5 = load i64, i64* %4
br label %6
6: ; preds = %19, %2
%7 = load i32, i32* @MSG_NOSIGNAL
%8 = call i64 @send(i64 %5, i32* %3, i32 1, i32 %7)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %6
%11 = load i64, i64* @errno
%12 = load i64, i64* @EINTR
%13 = icmp eq i64 %11, %12
%14 = load i64, i64* @EAGAIN
%15 = icmp eq i64 %11, %14
%16 = select i1 %13, i1 true, i1 %15
br i1 %16, label %19, label %20
17: ; preds = %6
%18 = icmp eq i64 %8, 0
br i1 %18, label %19, label %20
19: ; preds = %17, %10
br label %6
20: ; preds = %10, %17
ret i64 %8
}