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

/* Variables and functions */
scalar_t__ listen(int, int);
int /*<<< orphan*/ logging(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ snprintf(char *, int, char *);
int Listen(int sockfd, int max_que_comm_nm) {
  int n;
  if ((n = listen(sockfd, max_que_comm_nm) < 0)) {
    perror("listen");
    return -1;
  }
  char logmsg[128];
  snprintf(logmsg, sizeof(logmsg), "Listening....\n");
  logging("lsrp-router.log", logmsg);
  return n;
}


x86 assembly (clang, -O0):
<Listen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <listen@plt>
cmp    $0x0,%rax
setl   %al
mov    %al,%cl
and    $0x1,%cl
movzbl %cl,%ecx
mov    %ecx,-0x10(%rbp)
test   $0x1,%al
jne    117b <Listen+0x3b>
jmp    1193 <Listen+0x53>
lea    0xe7e(%rip),%rdi
call   1060 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c4 <Listen+0x84>
lea    -0x90(%rbp),%rdi
mov    $0x80,%esi
lea    0xe61(%rip),%rdx
call   1030 <snprintf@plt>
lea    -0x90(%rbp),%rsi
lea    0xe5d(%rip),%rdi
call   1040 <logging@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Listen>:
push   %rbx
sub    $0x80,%rsp
call   1050 <listen@plt>
test   %rax,%rax
js     1183 <Listen+0x43>
lea    0xeae(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1030 <snprintf@plt>
lea    0xea6(%rip),%rdi
mov    %rbx,%rsi
call   1040 <logging@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
ret
lea    0xe76(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%eax
jmp    117a <Listen+0x3a>

LLVM IR (-O0):
@.str = [7 x i8] c"listen\00"
@.str.1 = [15 x i8] c"Listening....\0A\00"
@.str.2 = [16 x i8] c"lsrp-router.log\00"
define i32 @Listen(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [128 x i8]
store i32 %0, i32* %4
store i32 %1, i32* %5
%8 = load i32, i32* %4
%9 = load i32, i32* %5
%10 = call i64 @listen(i32 %8, i32 %9)
%11 = icmp slt i64 %10, 0
%12 = zext i1 %11 to i32
store i32 %12, i32* %6
br i1 %11, label %13, label %15
13: ; preds = %2
%14 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %21
15: ; preds = %2
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%17 = call i32 @snprintf(i8* %16, i32 128, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%19 = call i32 @logging(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = load i32, i32* %6
store i32 %20, i32* %3
br label %21
21: ; preds = %15, %13
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@.str = [7 x i8] c"listen\00"
@.str.1 = [15 x i8] c"Listening....\0A\00"
@.str.2 = [16 x i8] c"lsrp-router.log\00"
define i32 @Listen(i32 %0, i32 %1) {
%3 = alloca [128 x i8]
%4 = tail call i64 @listen(i32 %0, i32 %1)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %12
8: ; preds = %2
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%10 = call i32 @snprintf(i8* %9, i32 128, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @logging(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %9)
br label %12
12: ; preds = %8, %6
%13 = phi i32 [ -1, %6 ], [ 0, %8 ]
ret i32 %13
}