#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 getChassisPort(unsigned char, unsigned char, unsigned char);
int /*<<< orphan*/ sscanf(char *, char *, unsigned short *, unsigned char *,
                          unsigned char *, unsigned char *);
int getChassisPort_str(char *pci) {
  unsigned short dom = 0;
  unsigned char bus = 0, dev = 0, func = 0;
  if (pci == NULL)
    return 0;
  sscanf(pci, "%4hx:%2hhx:%2hhx.%1hhx", &dom, &bus, &dev, &func);
  return getChassisPort(bus, dev, func);
}


x86 assembly (clang, -O0):
<getChassisPort_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movw   $0x0,-0x12(%rbp)
movb   $0x0,-0x13(%rbp)
movb   $0x0,-0x14(%rbp)
movb   $0x0,-0x15(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1155 <getChassisPort_str+0x35>
movl   $0x0,-0x4(%rbp)
jmp    118d <getChassisPort_str+0x6d>
mov    -0x10(%rbp),%rdi
lea    0xea0(%rip),%rsi
lea    -0x12(%rbp),%rdx
lea    -0x13(%rbp),%rcx
lea    -0x14(%rbp),%r8
lea    -0x15(%rbp),%r9
call   1030 <sscanf@plt>
mov    -0x13(%rbp),%cl
mov    -0x14(%rbp),%al
movzbl %cl,%edi
movzbl %al,%esi
movzbl -0x15(%rbp),%edx
call   1040 <getChassisPort@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getChassisPort_str>:
push   %rax
movw   $0x0,0x6(%rsp)
movb   $0x0,0x5(%rsp)
movb   $0x0,0x4(%rsp)
movb   $0x0,0x3(%rsp)
test   %rdi,%rdi
je     1172 <getChassisPort_str+0x52>
lea    0xebd(%rip),%rsi
lea    0x6(%rsp),%rdx
lea    0x5(%rsp),%rcx
lea    0x4(%rsp),%r8
lea    0x3(%rsp),%r9
call   1030 <sscanf@plt>
movzbl 0x5(%rsp),%edi
movzbl 0x4(%rsp),%esi
movzbl 0x3(%rsp),%edx
call   1040 <getChassisPort@plt>
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"%4hx:%2hhx:%2hhx.%1hhx\00"
define i32 @getChassisPort_str(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i16
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
store i8* %0, i8** %3
store i16 0, i16* %4
store i8 0, i8* %5
store i8 0, i8* %6
store i8 0, i8* %7
%8 = load i8*, i8** %3
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 0, i32* %2
br label %18
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i16* %4, i8* %5, i8* %6, i8* %7)
%14 = load i8, i8* %5
%15 = load i8, i8* %6
%16 = load i8, i8* %7
%17 = call i32 @getChassisPort(i8 zeroext %14, i8 zeroext %15, i8 zeroext %16)
store i32 %17, i32* %2
br label %18
18: ; preds = %11, %10
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@.str = [23 x i8] c"%4hx:%2hhx:%2hhx.%1hhx\00"
define i32 @getChassisPort_str(i8* %0) {
%2 = alloca i16
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
%6 = bitcast i16* %2 to i8*
store i16 0, i16* %2
store i8 0, i8* %3
store i8 0, i8* %4
store i8 0, i8* %5
%7 = icmp eq i8* %0, null
br i1 %7, label %14, label %8
8: ; preds = %1
%9 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i16* %2, i8* %3, i8* %4, i8* %5)
%10 = load i8, i8* %3
%11 = load i8, i8* %4
%12 = load i8, i8* %5
%13 = call i32 @getChassisPort(i8 zeroext %10, i8 zeroext %11, i8 zeroext %12)
br label %14
14: ; preds = %1, %8
%15 = phi i32 [ %13, %8 ], [ 0, %1 ]
ret i32 %15
}