#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 _ts_ljump(unsigned char *);
void _ts_lcopy(unsigned char *a, unsigned char *label, char *host) {
  int len;
  if (*label == 0) {
    *host = 0;
    return;
  }
  for (len = 1; len <= *label; len++)
    *host++ = label[len];
  *host++ = '.';
  label += *label + 1;
  if (*label & 0xc0)
    return _ts_lcopy(a, a + _ts_ljump(label), host);
  _ts_lcopy(a, label, host);
}


x86 assembly (clang, -O0):
<_ts_lcopy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
jne    1150 <_ts_lcopy+0x30>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
jmp    1217 <_ts_lcopy+0xf7>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
movzbl (%rcx),%ecx
cmp    %ecx,%eax
jg     1193 <_ts_lcopy+0x73>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1157 <_ts_lcopy+0x37>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x2e,(%rax)
mov    -0x10(%rbp),%rax
movzbl (%rax),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
and    $0xc0,%eax
cmp    $0x0,%eax
je     1206 <_ts_lcopy+0xe6>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <_ts_ljump@plt>
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rdi
cltq
add    %rax,%rsi
mov    -0x18(%rbp),%rdx
call   1030 <_ts_lcopy@plt>
jmp    1217 <_ts_lcopy+0xf7>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <_ts_lcopy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_ts_lcopy>:
push   %r15
push   %r14
push   %rbx
cmpb   $0x0,(%rsi)
je     1186 <_ts_lcopy+0x76>
mov    %rdi,%r14
jmp    112f <_ts_lcopy+0x1f>
nop
lea    (%r15,%rbx,1),%rdx
add    $0x1,%rdx
mov    %rdi,%rsi
test   %al,%al
je     117e <_ts_lcopy+0x6e>
mov    %rdx,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl 0x1(%rsi,%rbx,1),%eax
mov    %al,(%r15,%rbx,1)
movzbl (%rsi),%eax
add    $0x1,%rbx
cmp    %rax,%rbx
jb     1140 <_ts_lcopy+0x30>
movb   $0x2e,(%r15,%rbx,1)
movzbl (%rsi),%eax
lea    (%rax,%rsi,1),%rdi
add    $0x1,%rdi
mov    0x1(%rax,%rsi,1),%al
cmp    $0x40,%al
jb     1120 <_ts_lcopy+0x10>
call   1030 <_ts_ljump@plt>
cltq
lea    (%r14,%rax,1),%rdi
mov    (%r14,%rax,1),%al
jmp    1120 <_ts_lcopy+0x10>
lea    (%r15,%rbx,1),%rdx
add    $0x1,%rdx
movb   $0x0,(%rdx)
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @_ts_lcopy(i8* %0, i8* %1, i8* %2) {
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %3, %34
%7 = phi i8* [ %22, %34 ], [ %2, %3 ]
%8 = phi i8* [ %36, %34 ], [ %1, %3 ]
br label %11
9: ; preds = %34, %3
%10 = phi i8* [ %2, %3 ], [ %22, %34 ]
store i8 0, i8* %10
ret void
11: ; preds = %6, %11
%12 = phi i64 [ 1, %6 ], [ %17, %11 ]
%13 = phi i8* [ %7, %6 ], [ %16, %11 ]
%14 = getelementptr inbounds i8, i8* %8, i64 %12
%15 = load i8, i8* %14
%16 = getelementptr inbounds i8, i8* %13, i64 1
store i8 %15, i8* %13
%17 = add nuw nsw i64 %12, 1
%18 = load i8, i8* %8
%19 = zext i8 %18 to i64
%20 = icmp ult i64 %12, %19
br i1 %20, label %11, label %21
21: ; preds = %11
%22 = getelementptr inbounds i8, i8* %13, i64 2
store i8 46, i8* %16
%23 = load i8, i8* %8
%24 = zext i8 %23 to i64
%25 = add nuw nsw i64 %24, 1
%26 = getelementptr inbounds i8, i8* %8, i64 %25
%27 = load i8, i8* %26
%28 = icmp ult i8 %27, 64
br i1 %28, label %34, label %29
29: ; preds = %21
%30 = tail call i32 @_ts_ljump(i8* %26)
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %0, i64 %31
%33 = load i8, i8* %32
br label %34
34: ; preds = %29, %21
%35 = phi i8 [ %33, %29 ], [ %27, %21 ]
%36 = phi i8* [ %32, %29 ], [ %26, %21 ]
%37 = icmp eq i8 %35, 0
br i1 %37, label %9, label %6
}