#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 */
char *match_alias(char *, char *, char *, int);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
int main(void) {
  char *name = "pci:v0000104Cd00008241sv00001028sd00000510bc0Csc03i30";
  int nlen = strlen(name);
  char line[] = "alias pci:v*d*sv*sd*bc0Csc03i30* xhci_pci\n";
  char *lend = line + strlen(line) - 1;
  char *out = match_alias(line, lend, name, nlen);
  printf("%s\n", out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xecf(%rip),%rsi
mov    $0x2b,%edx
call   1060 <memcpy@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
call   1040 <match_alias@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rsi
lea    0xe73(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
lea    0xec1(%rip),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
movups 0xf0b(%rip),%xmm0
movups %xmm0,0x1b(%rsp)
movaps 0xef4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xed8(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%rsi
add    $0xffffffffffffffff,%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %ebp,%ecx
call   1040 <match_alias@plt>
lea    0xea1(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [54 x i8] c"pci:v0000104Cd00008241sv00001028sd00000510bc0Csc03i30\00"
@__const.main.line = [43 x i8] c"alias pci:v*d*sv*sd*bc0Csc03i30* xhci_pci\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [43 x i8]
%5 = alloca i8*
%6 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %3
%9 = bitcast [43 x i8]* %4 to i8*
%10 = getelementptr inbounds [43 x i8], [43 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [43 x i8], [43 x i8]* %4, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %10, i64 %13
%15 = getelementptr inbounds i8, i8* %14, i64 -1
store i8* %15, i8** %5
%16 = getelementptr inbounds [43 x i8], [43 x i8]* %4, i64 0, i64 0
%17 = load i8*, i8** %5
%18 = load i8*, i8** %2
%19 = load i32, i32* %3
%20 = call i8* @match_alias(i8* %16, i8* %17, i8* %18, i32 %19)
store i8* %20, i8** %6
%21 = load i8*, i8** %6
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [54 x i8] c"pci:v0000104Cd00008241sv00001028sd00000510bc0Csc03i30\00"
@__const.main.line = [43 x i8] c"alias pci:v*d*sv*sd*bc0Csc03i30* xhci_pci\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [43 x i8]
%2 = tail call i32 @strlen(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%3 = getelementptr inbounds [43 x i8], [43 x i8]* %1, i64 0, i64 0
%4 = call i32 @strlen(i8* %3)
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds [43 x i8], [43 x i8]* %1, i64 0, i64 %5
%7 = getelementptr inbounds i8, i8* %6, i64 -1
%8 = call i8* @match_alias(i8* %3, i8* %7, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i32 %2)
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %8)
ret i32 0
}