#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*/ assert(int);
int /*<<< orphan*/ ipacl_close(int);
int ipacl_do_request(int, int *const, char const *const, unsigned int const,
                     unsigned int const);
int ipacl_open(int *);
int ipacl_request(int *const restrict pfh, const char *const restrict ip,
                  const unsigned int protocol, const unsigned int port) {
  int fh;
  int rc;
  assert(pfh != NULL);
  assert(ip != NULL);
  assert(protocol <= 65535u);
  assert(port <= 65535u);
  if ((rc = ipacl_open(&fh)) != 0)
    return rc;
  rc = ipacl_do_request(fh, pfh, ip, protocol, port);
  ipacl_close(fh);
  return rc;
}


x86 assembly (clang, -O0):
<ipacl_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpl   $0xffff,-0x1c(%rbp)
setbe  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpl   $0xffff,-0x20(%rbp)
setbe  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x24(%rbp),%rdi
call   1030 <ipacl_open@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
je     11c2 <ipacl_request+0x82>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ea <ipacl_request+0xaa>
mov    -0x24(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
call   1040 <ipacl_do_request@plt>
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
call   1060 <ipacl_close@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipacl_request>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %rsi,%r12
mov    %rdi,%rbp
xor    %edi,%edi
test   %rbp,%rbp
setne  %dil
call   1050 <assert@plt>
xor    %edi,%edi
test   %r12,%r12
setne  %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmp    $0x10000,%r15d
setb   %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmp    $0x10000,%r14d
setb   %dil
call   1050 <assert@plt>
lea    0xc(%rsp),%rdi
call   1030 <ipacl_open@plt>
mov    %eax,%ebx
test   %eax,%eax
jne    11c8 <ipacl_request+0x88>
mov    0xc(%rsp),%edi
mov    %rbp,%rsi
mov    %r12,%rdx
mov    %r15d,%ecx
mov    %r14d,%r8d
call   1040 <ipacl_do_request@plt>
mov    %eax,%ebx
mov    0xc(%rsp),%edi
call   1060 <ipacl_close@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ipacl_request(i32* noalias %0, i8* noalias %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%12 = load i32*, i32** %6
%13 = icmp ne i32* %12, null
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i8*, i8** %7
%17 = icmp ne i8* %16, null
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load i32, i32* %8
%21 = icmp ule i32 %20, 65535
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = load i32, i32* %9
%25 = icmp ule i32 %24, 65535
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = call i32 @ipacl_open(i32* %10)
store i32 %28, i32* %11
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %4
%31 = load i32, i32* %11
store i32 %31, i32* %5
br label %42
32: ; preds = %4
%33 = load i32, i32* %10
%34 = load i32*, i32** %6
%35 = load i8*, i8** %7
%36 = load i32, i32* %8
%37 = load i32, i32* %9
%38 = call i32 @ipacl_do_request(i32 %33, i32* %34, i8* %35, i32 %36, i32 %37)
store i32 %38, i32* %11
%39 = load i32, i32* %10
%40 = call i32 @ipacl_close(i32 %39)
%41 = load i32, i32* %11
store i32 %41, i32* %5
br label %42
42: ; preds = %32, %30
%43 = load i32, i32* %5
ret i32 %43
}

LLVM IR (-O2):
define i32 @ipacl_request(i32* noalias %0, i8* noalias %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = icmp ne i32* %0, null
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = icmp ne i8* %1, null
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = icmp ult i32 %2, 65536
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = icmp ult i32 %3, 65536
%17 = zext i1 %16 to i32
%18 = tail call i32 @assert(i32 %17)
%19 = call i32 @ipacl_open(i32* %5)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %4
%22 = load i32, i32* %5
%23 = call i32 @ipacl_do_request(i32 %22, i32* %0, i8* %1, i32 %2, i32 %3)
%24 = load i32, i32* %5
%25 = call i32 @ipacl_close(i32 %24)
br label %26
26: ; preds = %4, %21
%27 = phi i32 [ %23, %21 ], [ %19, %4 ]
ret i32 %27
}