#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*/ u_char;

/* Variables and functions */
int NS_MAXCDNAME;
int ns_name_ntop(int /*<<< orphan*/ *, char *, size_t);
int ns_name_unpack(int /*<<< orphan*/ const *, int /*<<< orphan*/ const *,
                   int /*<<< orphan*/ const *, int /*<<< orphan*/ *, int);
int ns_name_uncompress(const u_char *msg, const u_char *eom, const u_char *src,
                       char *dst, size_t dstsiz) {
  u_char tmp[NS_MAXCDNAME];
  int n;
  if ((n = ns_name_unpack(msg, eom, src, tmp, sizeof tmp)) == -1)
    return (-1);
  if (ns_name_ntop(tmp, dst, dstsiz) == -1)
    return (-1);
  return (n);
}


x86 assembly (clang, -O0):
<ns_name_uncompress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
shl    $0x2,%rax
mov    %eax,%r8d
call   1030 <ns_name_unpack@plt>
mov    %eax,-0x44(%rbp)
cmp    $0xffffffff,%eax
jne    11a0 <ns_name_uncompress+0x80>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x48(%rbp)
jmp    11da <ns_name_uncompress+0xba>
mov    -0x50(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1040 <ns_name_ntop@plt>
cmp    $0xffffffff,%eax
jne    11cd <ns_name_uncompress+0xad>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x48(%rbp)
jmp    11da <ns_name_uncompress+0xba>
mov    -0x44(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x48(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ns_name_uncompress>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8,%r14
mov    %rcx,%r15
mov    0x2ea8(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rbx
mov    %rbx,%rsp
lea    0x0(,%rax,4),%r8d
mov    %rbx,%rcx
call   1030 <ns_name_unpack@plt>
cmp    $0xffffffff,%eax
je     117e <ns_name_uncompress+0x5e>
mov    %eax,%r12d
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <ns_name_ntop@plt>
cmp    $0xffffffff,%eax
cmove  %eax,%r12d
jmp    1184 <ns_name_uncompress+0x64>
mov    $0xffffffff,%r12d
mov    %r12d,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@NS_MAXCDNAME = global i32 0
define i32 @ns_name_uncompress(i32* %0, i32* %1, i32* %2, i8* %3, i64 %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i32
%15 = alloca i32
store i32* %0, i32** %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i8* %3, i8** %10
store i64 %4, i64* %11
%16 = load i32, i32* @NS_MAXCDNAME
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %12
%19 = alloca i32, i64 %17
store i64 %17, i64* %13
%20 = load i32*, i32** %7
%21 = load i32*, i32** %8
%22 = load i32*, i32** %9
%23 = mul nuw i64 4, %17
%24 = trunc i64 %23 to i32
%25 = call i32 @ns_name_unpack(i32* %20, i32* %21, i32* %22, i32* %19, i32 %24)
store i32 %25, i32* %14
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %28
27: ; preds = %5
store i32 -1, i32* %6
store i32 1, i32* %15
br label %36
28: ; preds = %5
%29 = load i8*, i8** %10
%30 = load i64, i64* %11
%31 = call i32 @ns_name_ntop(i32* %19, i8* %29, i64 %30)
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %34
33: ; preds = %28
store i32 -1, i32* %6
store i32 1, i32* %15
br label %36
34: ; preds = %28
%35 = load i32, i32* %14
store i32 %35, i32* %6
store i32 1, i32* %15
br label %36
36: ; preds = %34, %33, %27
%37 = load i8*, i8** %12
%38 = load i32, i32* %6
ret i32 %38
}

LLVM IR (-O2):
@NS_MAXCDNAME = global i32 0
define i32 @ns_name_uncompress(i32* %0, i32* %1, i32* %2, i8* %3, i64 %4) {
%6 = load i32, i32* @NS_MAXCDNAME
%7 = zext i32 %6 to i64
%8 = alloca i32, i64 %7
%9 = shl i32 %6, 2
%10 = call i32 @ns_name_unpack(i32* %0, i32* %1, i32* %2, i32* %8, i32 %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %16, label %12
12: ; preds = %5
%13 = call i32 @ns_name_ntop(i32* %8, i8* %3, i64 %4)
%14 = icmp eq i32 %13, -1
%15 = select i1 %14, i32 -1, i32 %10
br label %16
16: ; preds = %12, %5
%17 = phi i32 [ -1, %5 ], [ %15, %12 ]
ret i32 %17
}