#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_7__ TYPE_2__;
typedef struct TYPE_6__ TYPE_1__;

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

/* Variables and functions */
int /*<<< orphan*/ EMSGSIZE;
int /*<<< orphan*/ ENODEV;
int /*<<< orphan*/ NS_GET16(int, int);
int /*<<< orphan*/ NS_GET32(scalar_t__, int);
int NS_INT16SZ;
int NS_INT32SZ;
int /*<<< orphan*/ NS_MAXDNAME;
int dn_expand(int /*<<< orphan*/, int, int, int /*<<< orphan*/,
              int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ local_ns_setsection(TYPE_2__ *, int);
int local_ns_skiprr(int, int, int, int);
int ns_s_max;
int ns_s_qd;
int local_ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
  int b;
  int tmp;
  tmp = section;
  if (tmp < 0 || section >= ns_s_max) {
    errno = ENODEV;
    return -1;
  }
  if (section != handle->_sect)
    local_ns_setsection(handle, section);
  if (rrnum == -1)
    rrnum = handle->_rrnum;
  if (rrnum < 0 || rrnum >= handle->_counts[(int)section]) {
    errno = ENODEV;
    return -1;
  }
  if (rrnum < handle->_rrnum)
    local_ns_setsection(handle, section);
  if (rrnum > handle->_rrnum) {
    b = local_ns_skiprr(handle->_msg_ptr, 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 + NS_INT16SZ > handle->_eom) {
    errno = EMSGSIZE;
    return -1;
  }
  NS_GET16(rr->type, handle->_msg_ptr);
  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 + NS_INT16SZ > handle->_eom) {
      errno = EMSGSIZE;
      return -1;
    }
    NS_GET32(rr->ttl, handle->_msg_ptr);
    NS_GET16(rr->rdlength, handle->_msg_ptr);
    if (handle->_msg_ptr + rr->rdlength > handle->_eom) {
      errno = EMSGSIZE;
      return -1;
    }
    rr->rdata = handle->_msg_ptr;
    handle->_msg_ptr += rr->rdlength;
  }
  if (++handle->_rrnum > handle->_counts[(int)section])
    local_ns_setsection(handle, (ns_sect)((int)section + 1));
  return 0;
}


x86 assembly (clang, -O0):
<local_ns_parserr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jl     1188 <local_ns_parserr+0x38>
mov    -0x14(%rbp),%eax
mov    0x2e20(%rip),%rcx
cmp    (%rcx),%eax
jl     11a6 <local_ns_parserr+0x56>
mov    0x2e29(%rip),%rax
mov    (%rax),%ecx
mov    0x2e28(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1482 <local_ns_parserr+0x332>
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
je     11c1 <local_ns_parserr+0x71>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <local_ns_setsection@plt>
cmpl   $0xffffffff,-0x18(%rbp)
jne    11d5 <local_ns_parserr+0x85>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     11f7 <local_ns_parserr+0xa7>
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    0x8(%rcx),%rcx
movslq -0x14(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jl     1215 <local_ns_parserr+0xc5>
mov    0x2dba(%rip),%rax
mov    (%rax),%ecx
mov    0x2db9(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1482 <local_ns_parserr+0x332>
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    0x4(%rcx),%eax
jge    1231 <local_ns_parserr+0xe1>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <local_ns_setsection@plt>
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    0x4(%rcx),%eax
jle    1291 <local_ns_parserr+0x141>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
sub    0x4(%rax),%ecx
call   1060 <local_ns_skiprr@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    127a <local_ns_parserr+0x12a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1482 <local_ns_parserr+0x332>
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
add    0x10(%rax),%ecx
mov    %ecx,0x10(%rax)
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%esi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%edx
mov    -0x20(%rbp),%rax
mov    0x20(%rax),%ecx
mov    0x2d2c(%rip),%rax
mov    (%rax),%r8d
call   1070 <dn_expand@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    12d5 <local_ns_parserr+0x185>
movl   $0xffffffff,-0x4(%rbp)
jmp    1482 <local_ns_parserr+0x332>
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
add    0x10(%rax),%ecx
mov    %ecx,0x10(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%eax
mov    0x2cc0(%rip),%rcx
add    (%rcx),%eax
mov    0x2cb7(%rip),%rcx
add    (%rcx),%eax
mov    -0x10(%rbp),%rcx
cmp    0x14(%rcx),%eax
jle    1326 <local_ns_parserr+0x1d6>
mov    0x2cc9(%rip),%rax
mov    (%rax),%ecx
mov    0x2ca8(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1482 <local_ns_parserr+0x332>
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%esi
call   1040 <NS_GET16@plt>
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%esi
call   1040 <NS_GET16@plt>
mov    -0x14(%rbp),%eax
mov    0x2c7b(%rip),%rcx
cmp    (%rcx),%eax
jne    1385 <local_ns_parserr+0x235>
mov    -0x20(%rbp),%rax
movq   $0x0,0x18(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,0x8(%rax)
mov    -0x20(%rbp),%rax
movq   $0x0,0x10(%rax)
jmp    144a <local_ns_parserr+0x2fa>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%eax
mov    0x2c55(%rip),%rcx
add    (%rcx),%eax
mov    0x2c14(%rip),%rcx
add    (%rcx),%eax
mov    -0x10(%rbp),%rcx
cmp    0x14(%rcx),%eax
jle    13c9 <local_ns_parserr+0x279>
mov    0x2c26(%rip),%rax
mov    (%rax),%ecx
mov    0x2c05(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1482 <local_ns_parserr+0x332>
mov    -0x20(%rbp),%rax
mov    0x18(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%esi
call   1030 <NS_GET32@plt>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%esi
call   1040 <NS_GET16@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%eax
mov    -0x20(%rbp),%rcx
add    0x8(%rcx),%eax
mov    -0x10(%rbp),%rcx
cmp    0x14(%rcx),%eax
jle    1429 <local_ns_parserr+0x2d9>
mov    0x2bc6(%rip),%rax
mov    (%rax),%ecx
mov    0x2ba5(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1482 <local_ns_parserr+0x332>
mov    -0x10(%rbp),%rax
movslq 0x10(%rax),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x10(%rbp),%rax
add    0x10(%rax),%ecx
mov    %ecx,0x10(%rax)
mov    -0x10(%rbp),%rcx
mov    0x4(%rcx),%eax
add    $0x1,%eax
mov    %eax,0x4(%rcx)
mov    -0x10(%rbp),%rcx
mov    0x8(%rcx),%rcx
movslq -0x14(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jle    147b <local_ns_parserr+0x32b>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
call   1050 <local_ns_setsection@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<local_ns_parserr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
js     1278 <local_ns_parserr+0x128>
mov    %esi,%ebx
mov    0x2e34(%rip),%rax
cmp    %esi,(%rax)
jle    1278 <local_ns_parserr+0x128>
mov    %rcx,%r15
mov    %edx,%ebp
mov    %rdi,%r14
cmp    %ebx,(%rdi)
jne    118e <local_ns_parserr+0x3e>
cmp    $0xffffffff,%ebp
je     119d <local_ns_parserr+0x4d>
test   %ebp,%ebp
jns    11a9 <local_ns_parserr+0x59>
jmp    1278 <local_ns_parserr+0x128>
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <local_ns_setsection@plt>
cmp    $0xffffffff,%ebp
jne    1185 <local_ns_parserr+0x35>
mov    0x4(%r14),%ebp
test   %ebp,%ebp
js     1278 <local_ns_parserr+0x128>
mov    0x8(%r14),%rax
mov    %ebx,%r12d
cmp    (%rax,%r12,4),%ebp
jge    1278 <local_ns_parserr+0x128>
mov    0x4(%r14),%eax
cmp    %eax,%ebp
jge    11d0 <local_ns_parserr+0x80>
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <local_ns_setsection@plt>
mov    0x4(%r14),%eax
mov    %ebp,%ecx
mov    0x10(%r14),%edx
sub    %eax,%ecx
jle    11fd <local_ns_parserr+0xad>
mov    0x14(%r14),%esi
mov    %edx,%edi
mov    %ebx,%edx
call   1060 <local_ns_skiprr@plt>
test   %eax,%eax
js     128a <local_ns_parserr+0x13a>
mov    %eax,%edx
add    0x10(%r14),%edx
mov    %edx,0x10(%r14)
mov    %ebp,0x4(%r14)
mov    0x14(%r14),%esi
mov    0x18(%r14),%edi
mov    0x20(%r15),%ecx
mov    0x2dd0(%rip),%rax
mov    (%rax),%r8d
call   1070 <dn_expand@plt>
mov    $0xffffffff,%ebp
test   %eax,%eax
js     128f <local_ns_parserr+0x13f>
add    0x10(%r14),%eax
mov    %eax,0x10(%r14)
mov    0x2d80(%rip),%r13
mov    0x0(%r13),%ecx
lea    (%rax,%rcx,2),%ecx
cmp    0x14(%r14),%ecx
jg     12df <local_ns_parserr+0x18f>
mov    (%r15),%edi
mov    %eax,%esi
call   1040 <NS_GET16@plt>
mov    0x4(%r15),%edi
mov    0x10(%r14),%esi
call   1040 <NS_GET16@plt>
mov    0x2d71(%rip),%rax
cmp    %ebx,(%rax)
jne    12a0 <local_ns_parserr+0x150>
movl   $0x0,0x8(%r15)
xorps  %xmm0,%xmm0
movups %xmm0,0x10(%r15)
jmp    12fb <local_ns_parserr+0x1ab>
mov    0x2d39(%rip),%rax
mov    (%rax),%eax
mov    0x2d38(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x10(%r14),%esi
mov    0x2d3d(%rip),%rax
mov    (%rax),%eax
add    %esi,%eax
add    0x0(%r13),%eax
cmp    0x14(%r14),%eax
jg     12df <local_ns_parserr+0x18f>
mov    0x18(%r15),%rdi
call   1030 <NS_GET32@plt>
mov    0x8(%r15),%edi
mov    0x10(%r14),%esi
call   1040 <NS_GET16@plt>
movslq 0x10(%r14),%rax
mov    0x8(%r15),%ecx
add    %eax,%ecx
cmp    0x14(%r14),%ecx
jle    12f3 <local_ns_parserr+0x1a3>
mov    0x2cf2(%rip),%rax
mov    (%rax),%eax
mov    0x2cd1(%rip),%rcx
mov    %eax,(%rcx)
jmp    128f <local_ns_parserr+0x13f>
mov    %rax,0x10(%r15)
mov    %ecx,0x10(%r14)
mov    0x4(%r14),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0x4(%r14)
mov    0x8(%r14),%rcx
xor    %ebp,%ebp
cmp    (%rcx,%r12,4),%eax
jl     128f <local_ns_parserr+0x13f>
add    $0x1,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <local_ns_setsection@plt>
jmp    128f <local_ns_parserr+0x13f>

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

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