#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*/ memcpy(char *, char const *, char const);
int fill_domain_to_len_label(const char *from, char *to) {
  int len = 0;
  const char *itor = from;
  if (itor[0] == 0) {
    to[0] = '.';
    return 1;
  }
  while (itor[0] != 0) {
    memcpy(to, itor + 1, itor[0]);
    to += itor[0];
    len += itor[0];
    itor = itor + itor[0] + 1;
    to[0] = '.';
    to++;
    len++;
  }
  return len;
}


x86 assembly (clang, -O0):
<fill_domain_to_len_label>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1152 <fill_domain_to_len_label+0x42>
mov    -0x18(%rbp),%rax
movb   $0x2e,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11e3 <fill_domain_to_len_label+0xd3>
jmp    1157 <fill_domain_to_len_label+0x47>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11dd <fill_domain_to_len_label+0xcd>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
add    $0x1,%rsi
mov    -0x28(%rbp),%rax
mov    (%rax),%al
movsbl %al,%edx
call   1030 <memcpy@plt>
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsbl (%rcx),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x2e,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1157 <fill_domain_to_len_label+0x47>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_domain_to_len_label>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    (%rdi),%al
test   %al,%al
je     1168 <fill_domain_to_len_label+0x58>
mov    %rdi,%r15
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x1(%r15),%rsi
movsbl %al,%edx
mov    %rbx,%rdi
call   1030 <memcpy@plt>
movsbq (%r15),%rcx
movb   $0x2e,(%rbx,%rcx,1)
movzbl 0x1(%r15,%rcx,1),%eax
add    %rcx,%r15
add    $0x1,%r15
add    %rcx,%rbx
add    $0x1,%rbx
add    %ecx,%r14d
add    $0x1,%r14d
test   %al,%al
jne    1130 <fill_domain_to_len_label+0x20>
jmp    1171 <fill_domain_to_len_label+0x61>
movb   $0x2e,(%rbx)
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @fill_domain_to_len_label(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %6
%8 = load i8*, i8** %4
store i8* %8, i8** %7
%9 = load i8*, i8** %7
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 0
store i8 46, i8* %16
store i32 1, i32* %3
br label %61
17: ; preds = %2
br label %18
18: ; preds = %24, %17
%19 = load i8*, i8** %7
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %59
24: ; preds = %18
%25 = load i8*, i8** %5
%26 = load i8*, i8** %7
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i8*, i8** %7
%29 = getelementptr inbounds i8, i8* %28, i64 0
%30 = load i8, i8* %29
%31 = call i32 @memcpy(i8* %25, i8* %27, i8 signext %30)
%32 = load i8*, i8** %7
%33 = getelementptr inbounds i8, i8* %32, i64 0
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = load i8*, i8** %5
%37 = sext i32 %35 to i64
%38 = getelementptr inbounds i8, i8* %36, i64 %37
store i8* %38, i8** %5
%39 = load i8*, i8** %7
%40 = getelementptr inbounds i8, i8* %39, i64 0
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = load i32, i32* %6
%44 = add nsw i32 %43, %42
store i32 %44, i32* %6
%45 = load i8*, i8** %7
%46 = load i8*, i8** %7
%47 = getelementptr inbounds i8, i8* %46, i64 0
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %45, i64 %50
%52 = getelementptr inbounds i8, i8* %51, i64 1
store i8* %52, i8** %7
%53 = load i8*, i8** %5
%54 = getelementptr inbounds i8, i8* %53, i64 0
store i8 46, i8* %54
%55 = load i8*, i8** %5
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %5
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
store i32 %58, i32* %6
br label %18
59: ; preds = %18
%60 = load i32, i32* %6
store i32 %60, i32* %3
br label %61
61: ; preds = %59, %14
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
define i32 @fill_domain_to_len_label(i8* %0, i8* %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %2
store i8 46, i8* %1
br label %24
6: ; preds = %2, %6
%7 = phi i8* [ %18, %6 ], [ %0, %2 ]
%8 = phi i32 [ %21, %6 ], [ 0, %2 ]
%9 = phi i8* [ %19, %6 ], [ %1, %2 ]
%10 = phi i8 [ %22, %6 ], [ %3, %2 ]
%11 = getelementptr inbounds i8, i8* %7, i64 1
%12 = tail call i32 @memcpy(i8* %9, i8* %11, i8 signext %10)
%13 = load i8, i8* %7
%14 = sext i8 %13 to i32
%15 = sext i8 %13 to i64
%16 = getelementptr inbounds i8, i8* %9, i64 %15
%17 = getelementptr inbounds i8, i8* %7, i64 1
%18 = getelementptr inbounds i8, i8* %17, i64 %15
store i8 46, i8* %16
%19 = getelementptr inbounds i8, i8* %16, i64 1
%20 = add i32 %8, 1
%21 = add i32 %20, %14
%22 = load i8, i8* %18
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %6
24: ; preds = %6, %5
%25 = phi i32 [ 1, %5 ], [ %21, %6 ]
ret i32 %25
}