#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 /*<<< orphan*/ uint8_t;
typedef scalar_t__ uint16_t;

/* Variables and functions */
scalar_t__ dns_response_get16(int /*<<< orphan*/ const *);
int /*<<< orphan*/ *skip_labels(int /*<<< orphan*/ const *);
const uint8_t *skip_questions(const uint8_t *dns_response) {
  uint16_t qdcount;
  const uint8_t *presp;
  uint16_t ientry;
  qdcount = dns_response_get16(&dns_response[4]);
  presp = &dns_response[12];
  for (ientry = 0; ientry < qdcount; ientry++) {
    presp = skip_labels(presp);
    if (presp == NULL) {
      break;
    }
    presp += (2 + 2);
  }
  if (ientry != qdcount) {
    presp = NULL;
  }
  return presp;
}


x86 assembly (clang, -O0):
<skip_questions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x10,%rdi
call   1040 <dns_response_get16@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    1199 <skip_questions+0x79>
mov    -0x18(%rbp),%rdi
call   1030 <skip_labels@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    117c <skip_questions+0x5c>
jmp    1199 <skip_questions+0x79>
mov    -0x18(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1151 <skip_questions+0x31>
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     11af <skip_questions+0x8f>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_questions>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
add    $0x10,%rdi
call   1040 <dns_response_get16@plt>
mov    %rax,%r14
add    $0x30,%rbx
xor    %r15d,%r15d
test   %rax,%rax
jle    1164 <skip_questions+0x44>
mov    %rbx,%rdi
call   1030 <skip_labels@plt>
test   %rax,%rax
je     1162 <skip_questions+0x42>
mov    %rax,%rbx
add    $0x10,%rbx
add    $0x1,%r15
cmp    %r15,%r14
jne    1140 <skip_questions+0x20>
mov    %r14,%r15
jmp    1164 <skip_questions+0x44>
xor    %ebx,%ebx
xor    %eax,%eax
cmp    %r14,%r15
cmove  %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32* @skip_questions(i32* %0) {
%2 = alloca i32*
%3 = alloca i64
%4 = alloca i32*
%5 = alloca i64
store i32* %0, i32** %2
%6 = load i32*, i32** %2
%7 = getelementptr inbounds i32, i32* %6, i64 4
%8 = call i64 @dns_response_get16(i32* %7)
store i64 %8, i64* %3
%9 = load i32*, i32** %2
%10 = getelementptr inbounds i32, i32* %9, i64 12
store i32* %10, i32** %4
store i64 0, i64* %5
br label %11
11: ; preds = %24, %1
%12 = load i64, i64* %5
%13 = load i64, i64* %3
%14 = icmp slt i64 %12, %13
br i1 %14, label %15, label %27
15: ; preds = %11
%16 = load i32*, i32** %4
%17 = call i32* @skip_labels(i32* %16)
store i32* %17, i32** %4
%18 = load i32*, i32** %4
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %21
20: ; preds = %15
br label %27
21: ; preds = %15
%22 = load i32*, i32** %4
%23 = getelementptr inbounds i32, i32* %22, i64 4
store i32* %23, i32** %4
br label %24
24: ; preds = %21
%25 = load i64, i64* %5
%26 = add nsw i64 %25, 1
store i64 %26, i64* %5
br label %11
27: ; preds = %20, %11
%28 = load i64, i64* %5
%29 = load i64, i64* %3
%30 = icmp ne i64 %28, %29
br i1 %30, label %31, label %32
31: ; preds = %27
store i32* null, i32** %4
br label %32
32: ; preds = %31, %27
%33 = load i32*, i32** %4
ret i32* %33
}

LLVM IR (-O2):
define i32* @skip_questions(i32* %0) {
%2 = getelementptr inbounds i32, i32* %0, i64 4
%3 = tail call i64 @dns_response_get16(i32* %2)
%4 = getelementptr inbounds i32, i32* %0, i64 12
%5 = icmp sgt i64 %3, 0
br i1 %5, label %6, label %15
6: ; preds = %1, %11
%7 = phi i64 [ %13, %11 ], [ 0, %1 ]
%8 = phi i32* [ %12, %11 ], [ %4, %1 ]
%9 = tail call i32* @skip_labels(i32* %8)
%10 = icmp eq i32* %9, null
br i1 %10, label %15, label %11
11: ; preds = %6
%12 = getelementptr inbounds i32, i32* %9, i64 4
%13 = add nuw nsw i64 %7, 1
%14 = icmp eq i64 %13, %3
br i1 %14, label %15, label %6
15: ; preds = %11, %6, %1
%16 = phi i64 [ 0, %1 ], [ %7, %6 ], [ %3, %11 ]
%17 = phi i32* [ %4, %1 ], [ null, %6 ], [ %12, %11 ]
%18 = icmp eq i64 %16, %3
%19 = select i1 %18, i32* %17, i32* null
ret i32* %19
}