#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 listen(int, int);
int /*<<< orphan*/ warn_errno(char *, char *, int);
scalar_t__ zap_bind(int);
int zap_listen(int sock) {
  int rv;
  if (zap_bind(sock)) {
    return 1;
  }
  if (rv = listen(sock, 5)) {
    do {
      if (rv == -1) {
        warn_errno("zap_listen",
                   "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/kennysgithub/zapwireless/"
                   "refs/heads/master/zaplib/zaplib.c",
                   603);
      }
    } while (0);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<zap_listen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <zap_bind@plt>
cmp    $0x0,%rax
je     1159 <zap_listen+0x29>
movl   $0x1,-0x4(%rbp)
jmp    11b1 <zap_listen+0x81>
mov    -0x8(%rbp),%edi
mov    $0x5,%esi
call   1050 <listen@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
je     11aa <zap_listen+0x7a>
jmp    1177 <zap_listen+0x47>
cmpl   $0xffffffff,-0xc(%rbp)
jne    1199 <zap_listen+0x69>
lea    0xe78(%rip),%rdi
lea    0xe7c(%rip),%rsi
mov    $0x25b,%edx
call   1030 <warn_errno@plt>
jmp    119e <zap_listen+0x6e>
movl   $0x1,-0x4(%rbp)
jmp    11b1 <zap_listen+0x81>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zap_listen>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
call   1040 <zap_bind@plt>
mov    $0x1,%ebx
test   %rax,%rax
je     114d <zap_listen+0x1d>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %ebp,%edi
mov    $0x5,%esi
call   1050 <listen@plt>
test   %eax,%eax
je     117c <zap_listen+0x4c>
cmp    $0xffffffff,%eax
jne    1144 <zap_listen+0x14>
lea    0xe97(%rip),%rdi
lea    0xe9b(%rip),%rsi
mov    $0x25b,%edx
call   1030 <warn_errno@plt>
jmp    1144 <zap_listen+0x14>
xor    %ebx,%ebx
jmp    1144 <zap_listen+0x14>

LLVM IR (-O0):
@.str = [11 x i8] c"zap_listen\00"
@.str.1 = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kennysgithub/zapwireless/refs/heads/master/zaplib/zaplib.c\00"
define i32 @zap_listen(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = call i64 @zap_bind(i32 %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 1, i32* %2
br label %22
9: ; preds = %1
%10 = load i32, i32* %3
%11 = call i32 @listen(i32 %10, i32 5)
store i32 %11, i32* %4
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %9
br label %14
14: ; preds = %13
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @warn_errno(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 603)
br label %19
19: ; preds = %17, %14
br label %20
20: ; preds = %19
store i32 1, i32* %2
br label %22
21: ; preds = %9
store i32 0, i32* %2
br label %22
22: ; preds = %21, %20, %8
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
@.str = [11 x i8] c"zap_listen\00"
@.str.1 = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kennysgithub/zapwireless/refs/heads/master/zaplib/zaplib.c\00"
define i32 @zap_listen(i32 %0) {
%2 = tail call i64 @zap_bind(i32 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = tail call i32 @listen(i32 %0, i32 5)
switch i32 %5, label %9 [
i32 0, label %8
i32 -1, label %6
]
6: ; preds = %4
%7 = tail call i32 @warn_errno(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0), i32 603)
br label %9
8: ; preds = %4
br label %9
9: ; preds = %6, %4, %1, %8
%10 = phi i32 [ 0, %8 ], [ 1, %1 ], [ 1, %4 ], [ 1, %6 ]
ret i32 %10
}