#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*/ snprintf(char *, int, char *, int, int, int, ...);
void xconfigFormatPciBusString(char *str, int len, int domain, int bus,
                               int device, int func) {
  if (domain) {
    snprintf(str, len, "PCI:%d@%d:%d:%d", bus, domain, device, func);
  } else {
    snprintf(str, len, "PCI:%d:%d:%d", bus, device, func);
  }
  str[len - 1] = '\0';
}


x86 assembly (clang, -O0):
<xconfigFormatPciBusString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1162 <xconfigFormatPciBusString+0x52>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x18(%rbp),%r9d
mov    -0x1c(%rbp),%eax
lea    0xead(%rip),%rdx
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    1182 <xconfigFormatPciBusString+0x72>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
lea    0xe95(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xconfigFormatPciBusString>:
push   %rbp
push   %rbx
push   %rax
mov    %r8d,%eax
mov    %esi,%ebp
mov    %rdi,%rbx
test   %edx,%edx
je     1137 <xconfigFormatPciBusString+0x27>
mov    %edx,%r8d
mov    %r9d,(%rsp)
lea    0xed3(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %eax,%r9d
jmp    1146 <xconfigFormatPciBusString+0x36>
lea    0xed2(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %eax,%r8d
xor    %eax,%eax
call   1030 <snprintf@plt>
movslq %ebp,%rax
movb   $0x0,-0x1(%rax,%rbx,1)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"PCI:%d@%d:%d:%d\00"
@.str.1 = [13 x i8] c"PCI:%d:%d:%d\00"
define void @xconfigFormatPciBusString(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%13 = load i32, i32* %9
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %6
%16 = load i8*, i8** %7
%17 = load i32, i32* %8
%18 = load i32, i32* %10
%19 = load i32, i32* %9
%20 = load i32, i32* %11
%21 = load i32, i32* %12
%22 = call i32 (i8*, i32, i8*, i32, i32, i32, ...) @snprintf(i8* %16, i32 %17, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %19, i32 %20, i32 %21)
br label %30
23: ; preds = %6
%24 = load i8*, i8** %7
%25 = load i32, i32* %8
%26 = load i32, i32* %10
%27 = load i32, i32* %11
%28 = load i32, i32* %12
%29 = call i32 (i8*, i32, i8*, i32, i32, i32, ...) @snprintf(i8* %24, i32 %25, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %26, i32 %27, i32 %28)
br label %30
30: ; preds = %23, %15
%31 = load i8*, i8** %7
%32 = load i32, i32* %8
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %31, i64 %34
store i8 0, i8* %35
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"PCI:%d@%d:%d:%d\00"
@.str.1 = [13 x i8] c"PCI:%d:%d:%d\00"
define void @xconfigFormatPciBusString(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = icmp eq i32 %2, 0
br i1 %7, label %10, label %8
8: ; preds = %6
%9 = tail call i32 (i8*, i32, i8*, i32, i32, i32, ...) @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %2, i32 %4, i32 %5)
br label %12
10: ; preds = %6
%11 = tail call i32 (i8*, i32, i8*, i32, i32, i32, ...) @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %3, i32 %4, i32 %5)
br label %12
12: ; preds = %10, %8
%13 = add nsw i32 %1, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
store i8 0, i8* %15
ret void
}