#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 /*<<< orphan*/ PerformAcceptActivity(int);
int /*<<< orphan*/ getpid();
int iTermFileDescriptorServerSocketBindListen(char *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, int /*<<< orphan*/);
void MainLoop(char *path) {
  syslog(LOG_DEBUG,
         "Client(%d) "
         "Entering main loop.",
         getpid());
  int socketFd;
  do {
    syslog(LOG_DEBUG,
           "Client(%d) "
           "Calling iTermFileDescriptorServerSocketBindListen.",
           getpid());
    socketFd = iTermFileDescriptorServerSocketBindListen(path);
    if (socketFd < 0) {
      syslog(LOG_DEBUG,
             "Client(%d) "
             "iTermFileDescriptorServerSocketBindListen failed",
             getpid());
      return;
    }
    syslog(LOG_DEBUG,
           "Client(%d) "
           "Calling PerformAcceptActivity",
           getpid());
  } while (!PerformAcceptActivity(socketFd));
}


x86 assembly (clang, -O0):
<MainLoop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e8d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x10(%rbp),%edi
mov    %eax,%edx
lea    0xe95(%rip),%rsi
call   1060 <syslog@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x14(%rbp),%edi
mov    %eax,%edx
lea    0xe90(%rip),%rsi
call   1060 <syslog@plt>
mov    -0x8(%rbp),%rdi
call   1050 <iTermFileDescriptorServerSocketBindListen@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11d3 <MainLoop+0x93>
mov    0x2e2f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x18(%rbp),%edi
mov    %eax,%edx
lea    0xe94(%rip),%rsi
call   1060 <syslog@plt>
jmp    120f <MainLoop+0xcf>
mov    0x2e06(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%edx
lea    0xea7(%rip),%rsi
call   1060 <syslog@plt>
mov    -0xc(%rbp),%edi
call   1030 <PerformAcceptActivity@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1170 <MainLoop+0x30>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MainLoop>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
mov    0x2e8b(%rip),%r13
mov    0x0(%r13),%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe99(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
call   1060 <syslog@plt>
lea    0xea8(%rip),%r14
lea    0xf1b(%rip),%r15
xchg   %ax,%ax
mov    0x0(%r13),%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1060 <syslog@plt>
mov    %r12,%rdi
call   1050 <iTermFileDescriptorServerSocketBindListen@plt>
mov    %eax,%ebp
mov    0x0(%r13),%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
test   %ebp,%ebp
js     11d6 <MainLoop+0x96>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1060 <syslog@plt>
mov    %ebp,%edi
call   1030 <PerformAcceptActivity@plt>
test   %eax,%eax
je     1180 <MainLoop+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe80(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <syslog@plt>

LLVM IR (-O0):
@LOG_DEBUG = global i32 0
@.str = [31 x i8] c"Client(%d) Entering main loop.\00"
@.str.1 = [62 x i8] c"Client(%d) Calling iTermFileDescriptorServerSocketBindListen.\00"
@.str.2 = [60 x i8] c"Client(%d) iTermFileDescriptorServerSocketBindListen failed\00"
@.str.3 = [41 x i8] c"Client(%d) Calling PerformAcceptActivity\00"
define void @MainLoop(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i32, i32* @LOG_DEBUG
%5 = call i32 (...) @getpid()
%6 = call i32 @syslog(i32 %4, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %7
7: ; preds = %23, %1
%8 = load i32, i32* @LOG_DEBUG
%9 = call i32 (...) @getpid()
%10 = call i32 @syslog(i32 %8, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = load i8*, i8** %2
%12 = call i32 @iTermFileDescriptorServerSocketBindListen(i8* %11)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %7
%16 = load i32, i32* @LOG_DEBUG
%17 = call i32 (...) @getpid()
%18 = call i32 @syslog(i32 %16, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0), i32 %17)
br label %28
19: ; preds = %7
%20 = load i32, i32* @LOG_DEBUG
%21 = call i32 (...) @getpid()
%22 = call i32 @syslog(i32 %20, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %19
%24 = load i32, i32* %3
%25 = call i32 @PerformAcceptActivity(i32 %24)
%26 = icmp ne i32 %25, 0
%27 = xor i1 %26, true
br i1 %27, label %7, label %28
28: ; preds = %15, %23
ret void
}

LLVM IR (-O2):
@LOG_DEBUG = global i32 0
@.str = [31 x i8] c"Client(%d) Entering main loop.\00"
@.str.1 = [62 x i8] c"Client(%d) Calling iTermFileDescriptorServerSocketBindListen.\00"
@.str.2 = [60 x i8] c"Client(%d) iTermFileDescriptorServerSocketBindListen failed\00"
@.str.3 = [41 x i8] c"Client(%d) Calling PerformAcceptActivity\00"
define void @MainLoop(i8* %0) {
%2 = load i32, i32* @LOG_DEBUG
%3 = tail call i32 (...) @getpid()
%4 = tail call i32 @syslog(i32 %2, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %3)
br label %5
5: ; preds = %15, %1
%6 = load i32, i32* @LOG_DEBUG
%7 = tail call i32 (...) @getpid()
%8 = tail call i32 @syslog(i32 %6, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = tail call i32 @iTermFileDescriptorServerSocketBindListen(i8* %0)
%10 = icmp slt i32 %9, 0
%11 = load i32, i32* @LOG_DEBUG
%12 = tail call i32 (...) @getpid()
br i1 %10, label %13, label %15
13: ; preds = %5
%14 = tail call i32 @syslog(i32 %11, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0), i32 %12)
br label %19
15: ; preds = %5
%16 = tail call i32 @syslog(i32 %11, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%17 = tail call i32 @PerformAcceptActivity(i32 %9)
%18 = icmp eq i32 %17, 0
br i1 %18, label %5, label %19
19: ; preds = %15, %13
ret void
}