#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_pack(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int,
                 int /*<<< orphan*/ const **, int /*<<< orphan*/ const **);
int ns_name_pton(char const *, int /*<<< orphan*/ *, int);
int ns_name_compress(const char *src, u_char *dst, size_t dstsiz,
                     const u_char **dnptrs, const u_char **lastdnptr) {
  u_char tmp[NS_MAXCDNAME];
  if (ns_name_pton(src, tmp, sizeof tmp) == -1)
    return (-1);
  return (ns_name_pack(tmp, dst, (int)dstsiz, dnptrs, lastdnptr));
}


x86 assembly (clang, -O0):
<ns_name_compress>:
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),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x50(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
shl    $0x2,%rax
mov    %eax,%edx
call   1040 <ns_name_pton@plt>
cmp    $0xffffffff,%eax
jne    1194 <ns_name_compress+0x74>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
jmp    11b9 <ns_name_compress+0x99>
mov    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    %eax,%edx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1030 <ns_name_pack@plt>
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ns_name_compress>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r13
mov    0x2e9f(%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),%edx
mov    %rbx,%rsi
call   1040 <ns_name_pton@plt>
cmp    $0xffffffff,%eax
je     1182 <ns_name_compress+0x62>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12d,%edx
mov    %r15,%rcx
mov    %r14,%r8
call   1030 <ns_name_pack@plt>
jmp    1187 <ns_name_compress+0x67>
mov    $0xffffffff,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@NS_MAXCDNAME = global i32 0
define i32 @ns_name_compress(i8* %0, i32* %1, i64 %2, i32** %3, i32** %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_pton(i8* %0, i32* %8, i32 %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %15, label %12
12: ; preds = %5
%13 = trunc i64 %2 to i32
%14 = call i32 @ns_name_pack(i32* %8, i32* %1, i32 %13, i32** %3, i32** %4)
br label %15
15: ; preds = %5, %12
%16 = phi i32 [ %14, %12 ], [ -1, %5 ]
ret i32 %16
}