#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*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
scalar_t__ listen(int, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ socket_get_backlog(int, int *, char const *, char const *, char *);
int /*<<< orphan*/ warn(char *, char const *, char const *, ...);
int /*<<< orphan*/ warnx(char *, char const *, char const *, int, int);
int socket_listen_update(int domain, int type, int protocol, int backlog,
                         int update_backlog, int listen_backlog_assertion,
                         int update_backlog_assertion, int *sockp,
                         const char *domainstring, const char *typestring,
                         const char *testclass, const char *test) {
  int backlog_retrieved, sock;
  sock = socket(PF_INET, SOCK_STREAM, 0);
  if (sock < 0) {
    warn("%s: %s: socket_listen_update: socket(%s, %s)", testclass, test,
         domainstring, typestring);
    return (-1);
  }
  if (listen(sock, backlog) < 0) {
    warn("%s: %s: socket_listen_update: initial listen(, %d)", testclass, test,
         backlog);
    close(sock);
    return (-1);
  }
  if (socket_get_backlog(sock, &backlog_retrieved, testclass, test,
                         "socket_listen_update") < 0) {
    close(sock);
    return (-1);
  }
  if (backlog_retrieved != listen_backlog_assertion) {
    warnx("%s: %s: socket_listen_update: initial backlog is %d "
          "not %d",
          testclass, test, backlog_retrieved, listen_backlog_assertion);
    close(sock);
    return (-1);
  }
  if (listen(sock, update_backlog) < 0) {
    warn("%s: %s: socket_listen_update: update listen(, %d)", testclass, test,
         update_backlog);
    close(sock);
    return (-1);
  }
  if (socket_get_backlog(sock, &backlog_retrieved, testclass, test,
                         "socket_listen_update") < 0) {
    close(sock);
    return (-1);
  }
  if (backlog_retrieved != update_backlog_assertion) {
    warnx("%s: %s: socket_listen_update: updated backlog is %d "
          "not %d",
          testclass, test, backlog_retrieved, update_backlog_assertion);
    close(sock);
    return (-1);
  }
  *sockp = sock;
  return (0);
}


x86 assembly (clang, -O0):
<socket_listen_update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
mov    0x2e3d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1080 <socket@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    11e3 <socket_listen_update+0x83>
mov    0x30(%rbp),%rsi
mov    0x38(%rbp),%rdx
mov    0x20(%rbp),%rcx
mov    0x28(%rbp),%r8
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <warn@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    135f <socket_listen_update+0x1ff>
mov    -0x24(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1070 <listen@plt>
cmp    $0x0,%rax
jge    1225 <socket_listen_update+0xc5>
mov    0x30(%rbp),%rsi
mov    0x38(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <warn@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    135f <socket_listen_update+0x1ff>
mov    -0x24(%rbp),%edi
mov    0x30(%rbp),%rdx
mov    0x38(%rbp),%rcx
lea    -0x20(%rbp),%rsi
lea    0xe25(%rip),%r8
call   1040 <socket_get_backlog@plt>
cmp    $0x0,%rax
jge    125e <socket_listen_update+0xfe>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    135f <socket_listen_update+0x1ff>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     1299 <socket_listen_update+0x139>
mov    0x30(%rbp),%rsi
mov    0x38(%rbp),%rdx
mov    -0x20(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
lea    0xdf5(%rip),%rdi
call   1050 <warnx@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    135f <socket_listen_update+0x1ff>
mov    -0x24(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1070 <listen@plt>
cmp    $0x0,%rax
jge    12db <socket_listen_update+0x17b>
mov    0x30(%rbp),%rsi
mov    0x38(%rbp),%rdx
mov    -0x18(%rbp),%ecx
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1030 <warn@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    135f <socket_listen_update+0x1ff>
mov    -0x24(%rbp),%edi
mov    0x30(%rbp),%rdx
mov    0x38(%rbp),%rcx
lea    -0x20(%rbp),%rsi
lea    0xd6f(%rip),%r8
call   1040 <socket_get_backlog@plt>
cmp    $0x0,%rax
jge    1314 <socket_listen_update+0x1b4>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    135f <socket_listen_update+0x1ff>
mov    -0x20(%rbp),%eax
cmp    0x10(%rbp),%eax
je     134f <socket_listen_update+0x1ef>
mov    0x30(%rbp),%rsi
mov    0x38(%rbp),%rdx
mov    -0x20(%rbp),%ecx
mov    0x10(%rbp),%r8d
lea    0xdac(%rip),%rdi
call   1050 <warnx@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    135f <socket_listen_update+0x1ff>
mov    -0x24(%rbp),%ecx
mov    0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<socket_listen_update>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r13d
mov    %r8d,%r12d
mov    %ecx,%ebp
mov    0x68(%rsp),%r14
mov    0x60(%rsp),%r15
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
mov    0x2e53(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1080 <socket@plt>
test   %eax,%eax
js     122f <socket_listen_update+0xcf>
mov    %eax,%ebx
mov    %eax,%edi
mov    %ebp,%esi
call   1070 <listen@plt>
test   %rax,%rax
js     124f <socket_listen_update+0xef>
lea    0xea7(%rip),%r8
lea    0x4(%rsp),%rsi
mov    %ebx,%edi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <socket_get_backlog@plt>
test   %rax,%rax
js     127c <socket_listen_update+0x11c>
mov    0x4(%rsp),%ecx
cmp    %r13d,%ecx
jne    1267 <socket_listen_update+0x107>
mov    %ebx,%edi
mov    %r12d,%esi
call   1070 <listen@plt>
test   %rax,%rax
js     1297 <socket_listen_update+0x137>
lea    0xe65(%rip),%r8
lea    0x4(%rsp),%rsi
mov    %ebx,%edi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <socket_get_backlog@plt>
test   %rax,%rax
js     127c <socket_listen_update+0x11c>
mov    0x40(%rsp),%r8d
mov    0x4(%rsp),%ecx
cmp    %r8d,%ecx
jne    12a9 <socket_listen_update+0x149>
mov    0x48(%rsp),%rax
mov    %ebx,(%rax)
xor    %eax,%eax
jmp    1288 <socket_listen_update+0x128>
mov    0x58(%rsp),%r8
mov    0x50(%rsp),%rcx
lea    0xdc0(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <warn@plt>
jmp    1283 <socket_listen_update+0x123>
lea    0xdd7(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1030 <warn@plt>
jmp    127c <socket_listen_update+0x11c>
lea    0xe07(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %r13d,%r8d
call   1050 <warnx@plt>
mov    %ebx,%edi
call   1060 <close@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe12(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %r12d,%ecx
jmp    125e <socket_listen_update+0xfe>
lea    0xe32(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
jmp    1277 <socket_listen_update+0x117>

LLVM IR (-O0):
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [45 x i8] c"%s: %s: socket_listen_update: socket(%s, %s)\00"
@.str.1 = [51 x i8] c"%s: %s: socket_listen_update: initial listen(, %d)\00"
@.str.2 = [21 x i8] c"socket_listen_update\00"
@.str.3 = [59 x i8] c"%s: %s: socket_listen_update: initial backlog is %d not %d\00"
@.str.4 = [50 x i8] c"%s: %s: socket_listen_update: update listen(, %d)\00"
@.str.5 = [59 x i8] c"%s: %s: socket_listen_update: updated backlog is %d not %d\00"
define i32 @socket_listen_update(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32* %7, i8* %8, i8* %9, i8* %10, i8* %11) {
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32*
%22 = alloca i8*
%23 = alloca i8*
%24 = alloca i8*
%25 = alloca i8*
%26 = alloca i32
%27 = alloca i32
store i32 %0, i32* %14
store i32 %1, i32* %15
store i32 %2, i32* %16
store i32 %3, i32* %17
store i32 %4, i32* %18
store i32 %5, i32* %19
store i32 %6, i32* %20
store i32* %7, i32** %21
store i8* %8, i8** %22
store i8* %9, i8** %23
store i8* %10, i8** %24
store i8* %11, i8** %25
%28 = load i32, i32* @PF_INET
%29 = load i32, i32* @SOCK_STREAM
%30 = call i32 @socket(i32 %28, i32 %29, i32 0)
store i32 %30, i32* %27
%31 = load i32, i32* %27
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %12
%34 = load i8*, i8** %24
%35 = load i8*, i8** %25
%36 = load i8*, i8** %22
%37 = load i8*, i8** %23
%38 = call i32 (i8*, i8*, i8*, ...) @warn(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %34, i8* %35, i8* %36, i8* %37)
store i32 -1, i32* %13
br label %108
39: ; preds = %12
%40 = load i32, i32* %27
%41 = load i32, i32* %17
%42 = call i64 @listen(i32 %40, i32 %41)
%43 = icmp slt i64 %42, 0
br i1 %43, label %44, label %51
44: ; preds = %39
%45 = load i8*, i8** %24
%46 = load i8*, i8** %25
%47 = load i32, i32* %17
%48 = call i32 (i8*, i8*, i8*, ...) @warn(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8* %45, i8* %46, i32 %47)
%49 = load i32, i32* %27
%50 = call i32 @close(i32 %49)
store i32 -1, i32* %13
br label %108
51: ; preds = %39
%52 = load i32, i32* %27
%53 = load i8*, i8** %24
%54 = load i8*, i8** %25
%55 = call i64 @socket_get_backlog(i32 %52, i32* %26, i8* %53, i8* %54, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%56 = icmp slt i64 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %51
%58 = load i32, i32* %27
%59 = call i32 @close(i32 %58)
store i32 -1, i32* %13
br label %108
60: ; preds = %51
%61 = load i32, i32* %26
%62 = load i32, i32* %19
%63 = icmp ne i32 %61, %62
br i1 %63, label %64, label %72
64: ; preds = %60
%65 = load i8*, i8** %24
%66 = load i8*, i8** %25
%67 = load i32, i32* %26
%68 = load i32, i32* %19
%69 = call i32 @warnx(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0), i8* %65, i8* %66, i32 %67, i32 %68)
%70 = load i32, i32* %27
%71 = call i32 @close(i32 %70)
store i32 -1, i32* %13
br label %108
72: ; preds = %60
%73 = load i32, i32* %27
%74 = load i32, i32* %18
%75 = call i64 @listen(i32 %73, i32 %74)
%76 = icmp slt i64 %75, 0
br i1 %76, label %77, label %84
77: ; preds = %72
%78 = load i8*, i8** %24
%79 = load i8*, i8** %25
%80 = load i32, i32* %18
%81 = call i32 (i8*, i8*, i8*, ...) @warn(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i8* %78, i8* %79, i32 %80)
%82 = load i32, i32* %27
%83 = call i32 @close(i32 %82)
store i32 -1, i32* %13
br label %108
84: ; preds = %72
%85 = load i32, i32* %27
%86 = load i8*, i8** %24
%87 = load i8*, i8** %25
%88 = call i64 @socket_get_backlog(i32 %85, i32* %26, i8* %86, i8* %87, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%89 = icmp slt i64 %88, 0
br i1 %89, label %90, label %93
90: ; preds = %84
%91 = load i32, i32* %27
%92 = call i32 @close(i32 %91)
store i32 -1, i32* %13
br label %108
93: ; preds = %84
%94 = load i32, i32* %26
%95 = load i32, i32* %20
%96 = icmp ne i32 %94, %95
br i1 %96, label %97, label %105
97: ; preds = %93
%98 = load i8*, i8** %24
%99 = load i8*, i8** %25
%100 = load i32, i32* %26
%101 = load i32, i32* %20
%102 = call i32 @warnx(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0), i8* %98, i8* %99, i32 %100, i32 %101)
%103 = load i32, i32* %27
%104 = call i32 @close(i32 %103)
store i32 -1, i32* %13
br label %108
105: ; preds = %93
%106 = load i32, i32* %27
%107 = load i32*, i32** %21
store i32 %106, i32* %107
store i32 0, i32* %13
br label %108
108: ; preds = %105, %97, %90, %77, %64, %57, %44, %33
%109 = load i32, i32* %13
ret i32 %109
}

LLVM IR (-O2):
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [45 x i8] c"%s: %s: socket_listen_update: socket(%s, %s)\00"
@.str.1 = [51 x i8] c"%s: %s: socket_listen_update: initial listen(, %d)\00"
@.str.2 = [21 x i8] c"socket_listen_update\00"
@.str.3 = [59 x i8] c"%s: %s: socket_listen_update: initial backlog is %d not %d\00"
@.str.4 = [50 x i8] c"%s: %s: socket_listen_update: update listen(, %d)\00"
@.str.5 = [59 x i8] c"%s: %s: socket_listen_update: updated backlog is %d not %d\00"
define i32 @socket_listen_update(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32* nocapture writeonly %7, i8* %8, i8* %9, i8* %10, i8* %11) {
%13 = alloca i32
%14 = bitcast i32* %13 to i8*
%15 = load i32, i32* @PF_INET
%16 = load i32, i32* @SOCK_STREAM
%17 = tail call i32 @socket(i32 %15, i32 %16, i32 0)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = tail call i32 (i8*, i8*, i8*, ...) @warn(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11, i8* %8, i8* %9)
br label %56
21: ; preds = %12
%22 = tail call i64 @listen(i32 %17, i32 %3)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = tail call i32 (i8*, i8*, i8*, ...) @warn(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8* %10, i8* %11, i32 %3)
%26 = tail call i32 @close(i32 %17)
br label %56
27: ; preds = %21
%28 = call i64 @socket_get_backlog(i32 %17, i32* %13, i8* %10, i8* %11, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @close(i32 %17)
br label %56
32: ; preds = %27
%33 = load i32, i32* %13
%34 = icmp eq i32 %33, %5
br i1 %34, label %38, label %35
35: ; preds = %32
%36 = call i32 @warnx(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0), i8* %10, i8* %11, i32 %33, i32 %5)
%37 = call i32 @close(i32 %17)
br label %56
38: ; preds = %32
%39 = call i64 @listen(i32 %17, i32 %4)
%40 = icmp slt i64 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = call i32 (i8*, i8*, i8*, ...) @warn(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i8* %10, i8* %11, i32 %4)
%43 = call i32 @close(i32 %17)
br label %56
44: ; preds = %38
%45 = call i64 @socket_get_backlog(i32 %17, i32* %13, i8* %10, i8* %11, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%46 = icmp slt i64 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 @close(i32 %17)
br label %56
49: ; preds = %44
%50 = load i32, i32* %13
%51 = icmp eq i32 %50, %6
br i1 %51, label %55, label %52
52: ; preds = %49
%53 = call i32 @warnx(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0), i8* %10, i8* %11, i32 %50, i32 %6)
%54 = call i32 @close(i32 %17)
br label %56
55: ; preds = %49
store i32 %17, i32* %7
br label %56
56: ; preds = %55, %52, %47, %41, %35, %30, %24, %19
%57 = phi i32 [ -1, %19 ], [ -1, %24 ], [ -1, %30 ], [ -1, %35 ], [ -1, %41 ], [ -1, %47 ], [ -1, %52 ], [ 0, %55 ]
ret i32 %57
}