#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ UI_DEV_DESTROY;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ ioctl(int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void destroy_replay_device(int fd) {
  if (ioctl(fd, UI_DEV_DESTROY) < 0)
    do {
      fprintf(stderr, "ERROR: ");
      fprintf(stderr, "Could not destroy replay device");
      fprintf(stderr, "\n");
      exit(EXIT_FAILURE);
    } while (0);
}


x86 assembly (clang, -O0):
<destroy_replay_device>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2ea3(%rip),%rax
mov    (%rax),%esi
call   1030 <ioctl@plt>
cmp    $0x0,%rax
jge    11a8 <destroy_replay_device+0x78>
jmp    115b <destroy_replay_device+0x2b>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
lea    0xe95(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<destroy_replay_device>:
push   %rbx
mov    0x2eb0(%rip),%rax
mov    (%rax),%esi
call   1030 <ioctl@plt>
test   %rax,%rax
js     1146 <destroy_replay_device+0x16>
pop    %rbx
ret
mov    0x2e8b(%rip),%rbx
mov    (%rbx),%edi
lea    0xeaa(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xea4(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xeb6(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@UI_DEV_DESTROY = global i32 0
@stderr = global i32 0
@.str = [8 x i8] c"ERROR: \00"
@.str.1 = [32 x i8] c"Could not destroy replay device\00"
@.str.2 = [2 x i8] c"\0A\00"
@EXIT_FAILURE = global i32 0
define void @destroy_replay_device(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* @UI_DEV_DESTROY
%5 = call i64 @ioctl(i32 %3, i32 %4)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %18
7: ; preds = %1
br label %8
8: ; preds = %7
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; No predecessors!
br label %18
18: ; preds = %17, %1
ret void
}

LLVM IR (-O2):
@UI_DEV_DESTROY = global i32 0
@stderr = global i32 0
@.str = [8 x i8] c"ERROR: \00"
@.str.1 = [32 x i8] c"Could not destroy replay device\00"
@.str.2 = [2 x i8] c"\0A\00"
@EXIT_FAILURE = global i32 0
define void @destroy_replay_device(i32 %0) {
%2 = load i32, i32* @UI_DEV_DESTROY
%3 = tail call i64 @ioctl(i32 %0, i32 %2)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %14
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %1
ret void
}