#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 sysfs_find_fd(int, char **, int);
int sysfs_read_attr(char *, char const *, char const *, void *, void *, int);
int sysfs_get_attr(int fd, const char *attr, const char *fmt, void *val1,
                   void *val2, int verbose) {
  char *path;
  int err;
  err = sysfs_find_fd(fd, &path, verbose);
  if (!err)
    err = sysfs_read_attr(path, attr, fmt, val1, val2, verbose);
  return err;
}


x86 assembly (clang, -O0):
<sysfs_get_attr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x2c(%rbp),%edx
lea    -0x38(%rbp),%rsi
call   1040 <sysfs_find_fd@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    117b <sysfs_get_attr+0x5b>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x2c(%rbp),%r9d
call   1030 <sysfs_read_attr@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sysfs_get_attr>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r9d,%ebx
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r13
lea    0x8(%rsp),%rsi
mov    %r9d,%edx
call   1040 <sysfs_find_fd@plt>
test   %eax,%eax
jne    1166 <sysfs_get_attr+0x46>
mov    0x8(%rsp),%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
mov    %ebx,%r9d
call   1030 <sysfs_read_attr@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @sysfs_get_attr(i32 %0, i8* %1, i8* %2, i8* %3, i8* %4, i32 %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32
store i32 %0, i32* %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i32 %5, i32* %12
%15 = load i32, i32* %7
%16 = load i32, i32* %12
%17 = call i32 @sysfs_find_fd(i32 %15, i8** %13, i32 %16)
store i32 %17, i32* %14
%18 = load i32, i32* %14
%19 = icmp ne i32 %18, 0
br i1 %19, label %28, label %20
20: ; preds = %6
%21 = load i8*, i8** %13
%22 = load i8*, i8** %8
%23 = load i8*, i8** %9
%24 = load i8*, i8** %10
%25 = load i8*, i8** %11
%26 = load i32, i32* %12
%27 = call i32 @sysfs_read_attr(i8* %21, i8* %22, i8* %23, i8* %24, i8* %25, i32 %26)
store i32 %27, i32* %14
br label %28
28: ; preds = %20, %6
%29 = load i32, i32* %14
ret i32 %29
}

LLVM IR (-O2):
define i32 @sysfs_get_attr(i32 %0, i8* %1, i8* %2, i8* %3, i8* %4, i32 %5) {
%7 = alloca i8*
%8 = bitcast i8** %7 to i8*
%9 = call i32 @sysfs_find_fd(i32 %0, i8** %7, i32 %5)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i8*, i8** %7
%13 = call i32 @sysfs_read_attr(i8* %12, i8* %1, i8* %2, i8* %3, i8* %4, i32 %5)
br label %14
14: ; preds = %11, %6
%15 = phi i32 [ %9, %6 ], [ %13, %11 ]
ret i32 %15
}