#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 sscanf(char *, char *, unsigned int *, unsigned int *, unsigned int *, ...);
int strlen(char *);
int pcicmp(char *pciaddr, unsigned short domain, unsigned int bus_id) {
  int len, ret;
  unsigned int pci_domain, pci_busid, pci_addr, pci_func;
  len = strlen(pciaddr);
  switch (len) {
  case 7:
    ret = sscanf(pciaddr, "%02x:%02x.%01x", &pci_busid, &pci_addr, &pci_func);
    pci_domain = 0;
    break;
  case 12:
    ret = sscanf(pciaddr, "%04x:%02x:%02x.%01x", &pci_domain, &pci_busid,
                 &pci_addr, &pci_func);
    break;
  default:
    return -1;
  }
  if ((pci_domain == domain) && (pci_busid == bus_id))
    return 0;
  else
    return 1;
}


x86 assembly (clang, -O0):
<pcicmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %si,%ax
mov    %rdi,-0x10(%rbp)
mov    %ax,-0x12(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x34(%rbp)
sub    $0x7,%eax
je     1167 <pcicmp+0x47>
jmp    1156 <pcicmp+0x36>
mov    -0x34(%rbp),%eax
sub    $0xc,%eax
je     1194 <pcicmp+0x74>
jmp    11be <pcicmp+0x9e>
mov    -0x10(%rbp),%rdi
lea    0xe93(%rip),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
lea    -0x30(%rbp),%r8
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
jmp    11ca <pcicmp+0xaa>
mov    -0x10(%rbp),%rdi
lea    0xe61(%rip),%rsi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x2c(%rbp),%r8
lea    -0x30(%rbp),%r9
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    %eax,-0x20(%rbp)
jmp    11ca <pcicmp+0xaa>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f8 <pcicmp+0xd8>
mov    -0x24(%rbp),%eax
movzwl -0x12(%rbp),%ecx
cmp    %ecx,%eax
jne    11f1 <pcicmp+0xd1>
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    11f1 <pcicmp+0xd1>
movl   $0x0,-0x4(%rbp)
jmp    11f8 <pcicmp+0xd8>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pcicmp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebx
mov    %esi,%r14d
mov    %rdi,%rbp
call   1030 <strlen@plt>
cmp    $0xc,%eax
je     116d <pcicmp+0x4d>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0x7,%ecx
jne    11a9 <pcicmp+0x89>
lea    0xeb6(%rip),%rsi
xor    %r15d,%r15d
lea    0x8(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <sscanf@plt>
jmp    1197 <pcicmp+0x77>
lea    0xe8c(%rip),%rsi
lea    0x14(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x10(%rsp),%r8
lea    0xc(%rsp),%r9
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <sscanf@plt>
mov    0x14(%rsp),%r15d
movzwl %r14w,%ecx
xor    0x8(%rsp),%ebx
xor    %r15d,%ecx
xor    %eax,%eax
or     %ecx,%ebx
setne  %al
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"%02x:%02x.%01x\00"
@.str.1 = [20 x i8] c"%04x:%02x:%02x.%01x\00"
define i32 @pcicmp(i8* %0, i16 zeroext %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i16
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %5
store i16 %1, i16* %6
store i32 %2, i32* %7
%14 = load i8*, i8** %5
%15 = call i32 @strlen(i8* %14)
store i32 %15, i32* %8
%16 = load i32, i32* %8
switch i32 %16, label %23 [
i32 7, label %17
i32 12, label %20
]
17: ; preds = %3
%18 = load i8*, i8** %5
%19 = call i32 (i8*, i8*, i32*, i32*, i32*, ...) @sscanf(i8* %18, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32* %11, i32* %12, i32* %13)
store i32 %19, i32* %9
store i32 0, i32* %10
br label %24
20: ; preds = %3
%21 = load i8*, i8** %5
%22 = call i32 (i8*, i8*, i32*, i32*, i32*, ...) @sscanf(i8* %21, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32* %10, i32* %11, i32* %12, i32* %13)
store i32 %22, i32* %9
br label %24
23: ; preds = %3
store i32 -1, i32* %4
br label %35
24: ; preds = %20, %17
%25 = load i32, i32* %10
%26 = load i16, i16* %6
%27 = zext i16 %26 to i32
%28 = icmp eq i32 %25, %27
br i1 %28, label %29, label %34
29: ; preds = %24
%30 = load i32, i32* %11
%31 = load i32, i32* %7
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %34
33: ; preds = %29
store i32 0, i32* %4
br label %35
34: ; preds = %29, %24
store i32 1, i32* %4
br label %35
35: ; preds = %34, %33, %23
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
@.str = [15 x i8] c"%02x:%02x.%01x\00"
@.str.1 = [20 x i8] c"%04x:%02x:%02x.%01x\00"
define i32 @pcicmp(i8* %0, i16 zeroext %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = bitcast i32* %7 to i8*
%12 = tail call i32 @strlen(i8* %0)
switch i32 %12, label %26 [
i32 7, label %13
i32 12, label %15
]
13: ; preds = %3
%14 = call i32 (i8*, i8*, i32*, i32*, i32*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %6, i32* %7)
br label %18
15: ; preds = %3
%16 = call i32 (i8*, i8*, i32*, i32*, i32*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5, i32* %6, i32* %7)
%17 = load i32, i32* %4
br label %18
18: ; preds = %15, %13
%19 = phi i32 [ %17, %15 ], [ 0, %13 ]
%20 = zext i16 %1 to i32
%21 = icmp ne i32 %19, %20
%22 = load i32, i32* %5
%23 = icmp ne i32 %22, %2
%24 = select i1 %21, i1 true, i1 %23
%25 = zext i1 %24 to i32
br label %26
26: ; preds = %18, %3
%27 = phi i32 [ -1, %3 ], [ %25, %18 ]
ret i32 %27
}