#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*/ Log(int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
scalar_t__ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int amp_asn_flag_done_direct(int fd) {
  if (send(fd, "end\n", strlen("end\n"), 0) < 0) {
    Log(4, "Failed to send asn end flag: %s", strerror(errno));
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<amp_asn_flag_done_direct>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    0xea8(%rip),%rdi
call   1030 <strlen@plt>
mov    -0xc(%rbp),%edi
mov    %eax,%edx
lea    0xe97(%rip),%rsi
xor    %ecx,%ecx
call   1040 <send@plt>
cmp    $0x0,%rax
jge    11a7 <amp_asn_flag_done_direct+0x67>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %eax,%edx
mov    $0x4,%edi
lea    0xe6f(%rip),%rsi
call   1050 <Log@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ae <amp_asn_flag_done_direct+0x6e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<amp_asn_flag_done_direct>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
lea    0xeb3(%rip),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
xor    %ebx,%ebx
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
test   %rax,%rax
jns    1190 <amp_asn_flag_done_direct+0x50>
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe86(%rip),%rsi
mov    $0x4,%edi
mov    %eax,%edx
call   1050 <Log@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"end\0A\00"
@.str.1 = [32 x i8] c"Failed to send asn end flag: %s\00"
@errno = global i32 0
define i32 @amp_asn_flag_done_direct(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = call i64 @send(i32 %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %5, i32 0)
%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.1, i64 0, i64 0), i32 %10)
store i32 -1, i32* %2
br label %13
12: ; preds = %1
store i32 0, i32* %2
br label %13
13: ; preds = %12, %8
%14 = load i32, i32* %2
ret i32 %14
}

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