#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_NOTICE;
int SendFileDescriptorAndWait(int);
int /*<<< orphan*/ errno;
int iTermFileDescriptorServerAccept(int);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, int /*<<< orphan*/);
int PerformAcceptActivity(int socketFd) {
  int connectionFd = iTermFileDescriptorServerAccept(socketFd);
  if (connectionFd == -1) {
    syslog(LOG_NOTICE, "accept failed %s", strerror(errno));
    return 0;
  }
  return SendFileDescriptorAndWait(connectionFd);
}


x86 assembly (clang, -O0):
<PerformAcceptActivity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <iTermFileDescriptorServerAccept@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1197 <PerformAcceptActivity+0x57>
mov    0x2e71(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x10(%rbp),%edi
mov    %eax,%edx
lea    0xe7a(%rip),%rsi
call   1050 <syslog@plt>
movl   $0x0,-0x4(%rbp)
jmp    11a2 <PerformAcceptActivity+0x62>
mov    -0xc(%rbp),%edi
call   1030 <SendFileDescriptorAndWait@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PerformAcceptActivity>:
push   %rbx
call   1040 <iTermFileDescriptorServerAccept@plt>
cmp    $0xffffffff,%eax
je     1153 <PerformAcceptActivity+0x13>
mov    %eax,%edi
pop    %rbx
jmp    1030 <SendFileDescriptorAndWait@plt>
mov    0x2e7e(%rip),%rax
mov    (%rax),%ebx
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe8f(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
call   1050 <syslog@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@LOG_NOTICE = global i32 0
@.str = [17 x i8] c"accept failed %s\00"
@errno = global i32 0
define i32 @PerformAcceptActivity(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = call i32 @iTermFileDescriptorServerAccept(i32 %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %14
9: ; preds = %1
%10 = load i32, i32* @LOG_NOTICE
%11 = load i32, i32* @errno
%12 = call i32 @strerror(i32 %11)
%13 = call i32 @syslog(i32 %10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %12)
store i32 0, i32* %2
br label %17
14: ; preds = %1
%15 = load i32, i32* %4
%16 = call i32 @SendFileDescriptorAndWait(i32 %15)
store i32 %16, i32* %2
br label %17
17: ; preds = %14, %9
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
@LOG_NOTICE = global i32 0
@.str = [17 x i8] c"accept failed %s\00"
@errno = global i32 0
define i32 @PerformAcceptActivity(i32 %0) {
%2 = tail call i32 @iTermFileDescriptorServerAccept(i32 %0)
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = load i32, i32* @LOG_NOTICE
%6 = load i32, i32* @errno
%7 = tail call i32 @strerror(i32 %6)
%8 = tail call i32 @syslog(i32 %5, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %11
9: ; preds = %1
%10 = tail call i32 @SendFileDescriptorAndWait(i32 %2)
br label %11
11: ; preds = %9, %4
%12 = phi i32 [ 0, %4 ], [ %10, %9 ]
ret i32 %12
}