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

/* Variables and functions */
scalar_t__ ECONNREFUSED;
int /*<<< orphan*/ MSG_DONTWAIT;
scalar_t__ errno;
int /*<<< orphan*/ error(int, scalar_t__, char *);
int send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
void send_until_errconn(int fd) {
  static char data[1400];
  int ret;
retry:
  ret = send(fd, data, sizeof(data), MSG_DONTWAIT);
  if (ret == sizeof(data)) {
    sleep(1);
    goto retry;
  }
  if (ret != -1)
    error(1, 0, "sendto: expected err");
  if (errno != ECONNREFUSED)
    error(1, errno, "sendto");
}


x86 assembly (clang, -O0):
<send_until_errconn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e8b(%rip),%rax
mov    (%rax),%ecx
lea    0x2f02(%rip),%rsi
mov    $0x578,%edx
call   1030 <send@plt>
mov    %eax,-0x8(%rbp)
movslq -0x8(%rbp),%rax
cmp    $0x578,%rax
jne    117a <send_until_errconn+0x4a>
mov    $0x1,%edi
call   1050 <sleep@plt>
jmp    113b <send_until_errconn+0xb>
cmpl   $0xffffffff,-0x8(%rbp)
je     1199 <send_until_errconn+0x69>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0xe6c(%rip),%rdx
call   1040 <error@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%rax
mov    0x2e3e(%rip),%rcx
cmp    (%rcx),%rax
je     11ce <send_until_errconn+0x9e>
mov    0x2e1e(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xe4c(%rip),%rdx
call   1040 <error@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_until_errconn>:
push   %r15
push   %r14
push   %rbx
mov    %edi,%ebx
mov    0x2e92(%rip),%r15
lea    0x2f0b(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15),%ecx
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x578,%edx
call   1030 <send@plt>
cmp    $0x578,%eax
jne    1175 <send_until_errconn+0x45>
mov    $0x1,%edi
call   1050 <sleep@plt>
jmp    1150 <send_until_errconn+0x20>
cmp    $0xffffffff,%eax
je     118d <send_until_errconn+0x5d>
lea    0xe7f(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <error@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%rsi
mov    0x2e4a(%rip),%rax
cmp    (%rax),%rsi
jne    11a9 <send_until_errconn+0x79>
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe65(%rip),%rdx
mov    $0x1,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <error@plt>

LLVM IR (-O0):
@send_until_errconn.data = internal global [1400 x i8] zeroinitializer
@MSG_DONTWAIT = global i32 0
@.str = [21 x i8] c"sendto: expected err\00"
@errno = global i64 0
@ECONNREFUSED = global i64 0
@.str.1 = [7 x i8] c"sendto\00"
define void @send_until_errconn(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
br label %4
4: ; preds = %11, %1
%5 = load i32, i32* %2
%6 = load i32, i32* @MSG_DONTWAIT
%7 = call i32 @send(i32 %5, i8* getelementptr inbounds ([1400 x i8], [1400 x i8]* @send_until_errconn.data, i64 0, i64 0), i32 1400, i32 %6)
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = icmp eq i64 %9, 1400
br i1 %10, label %11, label %13
11: ; preds = %4
%12 = call i32 @sleep(i32 1)
br label %4
13: ; preds = %4
%14 = load i32, i32* %3
%15 = icmp ne i32 %14, -1
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 @error(i32 1, i64 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
%19 = load i64, i64* @errno
%20 = load i64, i64* @ECONNREFUSED
%21 = icmp ne i64 %19, %20
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i64, i64* @errno
%24 = call i32 @error(i32 1, i64 %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %22, %18
ret void
}

LLVM IR (-O2):
@send_until_errconn.data = internal global [1400 x i8] zeroinitializer
@MSG_DONTWAIT = global i32 0
@.str = [21 x i8] c"sendto: expected err\00"
@errno = global i64 0
@ECONNREFUSED = global i64 0
@.str.1 = [7 x i8] c"sendto\00"
define void @send_until_errconn(i32 %0) {
br label %2
2: ; preds = %5, %1
%3 = load i32, i32* @MSG_DONTWAIT
%4 = tail call i32 @send(i32 %0, i8* getelementptr inbounds ([1400 x i8], [1400 x i8]* @send_until_errconn.data, i64 0, i64 0), i32 1400, i32 %3)
switch i32 %4, label %7 [
i32 1400, label %5
i32 -1, label %9
]
5: ; preds = %2
%6 = tail call i32 @sleep(i32 1)
br label %2
7: ; preds = %2
%8 = tail call i32 @error(i32 1, i64 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %2, %7
%10 = load i64, i64* @errno
%11 = load i64, i64* @ECONNREFUSED
%12 = icmp eq i64 %10, %11
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = tail call i32 @error(i32 1, i64 %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %9
ret void
}