#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 floppy_raw_cmd {
  int rate;
  int *cmd;
  int cmd_count;
  int /*<<< orphan*/ flags;
  scalar_t__ length;
  int /*<<< orphan*/ *data;
};

/* Variables and functions */
int /*<<< orphan*/ FDRAWCMD;
int /*<<< orphan*/ FD_RAW_INTR;
int FD_SEEK;
int errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ ioctl(int, int /*<<< orphan*/, struct floppy_raw_cmd *);
int /*<<< orphan*/ stderr;
char *strerror(int);
void lif_seek_phy_device(int device, int cylinder) {
  struct floppy_raw_cmd cmd;
  cmd.data = NULL;
  cmd.length = 0;
  cmd.rate = 2;
  cmd.flags = FD_RAW_INTR;
  cmd.cmd[0] = FD_SEEK;
  cmd.cmd[1] = 0;
  cmd.cmd[2] = cylinder;
  cmd.cmd_count = 3;
  if (ioctl(device, FDRAWCMD, &cmd) < 0) {
    fprintf(stderr, "Error on seek to cylinder %d\n", cylinder);
    fprintf(stderr, "error= %s (%d)\n", strerror(errno), errno);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<lif_seek_phy_device>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x2,-0x30(%rbp)
mov    0x2e7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e68(%rip),%rax
mov    (%rax),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
movl   $0x0,0x4(%rax)
mov    -0x8(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x8(%rax)
movl   $0x3,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e2a(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
call   1030 <ioctl@plt>
cmp    $0x0,%rax
jge    1216 <lif_seek_phy_device+0xd6>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe32(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    %rax,%rdx
mov    0x2dc4(%rip),%rax
mov    (%rax),%ecx
lea    0xe19(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
LLVM IR (-O0):
%struct.floppy_raw_cmd = type { i32, i32*, i32, i32, i64, i32* }
@FD_RAW_INTR = global i32 0
@FD_SEEK = global i32 0
@FDRAWCMD = global i32 0
@stderr = global i32 0
@.str = [30 x i8] c"Error on seek to cylinder %d\0A\00"
@.str.1 = [16 x i8] c"error= %s (%d)\0A\00"
@errno = global i32 0
define void @lif_seek_phy_device(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.floppy_raw_cmd
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = getelementptr inbounds %struct.floppy_raw_cmd, %struct.floppy_raw_cmd* %5, i32 0, i32 5
store i32* null, i32** %6
%7 = getelementptr inbounds %struct.floppy_raw_cmd, %struct.floppy_raw_cmd* %5, i32 0, i32 4
store i64 0, i64* %7
%8 = getelementptr inbounds %struct.floppy_raw_cmd, %struct.floppy_raw_cmd* %5, i32 0, i32 0
store i32 2, i32* %8
%9 = load i32, i32* @FD_RAW_INTR
%10 = getelementptr inbounds %struct.floppy_raw_cmd, %struct.floppy_raw_cmd* %5, i32 0, i32 3
store i32 %9, i32* %10
%11 = load i32, i32* @FD_SEEK
%12 = getelementptr inbounds %struct.floppy_raw_cmd, %struct.floppy_raw_cmd* %5, i32 0, i32 1
%13 = load i32*, i32** %12
%14 = getelementptr inbounds i32, i32* %13, i64 0
store i32 %11, i32* %14
%15 = getelementptr inbounds %struct.floppy_raw_cmd, %struct.floppy_raw_cmd* %5, i32 0, i32 1
%16 = load i32*, i32** %15
%17 = getelementptr inbounds i32, i32* %16, i64 1
store i32 0, i32* %17
%18 = load i32, i32* %4
%19 = getelementptr inbounds %struct.floppy_raw_cmd, %struct.floppy_raw_cmd* %5, i32 0, i32 1
%20 = load i32*, i32** %19
%21 = getelementptr inbounds i32, i32* %20, i64 2
store i32 %18, i32* %21
%22 = getelementptr inbounds %struct.floppy_raw_cmd, %struct.floppy_raw_cmd* %5, i32 0, i32 2
store i32 3, i32* %22
%23 = load i32, i32* %3
%24 = load i32, i32* @FDRAWCMD
%25 = call i64 @ioctl(i32 %23, i32 %24, %struct.floppy_raw_cmd* %5)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %37
27: ; preds = %2
%28 = load i32, i32* @stderr
%29 = load i32, i32* %4
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = load i32, i32* @stderr
%32 = load i32, i32* @errno
%33 = call i8* @strerror(i32 %32)
%34 = load i32, i32* @errno
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %33, i32 %34)
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %2
ret void
}

LLVM IR (-O2):