#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int *aptr;

/* Variables and functions */
int C_IN;
int QFIXEDSZ;
int ares_expand_name(unsigned char const *, unsigned char const *, int, char **,
                     int *);
char *class_name(int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
char *type_name(int);
const unsigned char *display_question(const unsigned char *aptr,
                                      const unsigned char *abuf, int alen) {
  char *name;
  int type, dnsclass, status, len;
  status = ares_expand_name(aptr, abuf, alen, &name, &len);
  if (status != 0)
    return NULL;
  aptr += len;
  if (aptr + QFIXEDSZ > abuf + alen) {
    free(name);
    return NULL;
  }
  type = (((aptr)[0] << 8) | (aptr)[1]);
  dnsclass = ((((aptr) + 2)[0] << 8) | ((aptr) + 2)[1]);
  aptr += QFIXEDSZ;
  printf("\t%-15s.\t", name);
  if (dnsclass != C_IN)
    printf("\t%s", class_name(dnsclass));
  printf("\t%s\n", type_name(type));
  free(name);
  return aptr;
}


x86 assembly (clang, -O0):
<display_question>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    -0x28(%rbp),%rcx
lea    -0x38(%rbp),%r8
call   1050 <ares_expand_name@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     1195 <display_question+0x45>
movq   $0x0,-0x8(%rbp)
jmp    1288 <display_question+0x138>
mov    -0x38(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2e27(%rip),%rcx
movslq (%rcx),%rcx
add    %rcx,%rax
mov    -0x18(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jbe    11e1 <display_question+0x91>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1288 <display_question+0x138>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
shl    $0x8,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
or     %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%eax
shl    $0x8,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
or     %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    0x2dc1(%rip),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xdce(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%eax
mov    0x2da7(%rip),%rcx
cmp    (%rcx),%eax
je     1260 <display_question+0x110>
mov    -0x30(%rbp),%edi
call   1070 <class_name@plt>
mov    %rax,%rsi
lea    0xdae(%rip),%rdi
call   1040 <printf@plt>
mov    -0x2c(%rbp),%edi
call   1060 <type_name@plt>
mov    %rax,%rsi
lea    0xd9b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_question>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
call   1050 <ares_expand_name@plt>
test   %eax,%eax
je     117e <display_question+0x2e>
xor    %r15d,%r15d
jmp    120b <display_question+0xbb>
movslq 0xc(%rsp),%rax
add    %rax,%rbp
mov    0x2e4b(%rip),%rax
movslq (%rax),%r15
add    %rbp,%r15
movslq %r14d,%rax
add    %rax,%rbx
cmp    %rbx,%r15
jbe    11a3 <display_question+0x53>
xor    %r15d,%r15d
jmp    1201 <display_question+0xb1>
movzwl 0x0(%rbp),%r14d
shl    $0x10,%r14d
bswap  %r14d
movzwl 0x2(%rbp),%ebx
shl    $0x10,%ebx
bswap  %ebx
mov    0x10(%rsp),%rsi
lea    0xe3c(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e18(%rip),%rax
cmp    (%rax),%ebx
je     11ea <display_question+0x9a>
mov    %ebx,%edi
call   1070 <class_name@plt>
lea    0xe27(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %r14d,%edi
call   1060 <type_name@plt>
lea    0xe14(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    %r15,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@QFIXEDSZ = global i32 0
@.str = [9 x i8] c"\09%-15s.\09\00"
@C_IN = global i32 0
@.str.1 = [4 x i8] c"\09%s\00"
@.str.2 = [5 x i8] c"\09%s\0A\00"
define i8* @display_question(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%13 = load i8*, i8** %5
%14 = load i8*, i8** %6
%15 = load i32, i32* %7
%16 = call i32 @ares_expand_name(i8* %13, i8* %14, i32 %15, i8** %8, i32* %12)
store i32 %16, i32* %11
%17 = load i32, i32* %11
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %3
store i8* null, i8** %4
br label %80
20: ; preds = %3
%21 = load i32, i32* %12
%22 = load i8*, i8** %5
%23 = sext i32 %21 to i64
%24 = getelementptr inbounds i8, i8* %22, i64 %23
store i8* %24, i8** %5
%25 = load i8*, i8** %5
%26 = load i32, i32* @QFIXEDSZ
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8*, i8** %6
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = icmp ugt i8* %28, %32
br i1 %33, label %34, label %37
34: ; preds = %20
%35 = load i8*, i8** %8
%36 = call i32 @free(i8* %35)
store i8* null, i8** %4
br label %80
37: ; preds = %20
%38 = load i8*, i8** %5
%39 = getelementptr inbounds i8, i8* %38, i64 0
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = shl i32 %41, 8
%43 = load i8*, i8** %5
%44 = getelementptr inbounds i8, i8* %43, i64 1
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = or i32 %42, %46
store i32 %47, i32* %9
%48 = load i8*, i8** %5
%49 = getelementptr inbounds i8, i8* %48, i64 2
%50 = getelementptr inbounds i8, i8* %49, i64 0
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = shl i32 %52, 8
%54 = load i8*, i8** %5
%55 = getelementptr inbounds i8, i8* %54, i64 2
%56 = getelementptr inbounds i8, i8* %55, i64 1
%57 = load i8, i8* %56
%58 = zext i8 %57 to i32
%59 = or i32 %53, %58
store i32 %59, i32* %10
%60 = load i32, i32* @QFIXEDSZ
%61 = load i8*, i8** %5
%62 = sext i32 %60 to i64
%63 = getelementptr inbounds i8, i8* %61, i64 %62
store i8* %63, i8** %5
%64 = load i8*, i8** %8
%65 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %64)
%66 = load i32, i32* %10
%67 = load i32, i32* @C_IN
%68 = icmp ne i32 %66, %67
br i1 %68, label %69, label %73
69: ; preds = %37
%70 = load i32, i32* %10
%71 = call i8* @class_name(i32 %70)
%72 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %71)
br label %73
73: ; preds = %69, %37
%74 = load i32, i32* %9
%75 = call i8* @type_name(i32 %74)
%76 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %75)
%77 = load i8*, i8** %8
%78 = call i32 @free(i8* %77)
%79 = load i8*, i8** %5
store i8* %79, i8** %4
br label %80
80: ; preds = %73, %34, %19
%81 = load i8*, i8** %4
ret i8* %81
}

LLVM IR (-O2):
@QFIXEDSZ = global i32 0
@.str = [9 x i8] c"\09%-15s.\09\00"
@C_IN = global i32 0
@.str.1 = [4 x i8] c"\09%s\00"
@.str.2 = [5 x i8] c"\09%s\0A\00"
define i8* @display_question(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = bitcast i8** %4 to i8*
%7 = bitcast i32* %5 to i8*
%8 = call i32 @ares_expand_name(i8* %0, i8* %1, i32 %2, i8** %4, i32* %5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %50
10: ; preds = %3
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i32, i32* @QFIXEDSZ
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = sext i32 %2 to i64
%18 = getelementptr inbounds i8, i8* %1, i64 %17
%19 = icmp ugt i8* %16, %18
br i1 %19, label %46, label %20
20: ; preds = %10
%21 = load i8, i8* %13
%22 = zext i8 %21 to i32
%23 = shl nuw nsw i32 %22, 8
%24 = getelementptr inbounds i8, i8* %13, i64 1
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = or i32 %23, %26
%28 = getelementptr inbounds i8, i8* %13, i64 2
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = shl nuw nsw i32 %30, 8
%32 = getelementptr inbounds i8, i8* %28, i64 1
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = or i32 %31, %34
%36 = load i8*, i8** %4
%37 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %36)
%38 = load i32, i32* @C_IN
%39 = icmp eq i32 %35, %38
br i1 %39, label %43, label %40
40: ; preds = %20
%41 = call i8* @class_name(i32 %35)
%42 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %40, %20
%44 = call i8* @type_name(i32 %27)
%45 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %44)
br label %46
46: ; preds = %10, %43
%47 = phi i8* [ %16, %43 ], [ null, %10 ]
%48 = load i8*, i8** %4
%49 = call i32 @free(i8* %48)
br label %50
50: ; preds = %46, %3
%51 = phi i8* [ null, %3 ], [ %47, %46 ]
ret i8* %51
}