#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 */
typedef struct TYPE_6__ TYPE_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
typedef scalar_t__ ns_sect;
struct TYPE_5__ {
  int type;
  int rr_class;
  int rdlength;
  int /*<<< orphan*/ *rdata;
  scalar_t__ ttl;
  int /*<<< orphan*/ name;
};
typedef TYPE_1__ ns_rr;
struct TYPE_6__ {
  int _rrnum;
  scalar_t__ _msg_ptr;
  scalar_t__ *_sections;
  int *_counts;
  scalar_t__ _eom;
  int /*<<< orphan*/ _msg;
  scalar_t__ _sect;
};
typedef TYPE_2__ ns_msg;

/* Variables and functions */
int /*<<< orphan*/ EMSGSIZE;
int /*<<< orphan*/ ENODEV;
int /*<<< orphan*/ NS_GET16(int, scalar_t__);
int /*<<< orphan*/ NS_GET32(scalar_t__, scalar_t__);
int NS_INT16SZ;
int NS_INT32SZ;
int /*<<< orphan*/ NS_MAXDNAME;
int dn_expand(int /*<<< orphan*/, scalar_t__, scalar_t__, int /*<<< orphan*/,
              int /*<<< orphan*/);
int /*<<< orphan*/ errno;
scalar_t__ ns_s_max;
scalar_t__ ns_s_qd;
int skiprr(int /*<<< orphan*/, scalar_t__, scalar_t__, int);
int ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
  int b;
  if (section < 0 || section >= ns_s_max)
    goto enodev;
  if ((int)section != (int)handle->_sect) {
    handle->_sect = section;
    handle->_rrnum = 0;
    handle->_msg_ptr = handle->_sections[(int)section];
  }
  if (rrnum == -1)
    rrnum = handle->_rrnum;
  if (rrnum < 0 || rrnum >= handle->_counts[(int)section])
    goto enodev;
  if (rrnum < handle->_rrnum) {
    handle->_rrnum = 0;
    handle->_msg_ptr = handle->_sections[(int)section];
  }
  b = skiprr(handle->_msg, handle->_eom, section, rrnum - handle->_rrnum);
  if (b < 0)
    return (-1);
  handle->_msg_ptr += b;
  handle->_rrnum = rrnum;
  b = dn_expand(handle->_msg, handle->_eom, handle->_msg_ptr, rr->name,
                NS_MAXDNAME);
  if (b < 0)
    return (-1);
  handle->_msg_ptr += b;
  if (handle->_msg_ptr + NS_INT16SZ > handle->_eom)
    goto emsgsize;
  NS_GET16(rr->type, handle->_msg_ptr);
  if (handle->_msg_ptr + NS_INT16SZ > handle->_eom)
    goto emsgsize;
  NS_GET16(rr->rr_class, handle->_msg_ptr);
  if (section == ns_s_qd) {
    rr->ttl = 0;
    rr->rdlength = 0;
    rr->rdata = NULL;
  } else {
    if (handle->_msg_ptr + NS_INT32SZ > handle->_eom)
      goto emsgsize;
    NS_GET32(rr->ttl, handle->_msg_ptr);
    if (handle->_msg_ptr + NS_INT16SZ > handle->_eom)
      goto emsgsize;
    NS_GET16(rr->rdlength, handle->_msg_ptr);
    if (handle->_msg_ptr + rr->rdlength > handle->_eom)
      goto emsgsize;
    rr->rdata = handle->_msg_ptr;
    handle->_msg_ptr += rr->rdlength;
  }
  handle->_rrnum++;
  return (0);
enodev:
  errno = ENODEV;
  return (-1);
emsgsize:
  errno = EMSGSIZE;
  return (-1);
}


x86 assembly (clang, -O0):
<ns_parserr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
jl     1176 <ns_parserr+0x36>
mov    -0x18(%rbp),%rax
mov    0x2e33(%rip),%rcx
cmp    (%rcx),%rax
jl     117b <ns_parserr+0x3b>
jmp    1467 <ns_parserr+0x327>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    0x30(%rcx),%rcx
cmp    %ecx,%eax
je     11c0 <ns_parserr+0x80>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x30(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x18(%rbp),%rcx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    11d3 <ns_parserr+0x93>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     11f8 <ns_parserr+0xb8>
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    0x18(%rcx),%rcx
mov    -0x18(%rbp),%rdx
movslq %edx,%rdx
cmp    (%rcx,%rdx,4),%eax
jl     11fd <ns_parserr+0xbd>
jmp    1467 <ns_parserr+0x327>
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    1231 <ns_parserr+0xf1>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x18(%rbp),%rcx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
sub    (%rax),%ecx
call   1050 <skiprr@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    126b <ns_parserr+0x12b>
movl   $0xffffffff,-0x4(%rbp)
jmp    149e <ns_parserr+0x35e>
movslq -0x2c(%rbp),%rcx
mov    -0x10(%rbp),%rax
add    0x8(%rax),%rcx
mov    %rcx,0x8(%rax)
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x28(%rbp),%rax
mov    0x20(%rax),%ecx
mov    0x2d37(%rip),%rax
mov    (%rax),%r8d
call   1060 <dn_expand@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    12ca <ns_parserr+0x18a>
movl   $0xffffffff,-0x4(%rbp)
jmp    149e <ns_parserr+0x35e>
movslq -0x2c(%rbp),%rcx
mov    -0x10(%rbp),%rax
add    0x8(%rax),%rcx
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2cc7(%rip),%rcx
movslq (%rcx),%rcx
add    %rcx,%rax
mov    -0x10(%rbp),%rcx
cmp    0x20(%rcx),%rax
jle    1302 <ns_parserr+0x1c2>
jmp    1485 <ns_parserr+0x345>
mov    -0x28(%rbp),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <NS_GET16@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2c8c(%rip),%rcx
movslq (%rcx),%rcx
add    %rcx,%rax
mov    -0x10(%rbp),%rcx
cmp    0x20(%rcx),%rax
jle    133d <ns_parserr+0x1fd>
jmp    1485 <ns_parserr+0x345>
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <NS_GET16@plt>
mov    -0x18(%rbp),%rax
mov    0x2c74(%rip),%rcx
cmp    (%rcx),%rax
jne    138d <ns_parserr+0x24d>
mov    -0x28(%rbp),%rax
movq   $0x0,0x18(%rax)
mov    -0x28(%rbp),%rax
movl   $0x0,0x8(%rax)
mov    -0x28(%rbp),%rax
movq   $0x0,0x10(%rax)
jmp    1450 <ns_parserr+0x310>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2c4c(%rip),%rcx
movslq (%rcx),%rcx
add    %rcx,%rax
mov    -0x10(%rbp),%rcx
cmp    0x20(%rcx),%rax
jle    13b5 <ns_parserr+0x275>
jmp    1485 <ns_parserr+0x345>
mov    -0x28(%rbp),%rax
mov    0x18(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <NS_GET32@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2bd7(%rip),%rcx
movslq (%rcx),%rcx
add    %rcx,%rax
mov    -0x10(%rbp),%rcx
cmp    0x20(%rcx),%rax
jle    13f2 <ns_parserr+0x2b2>
jmp    1485 <ns_parserr+0x345>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <NS_GET16@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x28(%rbp),%rcx
movslq 0x8(%rcx),%rcx
add    %rcx,%rax
mov    -0x10(%rbp),%rcx
cmp    0x20(%rcx),%rax
jle    142c <ns_parserr+0x2ec>
jmp    1485 <ns_parserr+0x345>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x28(%rbp),%rax
movslq 0x8(%rax),%rcx
mov    -0x10(%rbp),%rax
add    0x8(%rax),%rcx
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    149e <ns_parserr+0x35e>
mov    0x2b4a(%rip),%rax
mov    (%rax),%ecx
mov    0x2b49(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    149e <ns_parserr+0x35e>
mov    0x2b4c(%rip),%rax
mov    (%rax),%ecx
mov    0x2b2b(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ns_parserr>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %rsi,%rsi
js     126e <ns_parserr+0x12e>
mov    %rsi,%rbx
mov    0x2e45(%rip),%rax
cmp    %rsi,(%rax)
jle    126e <ns_parserr+0x12e>
mov    %rcx,%r14
mov    %edx,%ebp
mov    %rdi,%r15
cmp    0x30(%rdi),%ebx
jne    117f <ns_parserr+0x3f>
cmp    $0xffffffff,%ebp
je     119e <ns_parserr+0x5e>
test   %ebp,%ebp
jns    11a9 <ns_parserr+0x69>
jmp    126e <ns_parserr+0x12e>
mov    %rbx,0x30(%r15)
movl   $0x0,(%r15)
mov    0x10(%r15),%rax
movslq %ebx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,0x8(%r15)
cmp    $0xffffffff,%ebp
jne    1176 <ns_parserr+0x36>
mov    (%r15),%ebp
test   %ebp,%ebp
js     126e <ns_parserr+0x12e>
mov    0x18(%r15),%rcx
movslq %ebx,%rax
cmp    (%rcx,%rax,4),%ebp
jge    126e <ns_parserr+0x12e>
mov    (%r15),%edx
cmp    %edx,%ebp
jge    11d5 <ns_parserr+0x95>
movl   $0x0,(%r15)
mov    0x10(%r15),%rcx
mov    (%rcx,%rax,8),%rax
mov    %rax,0x8(%r15)
xor    %edx,%edx
mov    0x28(%r15),%edi
mov    0x20(%r15),%rsi
mov    %ebp,%ecx
sub    %edx,%ecx
mov    %rbx,%rdx
call   1050 <skiprr@plt>
mov    $0xffffffff,%r12d
test   %eax,%eax
js     1286 <ns_parserr+0x146>
mov    %eax,%edx
add    0x8(%r15),%rdx
mov    %rdx,0x8(%r15)
mov    %ebp,(%r15)
mov    0x28(%r15),%edi
mov    0x20(%r15),%rsi
mov    0x20(%r14),%ecx
mov    0x2dc9(%rip),%rax
mov    (%rax),%r8d
call   1060 <dn_expand@plt>
test   %eax,%eax
js     1286 <ns_parserr+0x146>
mov    %eax,%esi
add    0x8(%r15),%rsi
mov    %rsi,0x8(%r15)
mov    0x2d7c(%rip),%rbp
movslq 0x0(%rbp),%rax
add    %rsi,%rax
cmp    0x20(%r15),%rax
jg     125a <ns_parserr+0x11a>
mov    (%r14),%edi
call   1040 <NS_GET16@plt>
mov    0x8(%r15),%rsi
movslq 0x0(%rbp),%rax
add    %rsi,%rax
cmp    0x20(%r15),%rax
jle    1292 <ns_parserr+0x152>
mov    0x2d77(%rip),%rax
mov    (%rax),%eax
mov    0x2d56(%rip),%rcx
mov    %eax,(%rcx)
jmp    1286 <ns_parserr+0x146>
mov    0x2d43(%rip),%rax
mov    (%rax),%eax
mov    0x2d42(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%r12d
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x4(%r14),%edi
call   1040 <NS_GET16@plt>
mov    0x2d2e(%rip),%rax
cmp    %rbx,(%rax)
jne    12c0 <ns_parserr+0x180>
movl   $0x0,0x8(%r14)
xorps  %xmm0,%xmm0
movups %xmm0,0x10(%r14)
addl   $0x1,(%r15)
xor    %r12d,%r12d
jmp    1286 <ns_parserr+0x146>
mov    0x8(%r15),%rsi
mov    0x2d1d(%rip),%rax
movslq (%rax),%rax
add    %rsi,%rax
cmp    0x20(%r15),%rax
jg     125a <ns_parserr+0x11a>
mov    0x18(%r14),%rdi
call   1030 <NS_GET32@plt>
mov    0x8(%r15),%rsi
movslq 0x0(%rbp),%rax
add    %rsi,%rax
cmp    0x20(%r15),%rax
jg     125a <ns_parserr+0x11a>
mov    0x8(%r14),%edi
call   1040 <NS_GET16@plt>
mov    0x8(%r15),%rax
movslq 0x8(%r14),%rcx
add    %rax,%rcx
cmp    0x20(%r15),%rcx
jg     125a <ns_parserr+0x11a>
mov    %rax,0x10(%r14)
mov    %rcx,0x8(%r15)
jmp    12b7 <ns_parserr+0x177>

LLVM IR (-O0):
%struct.TYPE_6__ = type { i32, i64, i64*, i32*, i64, i32, i64 }
%struct.TYPE_5__ = type { i32, i32, i32, i32*, i64, i32 }
@ns_s_max = global i64 0
@NS_MAXDNAME = global i32 0
@NS_INT16SZ = global i32 0
@ns_s_qd = global i64 0
@NS_INT32SZ = global i32 0
@ENODEV = global i32 0
@errno = global i32 0
@EMSGSIZE = global i32 0
define i32 @ns_parserr(%struct.TYPE_6__* %0, i64 %1, i32 %2, %struct.TYPE_5__* %3) {
%5 = alloca i32
%6 = alloca %struct.TYPE_6__*
%7 = alloca i64
%8 = alloca i32
%9 = alloca %struct.TYPE_5__*
%10 = alloca i32
store %struct.TYPE_6__* %0, %struct.TYPE_6__** %6
store i64 %1, i64* %7
store i32 %2, i32* %8
store %struct.TYPE_5__* %3, %struct.TYPE_5__** %9
%11 = load i64, i64* %7
%12 = icmp slt i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %4
%14 = load i64, i64* %7
%15 = load i64, i64* @ns_s_max
%16 = icmp sge i64 %14, %15
br i1 %16, label %17, label %18
17: ; preds = %13, %4
br label %254
18: ; preds = %13
%19 = load i64, i64* %7
%20 = trunc i64 %19 to i32
%21 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%22 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %21, i32 0, i32 6
%23 = load i64, i64* %22
%24 = trunc i64 %23 to i32
%25 = icmp ne i32 %20, %24
br i1 %25, label %26, label %42
26: ; preds = %18
%27 = load i64, i64* %7
%28 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%29 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %28, i32 0, i32 6
store i64 %27, i64* %29
%30 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%31 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %30, i32 0, i32 0
store i32 0, i32* %31
%32 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%33 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %32, i32 0, i32 2
%34 = load i64*, i64** %33
%35 = load i64, i64* %7
%36 = trunc i64 %35 to i32
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i64, i64* %34, i64 %37
%39 = load i64, i64* %38
%40 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%41 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %40, i32 0, i32 1
store i64 %39, i64* %41
br label %42
42: ; preds = %26, %18
%43 = load i32, i32* %8
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %49
45: ; preds = %42
%46 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%47 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %46, i32 0, i32 0
%48 = load i32, i32* %47
store i32 %48, i32* %8
br label %49
49: ; preds = %45, %42
%50 = load i32, i32* %8
%51 = icmp slt i32 %50, 0
br i1 %51, label %63, label %52
52: ; preds = %49
%53 = load i32, i32* %8
%54 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%55 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %54, i32 0, i32 3
%56 = load i32*, i32** %55
%57 = load i64, i64* %7
%58 = trunc i64 %57 to i32
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i32, i32* %56, i64 %59
%61 = load i32, i32* %60
%62 = icmp sge i32 %53, %61
br i1 %62, label %63, label %64
63: ; preds = %52, %49
br label %254
64: ; preds = %52
%65 = load i32, i32* %8
%66 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%67 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %66, i32 0, i32 0
%68 = load i32, i32* %67
%69 = icmp slt i32 %65, %68
br i1 %69, label %70, label %83
70: ; preds = %64
%71 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%72 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %71, i32 0, i32 0
store i32 0, i32* %72
%73 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%74 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %73, i32 0, i32 2
%75 = load i64*, i64** %74
%76 = load i64, i64* %7
%77 = trunc i64 %76 to i32
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i64, i64* %75, i64 %78
%80 = load i64, i64* %79
%81 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%82 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %81, i32 0, i32 1
store i64 %80, i64* %82
br label %83
83: ; preds = %70, %64
%84 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%85 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %84, i32 0, i32 5
%86 = load i32, i32* %85
%87 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%88 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %87, i32 0, i32 4
%89 = load i64, i64* %88
%90 = load i64, i64* %7
%91 = load i32, i32* %8
%92 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%93 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %92, i32 0, i32 0
%94 = load i32, i32* %93
%95 = sub nsw i32 %91, %94
%96 = call i32 @skiprr(i32 %86, i64 %89, i64 %90, i32 %95)
store i32 %96, i32* %10
%97 = load i32, i32* %10
%98 = icmp slt i32 %97, 0
br i1 %98, label %99, label %100
99: ; preds = %83
store i32 -1, i32* %5
br label %258
100: ; preds = %83
%101 = load i32, i32* %10
%102 = sext i32 %101 to i64
%103 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%104 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %103, i32 0, i32 1
%105 = load i64, i64* %104
%106 = add nsw i64 %105, %102
store i64 %106, i64* %104
%107 = load i32, i32* %8
%108 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%109 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %108, i32 0, i32 0
store i32 %107, i32* %109
%110 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%111 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %110, i32 0, i32 5
%112 = load i32, i32* %111
%113 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%114 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %113, i32 0, i32 4
%115 = load i64, i64* %114
%116 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%117 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %116, i32 0, i32 1
%118 = load i64, i64* %117
%119 = load %struct.TYPE_5__*, %struct.TYPE_5__** %9
%120 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %119, i32 0, i32 5
%121 = load i32, i32* %120
%122 = load i32, i32* @NS_MAXDNAME
%123 = call i32 @dn_expand(i32 %112, i64 %115, i64 %118, i32 %121, i32 %122)
store i32 %123, i32* %10
%124 = load i32, i32* %10
%125 = icmp slt i32 %124, 0
br i1 %125, label %126, label %127
126: ; preds = %100
store i32 -1, i32* %5
br label %258
127: ; preds = %100
%128 = load i32, i32* %10
%129 = sext i32 %128 to i64
%130 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%131 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %130, i32 0, i32 1
%132 = load i64, i64* %131
%133 = add nsw i64 %132, %129
store i64 %133, i64* %131
%134 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%135 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %134, i32 0, i32 1
%136 = load i64, i64* %135
%137 = load i32, i32* @NS_INT16SZ
%138 = sext i32 %137 to i64
%139 = add nsw i64 %136, %138
%140 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%141 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %140, i32 0, i32 4
%142 = load i64, i64* %141
%143 = icmp sgt i64 %139, %142
br i1 %143, label %144, label %145
144: ; preds = %127
br label %256
145: ; preds = %127
%146 = load %struct.TYPE_5__*, %struct.TYPE_5__** %9
%147 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %146, i32 0, i32 0
%148 = load i32, i32* %147
%149 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%150 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %149, i32 0, i32 1
%151 = load i64, i64* %150
%152 = call i32 @NS_GET16(i32 %148, i64 %151)
%153 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%154 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %153, i32 0, i32 1
%155 = load i64, i64* %154
%156 = load i32, i32* @NS_INT16SZ
%157 = sext i32 %156 to i64
%158 = add nsw i64 %155, %157
%159 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%160 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %159, i32 0, i32 4
%161 = load i64, i64* %160
%162 = icmp sgt i64 %158, %161
br i1 %162, label %163, label %164
163: ; preds = %145
br label %256
164: ; preds = %145
%165 = load %struct.TYPE_5__*, %struct.TYPE_5__** %9
%166 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %165, i32 0, i32 1
%167 = load i32, i32* %166
%168 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%169 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %168, i32 0, i32 1
%170 = load i64, i64* %169
%171 = call i32 @NS_GET16(i32 %167, i64 %170)
%172 = load i64, i64* %7
%173 = load i64, i64* @ns_s_qd
%174 = icmp eq i64 %172, %173
br i1 %174, label %175, label %182
175: ; preds = %164
%176 = load %struct.TYPE_5__*, %struct.TYPE_5__** %9
%177 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %176, i32 0, i32 4
store i64 0, i64* %177
%178 = load %struct.TYPE_5__*, %struct.TYPE_5__** %9
%179 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %178, i32 0, i32 2
store i32 0, i32* %179
%180 = load %struct.TYPE_5__*, %struct.TYPE_5__** %9
%181 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %180, i32 0, i32 3
store i32* null, i32** %181
br label %249
182: ; preds = %164
%183 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%184 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %183, i32 0, i32 1
%185 = load i64, i64* %184
%186 = load i32, i32* @NS_INT32SZ
%187 = sext i32 %186 to i64
%188 = add nsw i64 %185, %187
%189 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%190 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %189, i32 0, i32 4
%191 = load i64, i64* %190
%192 = icmp sgt i64 %188, %191
br i1 %192, label %193, label %194
193: ; preds = %182
br label %256
194: ; preds = %182
%195 = load %struct.TYPE_5__*, %struct.TYPE_5__** %9
%196 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %195, i32 0, i32 4
%197 = load i64, i64* %196
%198 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%199 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %198, i32 0, i32 1
%200 = load i64, i64* %199
%201 = call i32 @NS_GET32(i64 %197, i64 %200)
%202 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%203 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %202, i32 0, i32 1
%204 = load i64, i64* %203
%205 = load i32, i32* @NS_INT16SZ
%206 = sext i32 %205 to i64
%207 = add nsw i64 %204, %206
%208 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%209 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %208, i32 0, i32 4
%210 = load i64, i64* %209
%211 = icmp sgt i64 %207, %210
br i1 %211, label %212, label %213
212: ; preds = %194
br label %256
213: ; preds = %194
%214 = load %struct.TYPE_5__*, %struct.TYPE_5__** %9
%215 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %214, i32 0, i32 2
%216 = load i32, i32* %215
%217 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%218 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %217, i32 0, i32 1
%219 = load i64, i64* %218
%220 = call i32 @NS_GET16(i32 %216, i64 %219)
%221 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%222 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %221, i32 0, i32 1
%223 = load i64, i64* %222
%224 = load %struct.TYPE_5__*, %struct.TYPE_5__** %9
%225 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %224, i32 0, i32 2
%226 = load i32, i32* %225
%227 = sext i32 %226 to i64
%228 = add nsw i64 %223, %227
%229 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%230 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %229, i32 0, i32 4
%231 = load i64, i64* %230
%232 = icmp sgt i64 %228, %231
br i1 %232, label %233, label %234
233: ; preds = %213
br label %256
234: ; preds = %213
%235 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%236 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %235, i32 0, i32 1
%237 = load i64, i64* %236
%238 = inttoptr i64 %237 to i32*
%239 = load %struct.TYPE_5__*, %struct.TYPE_5__** %9
%240 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %239, i32 0, i32 3
store i32* %238, i32** %240
%241 = load %struct.TYPE_5__*, %struct.TYPE_5__** %9
%242 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %241, i32 0, i32 2
%243 = load i32, i32* %242
%244 = sext i32 %243 to i64
%245 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%246 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %245, i32 0, i32 1
%247 = load i64, i64* %246
%248 = add nsw i64 %247, %244
store i64 %248, i64* %246
br label %249
249: ; preds = %234, %175
%250 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%251 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %250, i32 0, i32 0
%252 = load i32, i32* %251
%253 = add nsw i32 %252, 1
store i32 %253, i32* %251
store i32 0, i32* %5
br label %258
254: ; preds = %63, %17
%255 = load i32, i32* @ENODEV
store i32 %255, i32* @errno
store i32 -1, i32* %5
br label %258
256: ; preds = %233, %212, %193, %163, %144
%257 = load i32, i32* @EMSGSIZE
store i32 %257, i32* @errno
store i32 -1, i32* %5
br label %258
258: ; preds = %256, %254, %249, %126, %99
%259 = load i32, i32* %5
ret i32 %259
}

LLVM IR (-O2):
%struct.TYPE_6__ = type { i32, i64, i64*, i32*, i64, i32, i64 }
%struct.TYPE_5__ = type { i32, i32, i32, i32*, i64, i32 }
@ns_s_max = global i64 0
@NS_MAXDNAME = global i32 0
@NS_INT16SZ = global i32 0
@ns_s_qd = global i64 0
@NS_INT32SZ = global i32 0
@ENODEV = global i32 0
@errno = global i32 0
@EMSGSIZE = global i32 0
define i32 @ns_parserr(%struct.TYPE_6__* nocapture %0, i64 %1, i32 %2, %struct.TYPE_5__* nocapture %3) {
%5 = icmp sgt i64 %1, -1
%6 = load i64, i64* @ns_s_max
%7 = icmp sgt i64 %6, %1
%8 = select i1 %5, i1 %7, i1 false
br i1 %8, label %9, label %133
9: ; preds = %4
%10 = trunc i64 %1 to i32
%11 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 6
%12 = load i64, i64* %11
%13 = trunc i64 %12 to i32
%14 = icmp eq i32 %10, %13
br i1 %14, label %24, label %15
15: ; preds = %9
store i64 %1, i64* %11
%16 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 0
store i32 0, i32* %16
%17 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 2
%18 = load i64*, i64** %17
%19 = shl i64 %1, 32
%20 = ashr exact i64 %19, 32
%21 = getelementptr inbounds i64, i64* %18, i64 %20
%22 = load i64, i64* %21
%23 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 1
store i64 %22, i64* %23
br label %24
24: ; preds = %15, %9
%25 = icmp eq i32 %2, -1
br i1 %25, label %26, label %29
26: ; preds = %24
%27 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 0
%28 = load i32, i32* %27
br label %29
29: ; preds = %26, %24
%30 = phi i32 [ %28, %26 ], [ %2, %24 ]
%31 = icmp slt i32 %30, 0
br i1 %31, label %133, label %32
32: ; preds = %29
%33 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 3
%34 = load i32*, i32** %33
%35 = shl i64 %1, 32
%36 = ashr exact i64 %35, 32
%37 = getelementptr inbounds i32, i32* %34, i64 %36
%38 = load i32, i32* %37
%39 = icmp slt i32 %30, %38
br i1 %39, label %40, label %133
40: ; preds = %32
%41 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 0
%42 = load i32, i32* %41
%43 = icmp slt i32 %30, %42
br i1 %43, label %44, label %50
44: ; preds = %40
store i32 0, i32* %41
%45 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 2
%46 = load i64*, i64** %45
%47 = getelementptr inbounds i64, i64* %46, i64 %36
%48 = load i64, i64* %47
%49 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 1
store i64 %48, i64* %49
br label %50
50: ; preds = %44, %40
%51 = phi i32 [ 0, %44 ], [ %42, %40 ]
%52 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 5
%53 = load i32, i32* %52
%54 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 4
%55 = load i64, i64* %54
%56 = sub nsw i32 %30, %51
%57 = tail call i32 @skiprr(i32 %53, i64 %55, i64 %1, i32 %56)
%58 = icmp slt i32 %57, 0
br i1 %58, label %137, label %59
59: ; preds = %50
%60 = zext i32 %57 to i64
%61 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 1
%62 = load i64, i64* %61
%63 = add nsw i64 %62, %60
store i64 %63, i64* %61
store i32 %30, i32* %41
%64 = load i32, i32* %52
%65 = load i64, i64* %54
%66 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 5
%67 = load i32, i32* %66
%68 = load i32, i32* @NS_MAXDNAME
%69 = tail call i32 @dn_expand(i32 %64, i64 %65, i64 %63, i32 %67, i32 %68)
%70 = icmp slt i32 %69, 0
br i1 %70, label %137, label %71
71: ; preds = %59
%72 = zext i32 %69 to i64
%73 = load i64, i64* %61
%74 = add nsw i64 %73, %72
store i64 %74, i64* %61
%75 = load i32, i32* @NS_INT16SZ
%76 = sext i32 %75 to i64
%77 = add nsw i64 %74, %76
%78 = load i64, i64* %54
%79 = icmp sgt i64 %77, %78
br i1 %79, label %135, label %80
80: ; preds = %71
%81 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 0
%82 = load i32, i32* %81
%83 = tail call i32 @NS_GET16(i32 %82, i64 %74)
%84 = load i64, i64* %61
%85 = load i32, i32* @NS_INT16SZ
%86 = sext i32 %85 to i64
%87 = add nsw i64 %84, %86
%88 = load i64, i64* %54
%89 = icmp sgt i64 %87, %88
br i1 %89, label %135, label %90
90: ; preds = %80
%91 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 1
%92 = load i32, i32* %91
%93 = tail call i32 @NS_GET16(i32 %92, i64 %84)
%94 = load i64, i64* @ns_s_qd
%95 = icmp eq i64 %94, %1
br i1 %95, label %96, label %100
96: ; preds = %90
%97 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 2
store i32 0, i32* %97
%98 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 3
%99 = bitcast i32** %98 to i8*
br label %130
100: ; preds = %90
%101 = load i64, i64* %61
%102 = load i32, i32* @NS_INT32SZ
%103 = sext i32 %102 to i64
%104 = add nsw i64 %101, %103
%105 = load i64, i64* %54
%106 = icmp sgt i64 %104, %105
br i1 %106, label %135, label %107
107: ; preds = %100
%108 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 4
%109 = load i64, i64* %108
%110 = tail call i32 @NS_GET32(i64 %109, i64 %101)
%111 = load i64, i64* %61
%112 = load i32, i32* @NS_INT16SZ
%113 = sext i32 %112 to i64
%114 = add nsw i64 %111, %113
%115 = load i64, i64* %54
%116 = icmp sgt i64 %114, %115
br i1 %116, label %135, label %117
117: ; preds = %107
%118 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 2
%119 = load i32, i32* %118
%120 = tail call i32 @NS_GET16(i32 %119, i64 %111)
%121 = load i64, i64* %61
%122 = load i32, i32* %118
%123 = sext i32 %122 to i64
%124 = add nsw i64 %121, %123
%125 = load i64, i64* %54
%126 = icmp sgt i64 %124, %125
br i1 %126, label %135, label %127
127: ; preds = %117
%128 = inttoptr i64 %121 to i32*
%129 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 3
store i32* %128, i32** %129
store i64 %124, i64* %61
br label %130
130: ; preds = %127, %96
%131 = load i32, i32* %41
%132 = add nsw i32 %131, 1
store i32 %132, i32* %41
br label %137
133: ; preds = %29, %32, %4
%134 = load i32, i32* @ENODEV
store i32 %134, i32* @errno
br label %137
135: ; preds = %117, %107, %100, %80, %71
%136 = load i32, i32* @EMSGSIZE
store i32 %136, i32* @errno
br label %137
137: ; preds = %59, %50, %135, %133, %130
%138 = phi i32 [ -1, %133 ], [ -1, %135 ], [ 0, %130 ], [ -1, %50 ], [ -1, %59 ]
ret i32 %138
}