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

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ Log(int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ MSG_NOSIGNAL;
int /*<<< orphan*/ errno;
scalar_t__ send(int, void *, int, int /*<<< orphan*/);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int amp_asn_flag_done_local(int fd) {
  uint16_t flag = AF_UNSPEC;
  if (send(fd, (void *)&flag, sizeof(flag), MSG_NOSIGNAL) < 0) {
    Log(4, "Failed to send asn end flag: %s", strerror(errno));
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<amp_asn_flag_done_local>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    0x2ea6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
lea    -0xc(%rbp),%rsi
mov    0x2e7b(%rip),%rax
mov    (%rax),%ecx
mov    $0x4,%edx
call   1030 <send@plt>
cmp    $0x0,%rax
jge    1198 <amp_asn_flag_done_local+0x68>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    %eax,%edx
mov    $0x4,%edi
lea    0xe79(%rip),%rsi
call   1040 <Log@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    119f <amp_asn_flag_done_local+0x6f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<amp_asn_flag_done_local>:
push   %rax
mov    0x2eb0(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%ecx
lea    0x4(%rsp),%rsi
mov    $0x4,%edx
call   1030 <send@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
js     1162 <amp_asn_flag_done_local+0x32>
pop    %rcx
ret
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe89(%rip),%rsi
mov    $0x4,%edi
mov    %eax,%edx
call   1040 <Log@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@AF_UNSPEC = global i32 0
@MSG_NOSIGNAL = global i32 0
@.str = [32 x i8] c"Failed to send asn end flag: %s\00"
@errno = global i32 0
define i32 @amp_asn_flag_done_local(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* @AF_UNSPEC
store i32 %5, i32* %4
%6 = load i32, i32* %3
%7 = bitcast i32* %4 to i8*
%8 = load i32, i32* @MSG_NOSIGNAL
%9 = call i64 @send(i32 %6, i8* %7, i32 4, i32 %8)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %1
%12 = load i32, i32* @errno
%13 = call i32 @strerror(i32 %12)
%14 = call i32 @Log(i32 4, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %13)
store i32 -1, i32* %2
br label %16
15: ; preds = %1
store i32 0, i32* %2
br label %16
16: ; preds = %15, %11
%17 = load i32, i32* %2
ret i32 %17
}

LLVM IR (-O2):
@AF_UNSPEC = global i32 0
@MSG_NOSIGNAL = global i32 0
@.str = [32 x i8] c"Failed to send asn end flag: %s\00"
@errno = global i32 0
define i32 @amp_asn_flag_done_local(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = load i32, i32* @AF_UNSPEC
store i32 %4, i32* %2
%5 = load i32, i32* @MSG_NOSIGNAL
%6 = call i64 @send(i32 %0, i8* %3, i32 4, i32 %5)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i32, i32* @errno
%10 = call i32 @strerror(i32 %9)
%11 = call i32 @Log(i32 4, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %1, %8
%13 = phi i32 [ -1, %8 ], [ 0, %1 ]
ret i32 %13
}