#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;
unsigned int 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 ((unsigned int)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)
mov    -0x18(%rbp),%rax
mov    0x2e3e(%rip),%rcx
cmp    (%rcx),%eax
jb     116f <ns_parserr+0x2f>
jmp    145b <ns_parserr+0x31b>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    0x30(%rcx),%rcx
cmp    %ecx,%eax
je     11b4 <ns_parserr+0x74>
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    11c7 <ns_parserr+0x87>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     11ec <ns_parserr+0xac>
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     11f1 <ns_parserr+0xb1>
jmp    145b <ns_parserr+0x31b>
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    1225 <ns_parserr+0xe5>
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    125f <ns_parserr+0x11f>
movl   $0xffffffff,-0x4(%rbp)
jmp    1492 <ns_parserr+0x352>
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    0x2d43(%rip),%rax
mov    (%rax),%r8d
call   1060 <dn_expand@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    12be <ns_parserr+0x17e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1492 <ns_parserr+0x352>
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    0x2cd3(%rip),%rcx
movslq (%rcx),%rcx
add    %rcx,%rax
mov    -0x10(%rbp),%rcx
cmp    0x20(%rcx),%rax
jle    12f6 <ns_parserr+0x1b6>
jmp    1479 <ns_parserr+0x339>
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    0x2c98(%rip),%rcx
movslq (%rcx),%rcx
add    %rcx,%rax
mov    -0x10(%rbp),%rcx
cmp    0x20(%rcx),%rax
jle    1331 <ns_parserr+0x1f1>
jmp    1479 <ns_parserr+0x339>
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    0x2c80(%rip),%rcx
cmp    (%rcx),%rax
jne    1381 <ns_parserr+0x241>
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    1444 <ns_parserr+0x304>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2c58(%rip),%rcx
movslq (%rcx),%rcx
add    %rcx,%rax
mov    -0x10(%rbp),%rcx
cmp    0x20(%rcx),%rax
jle    13a9 <ns_parserr+0x269>
jmp    1479 <ns_parserr+0x339>
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    0x2be3(%rip),%rcx
movslq (%rcx),%rcx
add    %rcx,%rax
mov    -0x10(%rbp),%rcx
cmp    0x20(%rcx),%rax
jle    13e6 <ns_parserr+0x2a6>
jmp    1479 <ns_parserr+0x339>
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    1420 <ns_parserr+0x2e0>
jmp    1479 <ns_parserr+0x339>
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    1492 <ns_parserr+0x352>
mov    0x2b56(%rip),%rax
mov    (%rax),%ecx
mov    0x2b55(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1492 <ns_parserr+0x352>
mov    0x2b58(%rip),%rax
mov    (%rax),%ecx
mov    0x2b37(%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
mov    %rsi,%rbx
mov    0x2e4e(%rip),%rax
cmp    %ebx,(%rax)
jbe    1264 <ns_parserr+0x124>
mov    %rcx,%r14
mov    %edx,%ebp
mov    %rdi,%r15
cmp    0x30(%rdi),%ebx
jne    1175 <ns_parserr+0x35>
cmp    $0xffffffff,%ebp
je     1194 <ns_parserr+0x54>
test   %ebp,%ebp
jns    119f <ns_parserr+0x5f>
jmp    1264 <ns_parserr+0x124>
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    116c <ns_parserr+0x2c>
mov    (%r15),%ebp
test   %ebp,%ebp
js     1264 <ns_parserr+0x124>
mov    0x18(%r15),%rcx
movslq %ebx,%rax
cmp    (%rcx,%rax,4),%ebp
jge    1264 <ns_parserr+0x124>
mov    (%r15),%edx
cmp    %edx,%ebp
jge    11cb <ns_parserr+0x8b>
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     127c <ns_parserr+0x13c>
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    0x2dd3(%rip),%rax
mov    (%rax),%r8d
call   1060 <dn_expand@plt>
test   %eax,%eax
js     127c <ns_parserr+0x13c>
mov    %eax,%esi
add    0x8(%r15),%rsi
mov    %rsi,0x8(%r15)
mov    0x2d86(%rip),%rbp
movslq 0x0(%rbp),%rax
add    %rsi,%rax
cmp    0x20(%r15),%rax
jg     1250 <ns_parserr+0x110>
mov    (%r14),%edi
call   1040 <NS_GET16@plt>
mov    0x8(%r15),%rsi
movslq 0x0(%rbp),%rax
add    %rsi,%rax
cmp    0x20(%r15),%rax
jle    1288 <ns_parserr+0x148>
mov    0x2d81(%rip),%rax
mov    (%rax),%eax
mov    0x2d60(%rip),%rcx
mov    %eax,(%rcx)
jmp    127c <ns_parserr+0x13c>
mov    0x2d4d(%rip),%rax
mov    (%rax),%eax
mov    0x2d4c(%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    0x2d38(%rip),%rax
cmp    %rbx,(%rax)
jne    12b6 <ns_parserr+0x176>
movl   $0x0,0x8(%r14)
xorps  %xmm0,%xmm0
movups %xmm0,0x10(%r14)
addl   $0x1,(%r15)
xor    %r12d,%r12d
jmp    127c <ns_parserr+0x13c>
mov    0x8(%r15),%rsi
mov    0x2d27(%rip),%rax
movslq (%rax),%rax
add    %rsi,%rax
cmp    0x20(%r15),%rax
jg     1250 <ns_parserr+0x110>
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     1250 <ns_parserr+0x110>
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     1250 <ns_parserr+0x110>
mov    %rax,0x10(%r14)
mov    %rcx,0x8(%r15)
jmp    12ad <ns_parserr+0x16d>

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

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