#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 */
struct PdSocket {
  int dummy;
};

/* Variables and functions */
struct PdSocket *pd_socket_accept(struct PdSocket *);
int /*<<< orphan*/ pd_socket_destroy(struct PdSocket *);
scalar_t__ pd_socket_keep_alive(struct PdSocket *, int);
scalar_t__ pd_socket_linger(struct PdSocket *, int, int);
scalar_t__ pd_socket_no_blocking(struct PdSocket *, int);
scalar_t__ pd_socket_recv_buffer(struct PdSocket *, long);
scalar_t__ pd_socket_send_buffer(struct PdSocket *, long);
scalar_t__ pd_socket_tcp_quickack(struct PdSocket *, int);
struct PdSocket *pd_socket_accept_tcp_client(struct PdSocket *listen_sock) {
  struct PdSocket *ret = pd_socket_accept(listen_sock);
  if (NULL != ret) {
    if (0 != pd_socket_keep_alive(ret, 1) ||
        0 != pd_socket_linger(ret, 1, 10) ||
        0 != pd_socket_tcp_quickack(ret, 1) ||
        0 != pd_socket_no_blocking(ret, 1) ||
        0 != pd_socket_send_buffer(ret, (1L << 23)) ||
        0 != pd_socket_recv_buffer(ret, (1L << 23))) {
      pd_socket_destroy(ret);
      ret = NULL;
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<pd_socket_accept_tcp_client>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <pd_socket_accept@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     1268 <pd_socket_accept_tcp_client+0xe8>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1080 <pd_socket_keep_alive@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1252 <pd_socket_accept_tcp_client+0xd2>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
mov    $0xa,%edx
call   1070 <pd_socket_linger@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1252 <pd_socket_accept_tcp_client+0xd2>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1040 <pd_socket_tcp_quickack@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1252 <pd_socket_accept_tcp_client+0xd2>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1060 <pd_socket_no_blocking@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1252 <pd_socket_accept_tcp_client+0xd2>
mov    -0x10(%rbp),%rdi
mov    $0x800000,%esi
call   1090 <pd_socket_send_buffer@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1252 <pd_socket_accept_tcp_client+0xd2>
mov    -0x10(%rbp),%rdi
mov    $0x800000,%esi
call   10a0 <pd_socket_recv_buffer@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1263 <pd_socket_accept_tcp_client+0xe3>
mov    -0x10(%rbp),%rdi
call   1030 <pd_socket_destroy@plt>
movq   $0x0,-0x10(%rbp)
jmp    1268 <pd_socket_accept_tcp_client+0xe8>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pd_socket_accept_tcp_client>:
push   %rbx
call   1050 <pd_socket_accept@plt>
test   %rax,%rax
je     1207 <pd_socket_accept_tcp_client+0x87>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1,%esi
call   1080 <pd_socket_keep_alive@plt>
test   %rax,%rax
jne    11ff <pd_socket_accept_tcp_client+0x7f>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0xa,%edx
call   1070 <pd_socket_linger@plt>
test   %rax,%rax
jne    11ff <pd_socket_accept_tcp_client+0x7f>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <pd_socket_tcp_quickack@plt>
test   %rax,%rax
jne    11ff <pd_socket_accept_tcp_client+0x7f>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1060 <pd_socket_no_blocking@plt>
test   %rax,%rax
jne    11ff <pd_socket_accept_tcp_client+0x7f>
mov    $0x800000,%esi
mov    %rbx,%rdi
call   1090 <pd_socket_send_buffer@plt>
test   %rax,%rax
jne    11ff <pd_socket_accept_tcp_client+0x7f>
mov    $0x800000,%esi
mov    %rbx,%rdi
call   10a0 <pd_socket_recv_buffer@plt>
test   %rax,%rax
je     1209 <pd_socket_accept_tcp_client+0x89>
mov    %rbx,%rdi
call   1030 <pd_socket_destroy@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
%struct.PdSocket = type { i32 }
define %struct.PdSocket* @pd_socket_accept_tcp_client(%struct.PdSocket* %0) {
%2 = alloca %struct.PdSocket*
%3 = alloca %struct.PdSocket*
store %struct.PdSocket* %0, %struct.PdSocket** %2
%4 = load %struct.PdSocket*, %struct.PdSocket** %2
%5 = call %struct.PdSocket* @pd_socket_accept(%struct.PdSocket* %4)
store %struct.PdSocket* %5, %struct.PdSocket** %3
%6 = load %struct.PdSocket*, %struct.PdSocket** %3
%7 = icmp ne %struct.PdSocket* null, %6
br i1 %7, label %8, label %36
8: ; preds = %1
%9 = load %struct.PdSocket*, %struct.PdSocket** %3
%10 = call i64 @pd_socket_keep_alive(%struct.PdSocket* %9, i32 1)
%11 = icmp ne i64 0, %10
br i1 %11, label %32, label %12
12: ; preds = %8
%13 = load %struct.PdSocket*, %struct.PdSocket** %3
%14 = call i64 @pd_socket_linger(%struct.PdSocket* %13, i32 1, i32 10)
%15 = icmp ne i64 0, %14
br i1 %15, label %32, label %16
16: ; preds = %12
%17 = load %struct.PdSocket*, %struct.PdSocket** %3
%18 = call i64 @pd_socket_tcp_quickack(%struct.PdSocket* %17, i32 1)
%19 = icmp ne i64 0, %18
br i1 %19, label %32, label %20
20: ; preds = %16
%21 = load %struct.PdSocket*, %struct.PdSocket** %3
%22 = call i64 @pd_socket_no_blocking(%struct.PdSocket* %21, i32 1)
%23 = icmp ne i64 0, %22
br i1 %23, label %32, label %24
24: ; preds = %20
%25 = load %struct.PdSocket*, %struct.PdSocket** %3
%26 = call i64 @pd_socket_send_buffer(%struct.PdSocket* %25, i64 8388608)
%27 = icmp ne i64 0, %26
br i1 %27, label %32, label %28
28: ; preds = %24
%29 = load %struct.PdSocket*, %struct.PdSocket** %3
%30 = call i64 @pd_socket_recv_buffer(%struct.PdSocket* %29, i64 8388608)
%31 = icmp ne i64 0, %30
br i1 %31, label %32, label %35
32: ; preds = %28, %24, %20, %16, %12, %8
%33 = load %struct.PdSocket*, %struct.PdSocket** %3
%34 = call i32 @pd_socket_destroy(%struct.PdSocket* %33)
store %struct.PdSocket* null, %struct.PdSocket** %3
br label %35
35: ; preds = %32, %28
br label %36
36: ; preds = %35, %1
%37 = load %struct.PdSocket*, %struct.PdSocket** %3
ret %struct.PdSocket* %37
}

LLVM IR (-O2):
%struct.PdSocket = type { i32 }
define %struct.PdSocket* @pd_socket_accept_tcp_client(%struct.PdSocket* %0) {
%2 = tail call %struct.PdSocket* @pd_socket_accept(%struct.PdSocket* %0)
%3 = icmp eq %struct.PdSocket* %2, null
br i1 %3, label %24, label %4
4: ; preds = %1
%5 = tail call i64 @pd_socket_keep_alive(%struct.PdSocket* %2, i32 1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %22
7: ; preds = %4
%8 = tail call i64 @pd_socket_linger(%struct.PdSocket* %2, i32 1, i32 10)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %22
10: ; preds = %7
%11 = tail call i64 @pd_socket_tcp_quickack(%struct.PdSocket* %2, i32 1)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = tail call i64 @pd_socket_no_blocking(%struct.PdSocket* %2, i32 1)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = tail call i64 @pd_socket_send_buffer(%struct.PdSocket* %2, i64 8388608)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = tail call i64 @pd_socket_recv_buffer(%struct.PdSocket* %2, i64 8388608)
%21 = icmp eq i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19, %16, %13, %10, %7, %4
%23 = tail call i32 @pd_socket_destroy(%struct.PdSocket* %2)
br label %24
24: ; preds = %19, %22, %1
%25 = phi %struct.PdSocket* [ null, %22 ], [ %2, %19 ], [ null, %1 ]
ret %struct.PdSocket* %25
}