#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int name_len;
  char *name;
  int /*<<< orphan*/ member_0;
};
typedef TYPE_1__ drm_version_t;

/* Variables and functions */
int /*<<< orphan*/ DRM_IOCTL_VERSION;
int ioctl(int, int /*<<< orphan*/, TYPE_1__ *);
int strcmp(char *, char *);
int check_vgem(int fd) {
  drm_version_t version = {0};
  char name[5];
  int ret;
  version.name_len = 4;
  version.name = name;
  ret = ioctl(fd, DRM_IOCTL_VERSION, &version);
  if (ret)
    return 1;
  return strcmp(name, "vgem");
}


x86 assembly (clang, -O0):
<check_vgem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1030 <memset@plt>
movl   $0x4,-0x20(%rbp)
lea    -0x25(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e7c(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     1188 <check_vgem+0x58>
movl   $0x1,-0x4(%rbp)
jmp    119b <check_vgem+0x6b>
lea    -0x25(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1050 <strcmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_vgem>:
sub    $0x28,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
movl   $0x4,0x10(%rsp)
lea    0xb(%rsp),%rax
mov    %rax,0x18(%rsp)
mov    0x2e92(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
call   1030 <ioctl@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
je     116a <check_vgem+0x4a>
add    $0x28,%rsp
ret
lea    0xe8f(%rip),%rsi
lea    0xb(%rsp),%rdi
call   1040 <strcmp@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i8*, i32 }
@DRM_IOCTL_VERSION = global i32 0
@.str = [5 x i8] c"vgem\00"
define i32 @check_vgem(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.TYPE_3__
%5 = alloca [5 x i8]
%6 = alloca i32
store i32 %0, i32* %3
%7 = bitcast %struct.TYPE_3__* %4 to i8*
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %4, i32 0, i32 0
store i32 4, i32* %8
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %4, i32 0, i32 1
store i8* %9, i8** %10
%11 = load i32, i32* %3
%12 = load i32, i32* @DRM_IOCTL_VERSION
%13 = call i32 @ioctl(i32 %11, i32 %12, %struct.TYPE_3__* %4)
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %1
store i32 1, i32* %2
br label %20
17: ; preds = %1
%18 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %19, i32* %2
br label %20
20: ; preds = %17, %16
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i8*, i32 }
@DRM_IOCTL_VERSION = global i32 0
@.str = [5 x i8] c"vgem\00"
define i32 @check_vgem(i32 %0) {
%2 = alloca %struct.TYPE_3__
%3 = alloca [5 x i8]
%4 = bitcast %struct.TYPE_3__* %2 to i8*
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 0, i32 0
store i32 4, i32* %6
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 0, i32 1
store i8* %5, i8** %7
%8 = load i32, i32* @DRM_IOCTL_VERSION
%9 = call i32 @ioctl(i32 %0, i32 %8, %struct.TYPE_3__* %2)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 @strcmp(i8* %5, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %1, %11
%14 = phi i32 [ %12, %11 ], [ 1, %1 ]
ret i32 %14
}