#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 */
struct in6_addr {
  int dummy;
};

/* Variables and functions */
int in6_bits(struct in6_addr *, int);
int /*<<< orphan*/ strcpy(char *, char *);
void make_reverse_name(struct in6_addr *a, char *p) {
  int i;
  const char hexdigits[] = "0123456789abcdef";
  for (i = 124; i >= 0; i -= 4) {
    int bits;
    bits = in6_bits(a, i);
    *p++ = hexdigits[bits];
    *p++ = '.';
  }
  strcpy(p, "ip6.arpa");
}


x86 assembly (clang, -O0):
<make_reverse_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xec9(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec6(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xec4(%rip),%al
mov    %al,-0x20(%rbp)
movl   $0x7c,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11a8 <make_reverse_name+0x88>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <in6_bits@plt>
mov    %eax,-0x34(%rbp)
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,1),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x2e,(%rax)
mov    -0x14(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x14(%rbp)
jmp    1156 <make_reverse_name+0x36>
mov    -0x10(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1040 <strcpy@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_reverse_name>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    $0x7c,%ebp
lea    0xec7(%rip),%r15
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <in6_bits@plt>
cltq
movzbl (%rax,%r15,1),%eax
mov    %al,(%rbx)
movb   $0x2e,0x1(%rbx)
add    $0x2,%rbx
add    $0xfffffffc,%ebp
cmp    $0xfffffffc,%ebp
jne    1140 <make_reverse_name+0x20>
lea    0xea7(%rip),%rsi
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <strcpy@plt>

LLVM IR (-O0):
%struct.in6_addr = type { i32 }
@__const.make_reverse_name.hexdigits = [17 x i8] c"0123456789abcdef\00"
@.str = [9 x i8] c"ip6.arpa\00"
define void @make_reverse_name(%struct.in6_addr* %0, i8* %1) {
%3 = alloca %struct.in6_addr*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [17 x i8]
%7 = alloca i32
store %struct.in6_addr* %0, %struct.in6_addr** %3
store i8* %1, i8** %4
%8 = bitcast [17 x i8]* %6 to i8*
store i32 124, i32* %5
br label %9
9: ; preds = %24, %2
%10 = load i32, i32* %5
%11 = icmp sge i32 %10, 0
br i1 %11, label %12, label %27
12: ; preds = %9
%13 = load %struct.in6_addr*, %struct.in6_addr** %3
%14 = load i32, i32* %5
%15 = call i32 @in6_bits(%struct.in6_addr* %13, i32 %14)
store i32 %15, i32* %7
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %4
store i8 %19, i8* %20
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %4
store i8 46, i8* %22
br label %24
24: ; preds = %12
%25 = load i32, i32* %5
%26 = sub nsw i32 %25, 4
store i32 %26, i32* %5
br label %9
27: ; preds = %9
%28 = load i8*, i8** %4
%29 = call i32 @strcpy(i8* %28, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.in6_addr = type { i32 }
@__const.make_reverse_name.hexdigits = [17 x i8] c"0123456789abcdef\00"
@.str = [9 x i8] c"ip6.arpa\00"
define void @make_reverse_name(%struct.in6_addr* %0, i8* %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i8* [ %1, %2 ], [ %11, %3 ]
%5 = phi i32 [ 124, %2 ], [ %12, %3 ]
%6 = tail call i32 @in6_bits(%struct.in6_addr* %0, i32 %5)
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.make_reverse_name.hexdigits, i64 0, i64 %7
%9 = load i8, i8* %8
%10 = getelementptr inbounds i8, i8* %4, i64 1
store i8 %9, i8* %4
%11 = getelementptr inbounds i8, i8* %4, i64 2
store i8 46, i8* %10
%12 = add nsw i32 %5, -4
%13 = icmp eq i32 %5, 0
br i1 %13, label %14, label %3
14: ; preds = %3
%15 = tail call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
ret void
}