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

/* Variables and functions */
int Initialize(char *, int /*<<< orphan*/);
int /*<<< orphan*/ LOG_NOTICE;
int /*<<< orphan*/ MainLoop(char *);
int /*<<< orphan*/ SendFileDescriptorAndWait(int);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ unlink(char *);
int iTermFileDescriptorServerRun(char *path, pid_t childPid, int connectionFd) {
  int rc = Initialize(path, childPid);
  if (rc) {
    syslog(LOG_NOTICE, "Initialize failed with code %d", rc);
  } else {
    syslog(LOG_NOTICE,
           "Sending file descriptor and waiting on initial connection");
    if (!SendFileDescriptorAndWait(connectionFd)) {
      MainLoop(path);
    }
  }
  syslog(LOG_NOTICE, "Unlink %s", path);
  unlink(path);
  return 1;
}


x86 assembly (clang, -O0):
<iTermFileDescriptorServerRun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1070 <Initialize@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     119a <iTermFileDescriptorServerRun+0x4a>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe72(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
jmp    11d0 <iTermFileDescriptorServerRun+0x80>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
mov    -0x10(%rbp),%edi
call   1030 <SendFileDescriptorAndWait@plt>
cmp    $0x0,%eax
jne    11cb <iTermFileDescriptorServerRun+0x7b>
mov    -0x8(%rbp),%rdi
call   1050 <MainLoop@plt>
jmp    11d0 <iTermFileDescriptorServerRun+0x80>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
mov    -0x8(%rbp),%rdi
call   1040 <unlink@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iTermFileDescriptorServerRun>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rdi,%rbx
call   1070 <Initialize@plt>
mov    0x2e7b(%rip),%r14
mov    (%r14),%edi
test   %eax,%eax
je     117e <iTermFileDescriptorServerRun+0x2e>
lea    0xe8d(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <syslog@plt>
jmp    119f <iTermFileDescriptorServerRun+0x4f>
lea    0xe9a(%rip),%rsi
xor    %eax,%eax
call   1060 <syslog@plt>
mov    %ebp,%edi
call   1030 <SendFileDescriptorAndWait@plt>
test   %eax,%eax
jne    119f <iTermFileDescriptorServerRun+0x4f>
mov    %rbx,%rdi
call   1050 <MainLoop@plt>
mov    (%r14),%edi
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <syslog@plt>
mov    %rbx,%rdi
call   1040 <unlink@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@LOG_NOTICE = global i32 0
@.str = [31 x i8] c"Initialize failed with code %d\00"
@.str.1 = [58 x i8] c"Sending file descriptor and waiting on initial connection\00"
@.str.2 = [10 x i8] c"Unlink %s\00"
define i32 @iTermFileDescriptorServerRun(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i8*, i8** %4
%9 = load i32, i32* %5
%10 = call i32 @Initialize(i8* %8, i32 %9)
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %3
%14 = load i32, i32* @LOG_NOTICE
%15 = load i32, i32* %7
%16 = call i32 (i32, i8*, ...) @syslog(i32 %14, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %27
17: ; preds = %3
%18 = load i32, i32* @LOG_NOTICE
%19 = call i32 (i32, i8*, ...) @syslog(i32 %18, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* %6
%21 = call i32 @SendFileDescriptorAndWait(i32 %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %17
%24 = load i8*, i8** %4
%25 = call i32 @MainLoop(i8* %24)
br label %26
26: ; preds = %23, %17
br label %27
27: ; preds = %26, %13
%28 = load i32, i32* @LOG_NOTICE
%29 = load i8*, i8** %4
%30 = call i32 (i32, i8*, ...) @syslog(i32 %28, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %29)
%31 = load i8*, i8** %4
%32 = call i32 @unlink(i8* %31)
ret i32 1
}

LLVM IR (-O2):
@LOG_NOTICE = global i32 0
@.str = [31 x i8] c"Initialize failed with code %d\00"
@.str.1 = [58 x i8] c"Sending file descriptor and waiting on initial connection\00"
@.str.2 = [10 x i8] c"Unlink %s\00"
define i32 @iTermFileDescriptorServerRun(i8* %0, i32 %1, i32 %2) {
%4 = tail call i32 @Initialize(i8* %0, i32 %1)
%5 = icmp eq i32 %4, 0
%6 = load i32, i32* @LOG_NOTICE
br i1 %5, label %9, label %7
7: ; preds = %3
%8 = tail call i32 (i32, i8*, ...) @syslog(i32 %6, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %4)
br label %15
9: ; preds = %3
%10 = tail call i32 (i32, i8*, ...) @syslog(i32 %6, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @SendFileDescriptorAndWait(i32 %2)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call i32 @MainLoop(i8* %0)
br label %15
15: ; preds = %9, %13, %7
%16 = load i32, i32* @LOG_NOTICE
%17 = tail call i32 (i32, i8*, ...) @syslog(i32 %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%18 = tail call i32 @unlink(i8* %0)
ret i32 1
}