#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 stat {
  int /*<<< orphan*/ st_dev;
};

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error_reason(int /*<<< orphan*/);
int misc_temp_dev(int /*<<< orphan*/, int, char **);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int misc_temp_dev_from_file(char *file, char **devno) {
  struct stat stats;
  if (stat(file, &stats)) {
    error_reason(strerror(errno));
    return -1;
  }
  return misc_temp_dev(stats.st_dev, 1, devno);
}


x86 assembly (clang, -O0):
<misc_temp_dev_from_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
je     1188 <misc_temp_dev_from_file+0x48>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %eax,%edi
call   1030 <error_reason@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    119c <misc_temp_dev_from_file+0x5c>
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%rdx
mov    $0x1,%esi
call   1040 <misc_temp_dev@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<misc_temp_dev_from_file>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
lea    0x8(%rsp),%rsi
call   1050 <stat@plt>
test   %rax,%rax
je     1173 <misc_temp_dev_from_file+0x33>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %eax,%edi
call   1030 <error_reason@plt>
mov    $0xffffffff,%eax
jmp    1184 <misc_temp_dev_from_file+0x44>
mov    0x8(%rsp),%edi
mov    $0x1,%esi
mov    %rbx,%rdx
call   1040 <misc_temp_dev@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@errno = global i32 0
define i32 @misc_temp_dev_from_file(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca %struct.stat
store i8* %0, i8** %4
store i8** %1, i8*** %5
%7 = load i8*, i8** %4
%8 = call i64 @stat(i8* %7, %struct.stat* %6)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @errno
%12 = call i32 @strerror(i32 %11)
%13 = call i32 @error_reason(i32 %12)
store i32 -1, i32* %3
br label %19
14: ; preds = %2
%15 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%16 = load i32, i32* %15
%17 = load i8**, i8*** %5
%18 = call i32 @misc_temp_dev(i32 %16, i32 1, i8** %17)
store i32 %18, i32* %3
br label %19
19: ; preds = %14, %10
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@errno = global i32 0
define i32 @misc_temp_dev_from_file(i8* %0, i8** %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = call i64 @stat(i8* %0, %struct.stat* %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %2
%8 = load i32, i32* @errno
%9 = call i32 @strerror(i32 %8)
%10 = call i32 @error_reason(i32 %9)
br label %15
11: ; preds = %2
%12 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%13 = load i32, i32* %12
%14 = call i32 @misc_temp_dev(i32 %13, i32 1, i8** %1)
br label %15
15: ; preds = %11, %7
%16 = phi i32 [ -1, %7 ], [ %14, %11 ]
ret i32 %16
}