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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int listen(int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ unboxTuple(int /*<<< orphan*/ *, int);
scalar_t__ unboxUnsigned(int /*<<< orphan*/);
uint32_t *socketListen(uint32_t context_len, uint32_t *tuple) {
  int sd;
  int n;
  int status;
  sd = (int)unboxUnsigned(unboxTuple(tuple, 0));
  n = (int)unboxUnsigned(unboxTuple(tuple, 1));
  status = listen(sd, n);
  if (-1 == status) {
    perror("listen()");
    exit(1);
  }
  return (uint32_t *)NULL;
}


x86 assembly (clang, -O0):
<socketListen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1040 <unboxTuple@plt>
mov    %eax,%edi
call   1030 <unboxUnsigned@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1040 <unboxTuple@plt>
mov    %eax,%edi
call   1030 <unboxUnsigned@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1050 <listen@plt>
mov    %eax,-0x1c(%rbp)
mov    $0xffffffff,%eax
cmp    -0x1c(%rbp),%eax
jne    11be <socketListen+0x6e>
lea    0xe51(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<socketListen>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rsi,%rdi
xor    %esi,%esi
call   1040 <unboxTuple@plt>
mov    %eax,%edi
call   1030 <unboxUnsigned@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <unboxTuple@plt>
mov    %eax,%edi
call   1030 <unboxUnsigned@plt>
mov    %r14d,%edi
mov    %eax,%esi
call   1050 <listen@plt>
cmp    $0xffffffff,%eax
je     1198 <socketListen+0x48>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe61(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

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

LLVM IR (-O2):
@.str = [9 x i8] c"listen()\00"
define noalias i32* @socketListen(i32 %0, i32* %1) {
%3 = tail call i32 @unboxTuple(i32* %1, i32 0)
%4 = tail call i64 @unboxUnsigned(i32 %3)
%5 = trunc i64 %4 to i32
%6 = tail call i32 @unboxTuple(i32* %1, i32 1)
%7 = tail call i64 @unboxUnsigned(i32 %6)
%8 = trunc i64 %7 to i32
%9 = tail call i32 @listen(i32 %5, i32 %8)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %2
ret i32* null
}