#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*/ r_cons_printf(char *, char const *, char const *);
int strlen(char *);
int /*<<< orphan*/ strncmp(char const *, char *, int);
int linklist(void *p, const char *k, const char *v) {
  if (!strncmp(k, "link.", strlen("link.")))
    r_cons_printf("tl %s @ 0x%s\n", v, k + strlen("link."));
  return 1;
}


x86 assembly (clang, -O0):
<linklist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    0xead(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%edx
lea    0xe9b(%rip),%rsi
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    11a8 <linklist+0x78>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    0xe76(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rsi
cltq
add    %rax,%rdx
lea    0xe63(%rip),%rdi
call   1030 <r_cons_printf@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linklist>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
lea    0xebe(%rip),%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    117e <linklist+0x4e>
lea    0xe9e(%rip),%rdi
call   1050 <strlen@plt>
cltq
add    %rax,%rbx
lea    0xe93(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <r_cons_printf@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"link.\00"
@.str.1 = [14 x i8] c"tl %s @ 0x%s\0A\00"
define i32 @linklist(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i8*, i8** %5
%8 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @strncmp(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %18, label %11
11: ; preds = %3
%12 = load i8*, i8** %6
%13 = load i8*, i8** %5
%14 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = call i32 @r_cons_printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %12, i8* %16)
br label %18
18: ; preds = %11, %3
ret i32 1
}

LLVM IR (-O2):
@.str = [6 x i8] c"link.\00"
@.str.1 = [14 x i8] c"tl %s @ 0x%s\0A\00"
define i32 @linklist(i8* nocapture readnone %0, i8* %1, i8* %2) {
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @strncmp(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %3
%8 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %1, i64 %9
%11 = tail call i32 @r_cons_printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %10)
br label %12
12: ; preds = %7, %3
ret i32 1
}