#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 fb_var_screeninfo {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ FBIOGET_VSCREENINFO;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ ioctl(int, int /*<<< orphan*/, struct fb_var_screeninfo *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
void getVarScreenInfo(int fh, struct fb_var_screeninfo *var) {
  if (ioctl(fh, FBIOGET_VSCREENINFO, var)) {
    fprintf(stderr, "ioctl FBIOGET_VSCREENINFO: %s\n", strerror(errno));
    exit(1);
  }
}


x86 assembly (clang, -O0):
<getVarScreenInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e77(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
call   1030 <ioctl@plt>
cmp    $0x0,%rax
je     11a4 <getVarScreenInfo+0x64>
mov    0x2e6b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%rdx
lea    0xe6b(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getVarScreenInfo>:
push   %rbx
mov    %rsi,%rdx
mov    0x2e85(%rip),%rax
mov    (%rax),%esi
call   1030 <ioctl@plt>
test   %rax,%rax
jne    1159 <getVarScreenInfo+0x19>
pop    %rbx
ret
mov    0x2e80(%rip),%rax
mov    (%rax),%ebx
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe89(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.fb_var_screeninfo = type { i32 }
@FBIOGET_VSCREENINFO = global i32 0
@stderr = global i32 0
@.str = [31 x i8] c"ioctl FBIOGET_VSCREENINFO: %s\0A\00"
@errno = global i32 0
define void @getVarScreenInfo(i32 %0, %struct.fb_var_screeninfo* %1) {
%3 = alloca i32
%4 = alloca %struct.fb_var_screeninfo*
store i32 %0, i32* %3
store %struct.fb_var_screeninfo* %1, %struct.fb_var_screeninfo** %4
%5 = load i32, i32* %3
%6 = load i32, i32* @FBIOGET_VSCREENINFO
%7 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %4
%8 = call i64 @ioctl(i32 %5, i32 %6, %struct.fb_var_screeninfo* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i32, i32* @errno
%13 = call i8* @strerror(i32 %12)
%14 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
ret void
}

LLVM IR (-O2):
%struct.fb_var_screeninfo = type { i32 }
@FBIOGET_VSCREENINFO = global i32 0
@stderr = global i32 0
@.str = [31 x i8] c"ioctl FBIOGET_VSCREENINFO: %s\0A\00"
@errno = global i32 0
define void @getVarScreenInfo(i32 %0, %struct.fb_var_screeninfo* %1) {
%3 = load i32, i32* @FBIOGET_VSCREENINFO
%4 = tail call i64 @ioctl(i32 %0, i32 %3, %struct.fb_var_screeninfo* %1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i32, i32* @errno
%9 = tail call i8* @strerror(i32 %8)
%10 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
ret void
}