#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 */
typedef int /*<<< orphan*/ attribute;

/* Variables and functions */
unsigned long long get_sysfs_ullong(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned char *);
int /*<<< orphan*/ strncmp(unsigned char *, char *, int);
unsigned long long get_PciBlockSize(unsigned char *devlink) {
  char attribute[256];
  unsigned long long size = 0;
  memset(attribute, 0, sizeof(attribute));
  if (!strncmp(devlink, "../", 3))
    snprintf(attribute, 255, "/sys/devices/%s/size", devlink);
  else
    snprintf(attribute, 255, "/sys/devices/../%s/size", devlink);
  size = get_sysfs_ullong(attribute);
  return size;
}


x86 assembly (clang, -O0):
<get_PciBlockSize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x118(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    0xe88(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11ac <get_PciBlockSize+0x6c>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0xff,%esi
lea    0xe62(%rip),%rdx
call   1050 <snprintf@plt>
jmp    11c8 <get_PciBlockSize+0x88>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0xff,%esi
lea    0xe56(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x110(%rbp),%rdi
call   1040 <get_sysfs_ullong@plt>
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_PciBlockSize>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
lea    0xe9a(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
lea    0xe88(%rip),%rax
lea    0xe96(%rip),%rdx
cmove  %rax,%rdx
mov    %r14,%rdi
mov    $0xff,%esi
mov    %rbx,%rcx
call   1050 <snprintf@plt>
mov    %r14,%rdi
call   1040 <get_sysfs_ullong@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"../\00"
@.str.1 = [21 x i8] c"/sys/devices/%s/size\00"
@.str.2 = [24 x i8] c"/sys/devices/../%s/size\00"
define i64 @get_PciBlockSize(i8* %0) {
%2 = alloca i8*
%3 = alloca [256 x i8]
%4 = alloca i64
store i8* %0, i8** %2
store i64 0, i64* %4
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 256)
%7 = load i8*, i8** %2
%8 = call i32 @strncmp(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%9 = icmp ne i32 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %1
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%12 = load i8*, i8** %2
%13 = call i32 @snprintf(i8* %11, i32 255, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %18
14: ; preds = %1
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%16 = load i8*, i8** %2
%17 = call i32 @snprintf(i8* %15, i32 255, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %14, %10
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%20 = call i64 @get_sysfs_ullong(i8* %19)
store i64 %20, i64* %4
%21 = load i64, i64* %4
ret i64 %21
}

LLVM IR (-O2):
@.str = [4 x i8] c"../\00"
@.str.1 = [21 x i8] c"/sys/devices/%s/size\00"
@.str.2 = [24 x i8] c"/sys/devices/../%s/size\00"
define i64 @get_PciBlockSize(i8* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i32 0, i32 256)
%5 = call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%6 = icmp eq i32 %5, 0
%7 = select i1 %6, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0)
%8 = call i32 @snprintf(i8* %3, i32 255, i8* %7, i8* %0)
%9 = call i64 @get_sysfs_ullong(i8* %3)
ret i64 %9
}