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


x86 assembly (clang, -O0):
<PerformAcceptActivity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <iTermFileDescriptorServerAccept@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    11b4 <PerformAcceptActivity+0x64>
mov    0x2e61(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,-0x10(%rbp)
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%edx
mov    %eax,%ecx
lea    0xe5d(%rip),%rsi
call   1060 <syslog@plt>
movl   $0x0,-0x4(%rbp)
jmp    11bf <PerformAcceptActivity+0x6f>
mov    -0xc(%rbp),%edi
call   1030 <SendFileDescriptorAndWait@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PerformAcceptActivity>:
push   %rbp
push   %rbx
push   %rax
call   1050 <iTermFileDescriptorServerAccept@plt>
cmp    $0xffffffff,%eax
je     116a <PerformAcceptActivity+0x1a>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <SendFileDescriptorAndWait@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %eax,%ebp
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe6f(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
mov    %eax,%ecx
call   1060 <syslog@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@LOG_DEBUG = global i32 0
@.str = [28 x i8] c"Client(%d) 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 %15
9: ; preds = %1
%10 = load i32, i32* @LOG_DEBUG
%11 = call i32 (...) @getpid()
%12 = load i32, i32* @errno
%13 = call i32 @strerror(i32 %12)
%14 = call i32 @syslog(i32 %10, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %13)
store i32 0, i32* %2
br label %18
15: ; preds = %1
%16 = load i32, i32* %4
%17 = call i32 @SendFileDescriptorAndWait(i32 %16)
store i32 %17, i32* %2
br label %18
18: ; preds = %15, %9
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@LOG_DEBUG = global i32 0
@.str = [28 x i8] c"Client(%d) 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 %10
4: ; preds = %1
%5 = load i32, i32* @LOG_DEBUG
%6 = tail call i32 (...) @getpid()
%7 = load i32, i32* @errno
%8 = tail call i32 @strerror(i32 %7)
%9 = tail call i32 @syslog(i32 %5, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %8)
br label %12
10: ; preds = %1
%11 = tail call i32 @SendFileDescriptorAndWait(i32 %2)
br label %12
12: ; preds = %10, %4
%13 = phi i32 [ 0, %4 ], [ %11, %10 ]
ret i32 %13
}