#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_ERR;
int /*<<< orphan*/ close(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
void handleTelNetErrors(int iVal, void *pArg1, void *pArg2) {
  if (iVal != 1)
    syslog(LOG_ERR, "Recieved Telnet error %d, rv = %d", iVal, (int)pArg1);
  else {
    syslog(LOG_ERR, "Quit: Socket Closed");
    close(0);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<handleTelNetErrors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x1,-0x4(%rbp)
je     1172 <handleTelNetErrors+0x42>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    %eax,%ecx
lea    0xe9a(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
jmp    119a <handleTelNetErrors+0x6a>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
xor    %edi,%edi
call   1030 <close@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handleTelNetErrors>:
push   %rax
mov    %edi,%edx
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
cmp    $0x1,%edx
je     1154 <handleTelNetErrors+0x24>
mov    %rsi,%rcx
lea    0xeb5(%rip),%rsi
xor    %eax,%eax
pop    %r8
jmp    1040 <syslog@plt>
lea    0xec7(%rip),%rsi
xor    %eax,%eax
call   1040 <syslog@plt>
xor    %edi,%edi
call   1030 <close@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@LOG_ERR = global i32 0
@.str = [34 x i8] c"Recieved Telnet error %d, rv = %d\00"
@.str.1 = [20 x i8] c"Quit: Socket Closed\00"
define void @handleTelNetErrors(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 1
br i1 %8, label %9, label %15
9: ; preds = %3
%10 = load i32, i32* @LOG_ERR
%11 = load i32, i32* %4
%12 = load i8*, i8** %5
%13 = ptrtoint i8* %12 to i32
%14 = call i32 (i32, i8*, ...) @syslog(i32 %10, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %13)
br label %20
15: ; preds = %3
%16 = load i32, i32* @LOG_ERR
%17 = call i32 (i32, i8*, ...) @syslog(i32 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @close(i32 0)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %9
ret void
}

LLVM IR (-O2):
@LOG_ERR = global i32 0
@.str = [34 x i8] c"Recieved Telnet error %d, rv = %d\00"
@.str.1 = [20 x i8] c"Quit: Socket Closed\00"
define void @handleTelNetErrors(i32 %0, i8* %1, i8* nocapture readnone %2) {
%4 = icmp eq i32 %0, 1
%5 = load i32, i32* @LOG_ERR
br i1 %4, label %10, label %6
6: ; preds = %3
%7 = ptrtoint i8* %1 to i64
%8 = trunc i64 %7 to i32
%9 = tail call i32 (i32, i8*, ...) @syslog(i32 %5, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %8)
ret void
10: ; preds = %3
%11 = tail call i32 (i32, i8*, ...) @syslog(i32 %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @close(i32 0)
%13 = tail call i32 @exit(i32 1)
unreachable
}