#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 */
struct mdinfo {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ close(int);
int sysfs_fd_get_two(int, unsigned long long *, unsigned long long *);
int sysfs_get_fd(struct mdinfo *, struct mdinfo *, char *);
int sysfs_get_two(struct mdinfo *sra, struct mdinfo *dev, char *name,
                  unsigned long long *v1, unsigned long long *v2) {
  int n;
  int fd;
  fd = sysfs_get_fd(sra, dev, name);
  if (fd < 0)
    return -1;
  n = sysfs_fd_get_two(fd, v1, v2);
  close(fd);
  return n;
}


x86 assembly (clang, -O0):
<sysfs_get_two>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <sysfs_get_fd@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jge    1176 <sysfs_get_two+0x46>
movl   $0xffffffff,-0x4(%rbp)
jmp    1197 <sysfs_get_two+0x67>
mov    -0x38(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1050 <sysfs_fd_get_two@plt>
mov    %eax,-0x34(%rbp)
mov    -0x38(%rbp),%edi
call   1030 <close@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sysfs_get_two>:
push   %rbp
push   %r14
push   %rbx
mov    %r8,%r14
mov    %rcx,%rbx
call   1040 <sysfs_get_fd@plt>
test   %eax,%eax
js     115f <sysfs_get_two+0x2f>
mov    %eax,%ebp
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <sysfs_fd_get_two@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1030 <close@plt>
mov    %ebx,%eax
jmp    1164 <sysfs_get_two+0x34>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.mdinfo = type { i32 }
define i32 @sysfs_get_two(%struct.mdinfo* %0, %struct.mdinfo* %1, i8* %2, i64* %3, i64* %4) {
%6 = alloca i32
%7 = alloca %struct.mdinfo*
%8 = alloca %struct.mdinfo*
%9 = alloca i8*
%10 = alloca i64*
%11 = alloca i64*
%12 = alloca i32
%13 = alloca i32
store %struct.mdinfo* %0, %struct.mdinfo** %7
store %struct.mdinfo* %1, %struct.mdinfo** %8
store i8* %2, i8** %9
store i64* %3, i64** %10
store i64* %4, i64** %11
%14 = load %struct.mdinfo*, %struct.mdinfo** %7
%15 = load %struct.mdinfo*, %struct.mdinfo** %8
%16 = load i8*, i8** %9
%17 = call i32 @sysfs_get_fd(%struct.mdinfo* %14, %struct.mdinfo* %15, i8* %16)
store i32 %17, i32* %13
%18 = load i32, i32* %13
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %5
store i32 -1, i32* %6
br label %29
21: ; preds = %5
%22 = load i32, i32* %13
%23 = load i64*, i64** %10
%24 = load i64*, i64** %11
%25 = call i32 @sysfs_fd_get_two(i32 %22, i64* %23, i64* %24)
store i32 %25, i32* %12
%26 = load i32, i32* %13
%27 = call i32 @close(i32 %26)
%28 = load i32, i32* %12
store i32 %28, i32* %6
br label %29
29: ; preds = %21, %20
%30 = load i32, i32* %6
ret i32 %30
}

LLVM IR (-O2):
%struct.mdinfo = type { i32 }
define i32 @sysfs_get_two(%struct.mdinfo* %0, %struct.mdinfo* %1, i8* %2, i64* %3, i64* %4) {
%6 = tail call i32 @sysfs_get_fd(%struct.mdinfo* %0, %struct.mdinfo* %1, i8* %2)
%7 = icmp slt i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = tail call i32 @sysfs_fd_get_two(i32 %6, i64* %3, i64* %4)
%10 = tail call i32 @close(i32 %6)
br label %11
11: ; preds = %5, %8
%12 = phi i32 [ %9, %8 ], [ -1, %5 ]
ret i32 %12
}