#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 unsigned long uint64_t;

/* Variables and functions */
int /*<<< orphan*/ logging_null(char *, char const *, char const *,
                                unsigned long long);
unsigned long sysfsparser_getvalue(char *, char const *, char const *);
uint64_t fc_host_get_statistic(const char *which, const char *host) {
  uint64_t value = sysfsparser_getvalue("/sys/class"
                                        "/fc_host"
                                        "/%s/statistics/%s",
                                        host, which);
  logging_null("/sys/class"
               "/fc_host"
               "/%s/statistics/%s = %Lu\n",
               host, which, (unsigned long long)value);
  if (value == ~0UL)
    return 0;
  return value;
}


x86 assembly (clang, -O0):
<fc_host_get_statistic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xec1(%rip),%rdi
call   1040 <sysfsparser_getvalue@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xec9(%rip),%rdi
call   1030 <logging_null@plt>
cmpq   $0xffffffffffffffff,-0x20(%rbp)
jne    1178 <fc_host_get_statistic+0x58>
movq   $0x0,-0x8(%rbp)
jmp    1180 <fc_host_get_statistic+0x60>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fc_host_get_statistic>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xece(%rip),%rdi
mov    %r14,%rdx
call   1040 <sysfsparser_getvalue@plt>
mov    %rax,%rbx
lea    0xee0(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %rax,%rcx
call   1030 <logging_null@plt>
xor    %eax,%eax
cmp    $0xffffffffffffffff,%rbx
cmovne %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [36 x i8] c"/sys/class/fc_host/%s/statistics/%s\00"
@.str.1 = [43 x i8] c"/sys/class/fc_host/%s/statistics/%s = %Lu\0A\00"
define i64 @fc_host_get_statistic(i8* %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = load i8*, i8** %4
%9 = call i64 @sysfsparser_getvalue(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %8)
store i64 %9, i64* %6
%10 = load i8*, i8** %5
%11 = load i8*, i8** %4
%12 = load i64, i64* %6
%13 = call i32 @logging_null(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %10, i8* %11, i64 %12)
%14 = load i64, i64* %6
%15 = icmp eq i64 %14, -1
br i1 %15, label %16, label %17
16: ; preds = %2
store i64 0, i64* %3
br label %19
17: ; preds = %2
%18 = load i64, i64* %6
store i64 %18, i64* %3
br label %19
19: ; preds = %17, %16
%20 = load i64, i64* %3
ret i64 %20
}

LLVM IR (-O2):
@.str = [36 x i8] c"/sys/class/fc_host/%s/statistics/%s\00"
@.str.1 = [43 x i8] c"/sys/class/fc_host/%s/statistics/%s = %Lu\0A\00"
define i64 @fc_host_get_statistic(i8* %0, i8* %1) {
%3 = tail call i64 @sysfsparser_getvalue(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %0)
%4 = tail call i32 @logging_null(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %0, i64 %3)
%5 = icmp eq i64 %3, -1
%6 = select i1 %5, i64 0, i64 %3
ret i64 %6
}