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

/* Variables and functions */
int /*<<< orphan*/ strcpy(char *, char *);
void mkptr6(char *s, const unsigned char *ip) {
  static const char xdigits[] = "0123456789abcdef";
  int i;
  for (i = 15; i >= 0; i--) {
    *s++ = xdigits[ip[i] & 15];
    *s++ = '.';
    *s++ = xdigits[ip[i] >> 4];
    *s++ = '.';
  }
  strcpy(s, "ip6.arpa");
}


x86 assembly (clang, -O0):
<mkptr6>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xf,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11bd <mkptr6+0xad>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
and    $0xf,%eax
movslq %eax,%rcx
lea    0xeb6(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x2e,(%rax)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
sar    $0x4,%eax
movslq %eax,%rcx
lea    0xe77(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x2e,(%rax)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <mkptr6+0x17>
mov    -0x8(%rbp),%rdi
lea    0xe49(%rip),%rsi
call   1030 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mkptr6>:
mov    $0x10,%eax
lea    0xee4(%rip),%rcx
nopl   0x0(%rax)
movzbl -0x1(%rsi,%rax,1),%edx
and    $0xf,%edx
movzbl (%rdx,%rcx,1),%edx
mov    %dl,(%rdi)
movb   $0x2e,0x1(%rdi)
movzbl -0x1(%rsi,%rax,1),%edx
shr    $0x4,%rdx
movzbl (%rdx,%rcx,1),%edx
mov    %dl,0x2(%rdi)
movb   $0x2e,0x3(%rdi)
movzbl -0x2(%rsi,%rax,1),%edx
and    $0xf,%edx
movzbl (%rdx,%rcx,1),%edx
mov    %dl,0x4(%rdi)
movb   $0x2e,0x5(%rdi)
movzbl -0x2(%rsi,%rax,1),%edx
shr    $0x4,%rdx
movzbl (%rdx,%rcx,1),%edx
mov    %dl,0x6(%rdi)
movb   $0x2e,0x7(%rdi)
add    $0x8,%rdi
add    $0xfffffffffffffffe,%rax
jne    1120 <mkptr6+0x10>
lea    0xe93(%rip),%rsi
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
@mkptr6.xdigits = internal constant [17 x i8] c"0123456789abcdef\00"
@.str = [9 x i8] c"ip6.arpa\00"
define void @mkptr6(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 15, i32* %5
br label %6
6: ; preds = %38, %2
%7 = load i32, i32* %5
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %41
9: ; preds = %6
%10 = load i8*, i8** %4
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = and i32 %15, 15
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [17 x i8], [17 x i8]* @mkptr6.xdigits, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %3
store i8 %19, i8* %20
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %3
store i8 46, i8* %22
%24 = load i8*, i8** %4
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = ashr i32 %29, 4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [17 x i8], [17 x i8]* @mkptr6.xdigits, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = load i8*, i8** %3
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %3
store i8 %33, i8* %34
%36 = load i8*, i8** %3
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %3
store i8 46, i8* %36
br label %38
38: ; preds = %9
%39 = load i32, i32* %5
%40 = add nsw i32 %39, -1
store i32 %40, i32* %5
br label %6
41: ; preds = %6
%42 = load i8*, i8** %3
%43 = call i32 @strcpy(i8* %42, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@mkptr6.xdigits = internal unnamed_addr constant [17 x i8] c"0123456789abcdef\00"
@.str = [9 x i8] c"ip6.arpa\00"
define void @mkptr6(i8* %0, i8* nocapture %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i64 [ 15, %2 ], [ %37, %3 ]
%5 = phi i8* [ %0, %2 ], [ %36, %3 ]
%6 = getelementptr inbounds i8, i8* %1, i64 %4
%7 = load i8, i8* %6
%8 = and i8 %7, 15
%9 = zext i8 %8 to i64
%10 = getelementptr inbounds [17 x i8], [17 x i8]* @mkptr6.xdigits, i64 0, i64 %9
%11 = load i8, i8* %10
%12 = getelementptr inbounds i8, i8* %5, i64 1
store i8 %11, i8* %5
%13 = getelementptr inbounds i8, i8* %5, i64 2
store i8 46, i8* %12
%14 = load i8, i8* %6
%15 = lshr i8 %14, 4
%16 = zext i8 %15 to i64
%17 = getelementptr inbounds [17 x i8], [17 x i8]* @mkptr6.xdigits, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = getelementptr inbounds i8, i8* %5, i64 3
store i8 %18, i8* %13
%20 = getelementptr inbounds i8, i8* %5, i64 4
store i8 46, i8* %19
%21 = add nsw i64 %4, -1
%22 = getelementptr inbounds i8, i8* %1, i64 %21
%23 = load i8, i8* %22
%24 = and i8 %23, 15
%25 = zext i8 %24 to i64
%26 = getelementptr inbounds [17 x i8], [17 x i8]* @mkptr6.xdigits, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = getelementptr inbounds i8, i8* %5, i64 5
store i8 %27, i8* %20
%29 = getelementptr inbounds i8, i8* %5, i64 6
store i8 46, i8* %28
%30 = load i8, i8* %22
%31 = lshr i8 %30, 4
%32 = zext i8 %31 to i64
%33 = getelementptr inbounds [17 x i8], [17 x i8]* @mkptr6.xdigits, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = getelementptr inbounds i8, i8* %5, i64 7
store i8 %34, i8* %29
%36 = getelementptr inbounds i8, i8* %5, i64 8
store i8 46, i8* %35
%37 = add nsw i64 %4, -2
%38 = icmp eq i64 %21, 0
br i1 %38, label %39, label %3
39: ; preds = %3
%40 = tail call i32 @strcpy(i8* %36, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
ret void
}