#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*/ Sys_failure(char *);
int atoi(char *);
char *getenv(char *);
int listen(int, int);
void Listen(int s, int backlog) {
  char *p;
  int retval;
  int n;
  p = getenv("LISTENQ");
  n = (p != NULL) ? atoi(p) : backlog;
  retval = listen(s, n);
  if (retval == -1)
    Sys_failure("listen");
}


x86 assembly (clang, -O0):
<Listen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    0xeab(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117a <Listen+0x3a>
mov    -0x10(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x1c(%rbp)
jmp    1180 <Listen+0x40>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <listen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11aa <Listen+0x6a>
lea    0xe63(%rip),%rdi
call   1050 <Sys_failure@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Listen>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
lea    0xeb2(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1162 <Listen+0x22>
mov    %rax,%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %ebp,%esi
call   1040 <listen@plt>
cmp    $0xffffffff,%eax
je     1177 <Listen+0x37>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe8a(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <Sys_failure@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"LISTENQ\00"
@.str.1 = [7 x i8] c"listen\00"
define void @Listen(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = call i32 @atoi(i8* %12)
br label %16
14: ; preds = %2
%15 = load i32, i32* %4
br label %16
16: ; preds = %14, %11
%17 = phi i32 [ %13, %11 ], [ %15, %14 ]
store i32 %17, i32* %7
%18 = load i32, i32* %3
%19 = load i32, i32* %7
%20 = call i32 @listen(i32 %18, i32 %19)
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %25
23: ; preds = %16
%24 = call i32 @Sys_failure(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %23, %16
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"LISTENQ\00"
@.str.1 = [7 x i8] c"listen\00"
define void @Listen(i32 %0, i32 %1) {
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @atoi(i8* %3)
br label %7
7: ; preds = %2, %5
%8 = phi i32 [ %6, %5 ], [ %1, %2 ]
%9 = tail call i32 @listen(i32 %0, i32 %8)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 @Sys_failure(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %7
ret void
}