#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_3__ TYPE_1__;

/* Type definitions */
typedef TYPE_1__ *res_state;
typedef scalar_t__ ns_sect;
typedef int /*<<< orphan*/ ns_rr;
typedef scalar_t__ ns_opcode;
typedef int /*<<< orphan*/ ns_msg;
struct TYPE_3__ {
  int pfcode;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ ENODEV;
scalar_t__ ENOSPC;
int RES_PRF_HEAD1;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ ns_f_opcode;
scalar_t__ ns_msg_getflag(int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ ns_parserr(int /*<<< orphan*/ *, scalar_t__, int,
                      int /*<<< orphan*/ *);
int /*<<< orphan*/ ns_rr_class(int /*<<< orphan*/);
char *ns_rr_name(int /*<<< orphan*/);
int /*<<< orphan*/ ns_rr_type(int /*<<< orphan*/);
scalar_t__ ns_s_qd;
int ns_sprintrr(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                int /*<<< orphan*/ *, int /*<<< orphan*/ *, char *, int);
char *p_class(int /*<<< orphan*/);
char *p_section(scalar_t__, scalar_t__);
char *p_type(int /*<<< orphan*/);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/ *);
char *strerror(scalar_t__);
void do_section(const res_state statp, ns_msg *handle, ns_sect section,
                int pflag, FILE *file) {
  int n, sflag, rrnum;
  static int buflen = 2048;
  char *buf;
  ns_opcode opcode;
  ns_rr rr;
  sflag = (statp->pfcode & pflag);
  if (statp->pfcode && !sflag)
    return;
  buf = malloc(buflen);
  if (buf == NULL) {
    fprintf(file, ";; memory allocation failure\n");
    return;
  }
  opcode = (ns_opcode)ns_msg_getflag(*handle, ns_f_opcode);
  rrnum = 0;
  for (;;) {
    if (ns_parserr(handle, section, rrnum, &rr)) {
      if (errno != ENODEV)
        fprintf(file, ";; ns_parserr: %s\n", strerror(errno));
      else if (rrnum > 0 && sflag != 0 && (statp->pfcode & RES_PRF_HEAD1))
        putc('\n', file);
      goto cleanup;
    }
    if (rrnum == 0 && sflag != 0 && (statp->pfcode & RES_PRF_HEAD1))
      fprintf(file, ";; %s SECTION:\n", p_section(section, opcode));
    if (section == ns_s_qd)
      fprintf(file, ";;\t%s, type = %s, class = %s\n", ns_rr_name(rr),
              p_type(ns_rr_type(rr)), p_class(ns_rr_class(rr)));
    else {
      n = ns_sprintrr(handle, &rr, NULL, NULL, buf, buflen);
      if (n < 0) {
        if (errno == ENOSPC) {
          free(buf);
          buf = NULL;
          if (buflen < 131072)
            buf = malloc(buflen += 1024);
          if (buf == NULL) {
            fprintf(file, ";; memory allocation failure\n");
            return;
          }
          continue;
        }
        fprintf(file, ";; ns_sprintrr: %s\n", strerror(errno));
        goto cleanup;
      }
      fputs(buf, file);
      fputc('\n', file);
    }
    rrnum++;
  }
cleanup:
  free(buf);
}


x86 assembly (clang, -O0):
<do_section>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
and    -0x1c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0x0,(%rax)
je     1246 <do_section+0x46>
cmpl   $0x0,-0x30(%rbp)
jne    1246 <do_section+0x46>
jmp    1511 <do_section+0x311>
mov    0x2e54(%rip),%edi
call   10e0 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1277 <do_section+0x77>
mov    -0x28(%rbp),%rdi
lea    0xd95(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
jmp    1511 <do_section+0x311>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    0x2d6c(%rip),%rax
mov    (%rax),%esi
call   10b0 <ns_msg_getflag@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x34(%rbp),%edx
lea    -0x4c(%rbp),%rcx
call   1040 <ns_parserr@plt>
cmp    $0x0,%rax
je     1343 <do_section+0x143>
mov    0x2d0d(%rip),%rax
mov    (%rax),%rax
mov    0x2cf3(%rip),%rcx
cmp    (%rcx),%rax
je     12ff <do_section+0xff>
mov    -0x28(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    0x2ceb(%rip),%rax
mov    (%rax),%rdi
call   1120 <strerror@plt>
mov    -0x58(%rbp),%rdi
mov    %rax,%rdx
lea    0xd2b(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
jmp    133e <do_section+0x13e>
cmpl   $0x0,-0x34(%rbp)
jle    1339 <do_section+0x139>
cmpl   $0x0,-0x30(%rbp)
je     1339 <do_section+0x139>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    0x2cb0(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1339 <do_section+0x139>
mov    -0x28(%rbp),%rsi
mov    $0xa,%edi
call   1090 <putc@plt>
jmp    133e <do_section+0x13e>
jmp    1508 <do_section+0x308>
cmpl   $0x0,-0x34(%rbp)
jne    1399 <do_section+0x199>
cmpl   $0x0,-0x30(%rbp)
je     1399 <do_section+0x199>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    0x2c6c(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1399 <do_section+0x199>
mov    -0x28(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1070 <p_section@plt>
mov    -0x60(%rbp),%rdi
mov    %rax,%rdx
lea    0xc9f(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    0x2c3c(%rip),%rcx
cmp    (%rcx),%rax
jne    1405 <do_section+0x205>
mov    -0x28(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x4c(%rbp),%edi
call   1100 <ns_rr_name@plt>
mov    %rax,-0x70(%rbp)
mov    -0x4c(%rbp),%edi
call   10d0 <ns_rr_type@plt>
mov    %eax,%edi
call   10f0 <p_type@plt>
mov    %rax,-0x68(%rbp)
mov    -0x4c(%rbp),%edi
call   1110 <ns_rr_class@plt>
mov    %eax,%edi
call   10a0 <p_class@plt>
mov    -0x78(%rbp),%rdi
mov    -0x70(%rbp),%rdx
mov    -0x68(%rbp),%rcx
mov    %rax,%r8
lea    0xc48(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
jmp    14fa <do_section+0x2fa>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%r8
mov    0x2c8c(%rip),%r9d
lea    -0x4c(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1050 <ns_sprintrr@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    14df <do_section+0x2df>
mov    0x2b90(%rip),%rax
mov    (%rax),%rax
mov    0x2b7e(%rip),%rcx
cmp    (%rcx),%rax
jne    14ae <do_section+0x2ae>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x40(%rbp)
cmpl   $0x20000,0x2c3a(%rip)
jge    1487 <do_section+0x287>
mov    0x2c2e(%rip),%edi
add    $0x400,%edi
mov    %edi,0x2c22(%rip)
call   10e0 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    14a9 <do_section+0x2a9>
mov    -0x28(%rbp),%rdi
lea    0xb63(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
jmp    1511 <do_section+0x311>
jmp    1296 <do_section+0x96>
mov    -0x28(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    0x2b0b(%rip),%rax
mov    (%rax),%rdi
call   1120 <strerror@plt>
mov    -0x80(%rbp),%rdi
mov    %rax,%rdx
lea    0xb8c(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
jmp    1508 <do_section+0x308>
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <fputs@plt>
mov    -0x28(%rbp),%rsi
mov    $0xa,%edi
call   1080 <fputc@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1296 <do_section+0x96>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_section>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,0x8(%rsp)
mov    %ecx,%r12d
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %rdi,0x10(%rsp)
mov    (%rdi),%eax
and    %eax,%r12d
test   %eax,%eax
je     1243 <do_section+0x33>
test   %r12d,%r12d
je     14a8 <do_section+0x298>
mov    0x2e5f(%rip),%edi
call   10e0 <malloc@plt>
test   %rax,%rax
je     145c <do_section+0x24c>
mov    %rax,%r14
mov    0x0(%rbp),%edi
mov    0x2d8c(%rip),%rax
mov    (%rax),%esi
call   10b0 <ns_msg_getflag@plt>
mov    %rax,0x18(%rsp)
xor    %r15d,%r15d
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r15d,%edx
lea    0x4(%rsp),%rcx
call   1040 <ns_parserr@plt>
test   %rax,%rax
mov    %r14,0x20(%rsp)
je     131c <do_section+0x10c>
jmp    1419 <do_section+0x209>
nopl   0x0(%rax)
mov    0x4(%rsp),%edi
call   1100 <ns_rr_name@plt>
mov    %rax,%r14
mov    0x4(%rsp),%edi
call   10d0 <ns_rr_type@plt>
mov    %eax,%edi
call   10f0 <p_type@plt>
mov    %r13,%rbx
mov    %r12d,%r13d
mov    %rax,%r12
mov    0x4(%rsp),%edi
call   1110 <ns_rr_class@plt>
mov    %eax,%edi
call   10a0 <p_class@plt>
mov    0x8(%rsp),%rdi
lea    0xd60(%rip),%rsi
mov    %r14,%rdx
mov    0x20(%rsp),%r14
mov    %r12,%rcx
mov    %r13d,%r12d
mov    %rbx,%r13
mov    %rax,%r8
xor    %eax,%eax
call   10c0 <fprintf@plt>
add    $0x1,%r15d
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r15d,%edx
lea    0x4(%rsp),%rcx
call   1040 <ns_parserr@plt>
test   %rax,%rax
jne    1419 <do_section+0x209>
test   %r15d,%r15d
jne    135b <do_section+0x14b>
test   %r12d,%r12d
je     135b <do_section+0x14b>
mov    0x2ca3(%rip),%rax
mov    (%rax),%eax
mov    0x10(%rsp),%rcx
test   %eax,(%rcx)
je     135b <do_section+0x14b>
mov    %r13,%rdi
mov    0x18(%rsp),%rsi
call   1070 <p_section@plt>
mov    0x8(%rsp),%rdi
lea    0xce0(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    0x2c7e(%rip),%rax
cmp    %r13,(%rax)
je     12a0 <do_section+0x90>
mov    0x2d36(%rip),%r9d
mov    %rbp,%rdi
lea    0x4(%rsp),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r14,%r8
call   1050 <ns_sprintrr@plt>
test   %eax,%eax
js     13ac <do_section+0x19c>
mov    %r14,%rdi
mov    0x8(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <fputs@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1080 <fputc@plt>
jmp    12fc <do_section+0xec>
mov    0x2c15(%rip),%rax
mov    (%rax),%rdi
mov    0x2c03(%rip),%rax
cmp    (%rax),%rdi
jne    14b7 <do_section+0x2a7>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x2cd4(%rip),%edi
cmp    $0x1ffff,%edi
jg     13f9 <do_section+0x1e9>
add    $0x400,%edi
mov    %edi,0x2cc0(%rip)
call   10e0 <malloc@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1273 <do_section+0x63>
lea    0xc00(%rip),%rdi
mov    $0x1d,%esi
mov    $0x1,%edx
mov    0x8(%rsp),%rcx
call   1120 <fwrite@plt>
jmp    14a8 <do_section+0x298>
mov    0x2ba8(%rip),%rax
mov    (%rax),%rdi
mov    0x2b8e(%rip),%rax
cmp    (%rax),%rdi
jne    1485 <do_section+0x275>
test   %r15d,%r15d
jle    14a0 <do_section+0x290>
test   %r12d,%r12d
je     14a0 <do_section+0x290>
mov    0x2b90(%rip),%rax
mov    (%rax),%eax
mov    0x10(%rsp),%rcx
test   %eax,(%rcx)
je     14a0 <do_section+0x290>
mov    $0xa,%edi
mov    0x8(%rsp),%rsi
call   1090 <putc@plt>
jmp    14a0 <do_section+0x290>
lea    0xb9d(%rip),%rdi
mov    $0x1d,%esi
mov    $0x1,%edx
mov    0x8(%rsp),%rcx
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1120 <fwrite@plt>
call   1130 <strerror@plt>
lea    0xb8d(%rip),%rsi
mov    0x8(%rsp),%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
call   1130 <strerror@plt>
lea    0xb9c(%rip),%rsi
jmp    1491 <do_section+0x281>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32 }
@do_section.buflen = internal global i32 2048
@.str = [30 x i8] c";; memory allocation failure\0A\00"
@ns_f_opcode = global i32 0
@errno = global i64 0
@ENODEV = global i64 0
@.str.1 = [19 x i8] c";; ns_parserr: %s\0A\00"
@RES_PRF_HEAD1 = global i32 0
@.str.2 = [16 x i8] c";; %s SECTION:\0A\00"
@ns_s_qd = global i64 0
@.str.3 = [30 x i8] c";;\09%s, type = %s, class = %s\0A\00"
@ENOSPC = global i64 0
@.str.4 = [20 x i8] c";; ns_sprintrr: %s\0A\00"
define void @do_section(%struct.TYPE_3__* %0, i32* %1, i64 %2, i32 %3, i32* %4) {
%6 = alloca %struct.TYPE_3__*
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i32
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %6
store i32* %1, i32** %7
store i64 %2, i64* %8
store i32 %3, i32* %9
store i32* %4, i32** %10
%17 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i32 0, i32 0
%19 = load i32, i32* %18
%20 = load i32, i32* %9
%21 = and i32 %19, %20
store i32 %21, i32* %12
%22 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%23 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %22, i32 0, i32 0
%24 = load i32, i32* %23
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %5
%27 = load i32, i32* %12
%28 = icmp ne i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %26
br label %154
30: ; preds = %26, %5
%31 = load i32, i32* @do_section.buflen
%32 = call i8* @malloc(i32 %31)
store i8* %32, i8** %14
%33 = load i8*, i8** %14
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %38
35: ; preds = %30
%36 = load i32*, i32** %10
%37 = call i32 (i32*, i8*, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %154
38: ; preds = %30
%39 = load i32*, i32** %7
%40 = load i32, i32* %39
%41 = load i32, i32* @ns_f_opcode
%42 = call i64 @ns_msg_getflag(i32 %40, i32 %41)
store i64 %42, i64* %15
store i32 0, i32* %13
br label %43
43: ; preds = %148, %136, %38
%44 = load i32*, i32** %7
%45 = load i64, i64* %8
%46 = load i32, i32* %13
%47 = call i64 @ns_parserr(i32* %44, i64 %45, i32 %46, i32* %16)
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %76
49: ; preds = %43
%50 = load i64, i64* @errno
%51 = load i64, i64* @ENODEV
%52 = icmp ne i64 %50, %51
br i1 %52, label %53, label %58
53: ; preds = %49
%54 = load i32*, i32** %10
%55 = load i64, i64* @errno
%56 = call i8* @strerror(i64 %55)
%57 = call i32 (i32*, i8*, ...) @fprintf(i32* %54, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %56)
br label %75
58: ; preds = %49
%59 = load i32, i32* %13
%60 = icmp sgt i32 %59, 0
br i1 %60, label %61, label %74
61: ; preds = %58
%62 = load i32, i32* %12
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %74
64: ; preds = %61
%65 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%66 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %65, i32 0, i32 0
%67 = load i32, i32* %66
%68 = load i32, i32* @RES_PRF_HEAD1
%69 = and i32 %67, %68
%70 = icmp ne i32 %69, 0
br i1 %70, label %71, label %74
71: ; preds = %64
%72 = load i32*, i32** %10
%73 = call i32 @putc(i8 signext 10, i32* %72)
br label %74
74: ; preds = %71, %64, %61, %58
br label %75
75: ; preds = %74, %53
br label %151
76: ; preds = %43
%77 = load i32, i32* %13
%78 = icmp eq i32 %77, 0
br i1 %78, label %79, label %95
79: ; preds = %76
%80 = load i32, i32* %12
%81 = icmp ne i32 %80, 0
br i1 %81, label %82, label %95
82: ; preds = %79
%83 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%84 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %83, i32 0, i32 0
%85 = load i32, i32* %84
%86 = load i32, i32* @RES_PRF_HEAD1
%87 = and i32 %85, %86
%88 = icmp ne i32 %87, 0
br i1 %88, label %89, label %95
89: ; preds = %82
%90 = load i32*, i32** %10
%91 = load i64, i64* %8
%92 = load i64, i64* %15
%93 = call i8* @p_section(i64 %91, i64 %92)
%94 = call i32 (i32*, i8*, ...) @fprintf(i32* %90, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %93)
br label %95
95: ; preds = %89, %82, %79, %76
%96 = load i64, i64* %8
%97 = load i64, i64* @ns_s_qd
%98 = icmp eq i64 %96, %97
br i1 %98, label %99, label %110
99: ; preds = %95
%100 = load i32*, i32** %10
%101 = load i32, i32* %16
%102 = call i8* @ns_rr_name(i32 %101)
%103 = load i32, i32* %16
%104 = call i32 @ns_rr_type(i32 %103)
%105 = call i8* @p_type(i32 %104)
%106 = load i32, i32* %16
%107 = call i32 @ns_rr_class(i32 %106)
%108 = call i8* @p_class(i32 %107)
%109 = call i32 (i32*, i8*, ...) @fprintf(i32* %100, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %102, i8* %105, i8* %108)
br label %148
110: ; preds = %95
%111 = load i32*, i32** %7
%112 = load i8*, i8** %14
%113 = load i32, i32* @do_section.buflen
%114 = call i32 @ns_sprintrr(i32* %111, i32* %16, i32* null, i32* null, i8* %112, i32 %113)
store i32 %114, i32* %11
%115 = load i32, i32* %11
%116 = icmp slt i32 %115, 0
br i1 %116, label %117, label %142
117: ; preds = %110
%118 = load i64, i64* @errno
%119 = load i64, i64* @ENOSPC
%120 = icmp eq i64 %118, %119
br i1 %120, label %121, label %137
121: ; preds = %117
%122 = load i8*, i8** %14
%123 = call i32 @free(i8* %122)
store i8* null, i8** %14
%124 = load i32, i32* @do_section.buflen
%125 = icmp slt i32 %124, 131072
br i1 %125, label %126, label %130
126: ; preds = %121
%127 = load i32, i32* @do_section.buflen
%128 = add nsw i32 %127, 1024
store i32 %128, i32* @do_section.buflen
%129 = call i8* @malloc(i32 %128)
store i8* %129, i8** %14
br label %130
130: ; preds = %126, %121
%131 = load i8*, i8** %14
%132 = icmp eq i8* %131, null
br i1 %132, label %133, label %136
133: ; preds = %130
%134 = load i32*, i32** %10
%135 = call i32 (i32*, i8*, ...) @fprintf(i32* %134, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %154
136: ; preds = %130
br label %43
137: ; preds = %117
%138 = load i32*, i32** %10
%139 = load i64, i64* @errno
%140 = call i8* @strerror(i64 %139)
%141 = call i32 (i32*, i8*, ...) @fprintf(i32* %138, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %140)
br label %151
142: ; preds = %110
%143 = load i8*, i8** %14
%144 = load i32*, i32** %10
%145 = call i32 @fputs(i8* %143, i32* %144)
%146 = load i32*, i32** %10
%147 = call i32 @fputc(i8 signext 10, i32* %146)
br label %148
148: ; preds = %142, %99
%149 = load i32, i32* %13
%150 = add nsw i32 %149, 1
store i32 %150, i32* %13
br label %43
151: ; preds = %137, %75
%152 = load i8*, i8** %14
%153 = call i32 @free(i8* %152)
br label %154
154: ; preds = %151, %133, %35, %29
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32 }
@do_section.buflen = internal unnamed_addr global i32 2048
@.str = [30 x i8] c";; memory allocation failure\0A\00"
@ns_f_opcode = global i32 0
@errno = global i64 0
@ENODEV = global i64 0
@.str.1 = [19 x i8] c";; ns_parserr: %s\0A\00"
@RES_PRF_HEAD1 = global i32 0
@.str.2 = [16 x i8] c";; %s SECTION:\0A\00"
@ns_s_qd = global i64 0
@.str.3 = [30 x i8] c";;\09%s, type = %s, class = %s\0A\00"
@ENOSPC = global i64 0
@.str.4 = [20 x i8] c";; ns_sprintrr: %s\0A\00"
define void @do_section(%struct.TYPE_3__* nocapture %0, i32* %1, i64 %2, i32 %3, i32* nocapture %4) {
%6 = alloca i32
%7 = bitcast i32* %6 to i8*
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%9 = load i32, i32* %8
%10 = and i32 %9, %3
%11 = icmp eq i32 %9, 0
%12 = icmp ne i32 %10, 0
%13 = or i1 %11, %12
br i1 %13, label %14, label %102
14: ; preds = %5
%15 = load i32, i32* @do_section.buflen
%16 = tail call i8* @malloc(i32 %15)
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = tail call i64 @fwrite(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i64 29, i64 1, i32* %4)
br label %102
20: ; preds = %14
%21 = load i32, i32* %1
%22 = load i32, i32* @ns_f_opcode
%23 = tail call i64 @ns_msg_getflag(i32 %21, i32 %22)
br label %24
24: ; preds = %84, %20
%25 = phi i8* [ %86, %84 ], [ %16, %20 ]
%26 = phi i32 [ %48, %84 ], [ 0, %20 ]
%27 = call i64 @ns_parserr(i32* %1, i64 %2, i32 %26, i32* %6)
%28 = icmp eq i64 %27, 0
br i1 %28, label %47, label %29
29: ; preds = %24, %96
%30 = phi i32 [ %97, %96 ], [ %26, %24 ]
%31 = load i64, i64* @errno
%32 = load i64, i64* @ENODEV
%33 = icmp eq i64 %31, %32
br i1 %33, label %37, label %34
34: ; preds = %29
%35 = call i8* @strerror(i64 %31)
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %35)
br label %100
37: ; preds = %29
%38 = icmp sgt i32 %30, 0
%39 = select i1 %38, i1 %12, i1 false
br i1 %39, label %40, label %100
40: ; preds = %37
%41 = load i32, i32* %8
%42 = load i32, i32* @RES_PRF_HEAD1
%43 = and i32 %42, %41
%44 = icmp eq i32 %43, 0
br i1 %44, label %100, label %45
45: ; preds = %40
%46 = call i32 @putc(i8 signext 10, i32* %4)
br label %100
47: ; preds = %24, %96
%48 = phi i32 [ %97, %96 ], [ %26, %24 ]
%49 = icmp eq i32 %48, 0
%50 = select i1 %49, i1 %12, i1 false
br i1 %50, label %51, label %59
51: ; preds = %47
%52 = load i32, i32* %8
%53 = load i32, i32* @RES_PRF_HEAD1
%54 = and i32 %53, %52
%55 = icmp eq i32 %54, 0
br i1 %55, label %59, label %56
56: ; preds = %51
%57 = call i8* @p_section(i64 %2, i64 %23)
%58 = call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %57)
br label %59
59: ; preds = %56, %51, %47
%60 = load i64, i64* @ns_s_qd
%61 = icmp eq i64 %60, %2
br i1 %61, label %62, label %72
62: ; preds = %59
%63 = load i32, i32* %6
%64 = call i8* @ns_rr_name(i32 %63)
%65 = load i32, i32* %6
%66 = call i32 @ns_rr_type(i32 %65)
%67 = call i8* @p_type(i32 %66)
%68 = load i32, i32* %6
%69 = call i32 @ns_rr_class(i32 %68)
%70 = call i8* @p_class(i32 %69)
%71 = call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %64, i8* %67, i8* %70)
br label %96
72: ; preds = %59
%73 = load i32, i32* @do_section.buflen
%74 = call i32 @ns_sprintrr(i32* %1, i32* %6, i32* null, i32* null, i8* %25, i32 %73)
%75 = icmp slt i32 %74, 0
br i1 %75, label %76, label %93
76: ; preds = %72
%77 = load i64, i64* @errno
%78 = load i64, i64* @ENOSPC
%79 = icmp eq i64 %77, %78
br i1 %79, label %80, label %90
80: ; preds = %76
%81 = call i32 @free(i8* %25)
%82 = load i32, i32* @do_section.buflen
%83 = icmp slt i32 %82, 131072
br i1 %83, label %84, label %88
84: ; preds = %80
%85 = add nsw i32 %82, 1024
store i32 %85, i32* @do_section.buflen
%86 = call i8* @malloc(i32 %85)
%87 = icmp eq i8* %86, null
br i1 %87, label %88, label %24
88: ; preds = %80, %84
%89 = call i64 @fwrite(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i64 29, i64 1, i32* %4)
br label %102
90: ; preds = %76
%91 = call i8* @strerror(i64 %77)
%92 = call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %91)
br label %100
93: ; preds = %72
%94 = call i32 @fputs(i8* %25, i32* %4)
%95 = call i32 @fputc(i8 signext 10, i32* %4)
br label %96
96: ; preds = %93, %62
%97 = add nsw i32 %48, 1
%98 = call i64 @ns_parserr(i32* %1, i64 %2, i32 %97, i32* %6)
%99 = icmp eq i64 %98, 0
br i1 %99, label %47, label %29
100: ; preds = %34, %45, %40, %37, %90
%101 = call i32 @free(i8* %25)
br label %102
102: ; preds = %5, %100, %88, %18
ret void
}