#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 track;
  int flags;
  int *cmd;
  scalar_t__ cmd_count;
};

/* Variables and functions */
int /*<<< orphan*/ FDRAWCMD;
int FD_RAW_INTR;
int FD_RAW_NEED_SEEK;
int FD_SEEK;
int /*<<< orphan*/ errno;
int ioctl(int, int /*<<< orphan*/, struct floppy_raw_cmd *);
int /*<<< orphan*/ printf(char *, char *);
char *strerror(int /*<<< orphan*/);
void seektrack(int fd, int trk) {
  struct floppy_raw_cmd raw_cmd;
  int tmp, i;
  raw_cmd.track = trk;
  raw_cmd.flags = FD_RAW_INTR | FD_RAW_NEED_SEEK;
  raw_cmd.cmd_count = 0;
  raw_cmd.cmd[raw_cmd.cmd_count++] = FD_SEEK;
  raw_cmd.cmd[raw_cmd.cmd_count++] = 0;
  raw_cmd.cmd[raw_cmd.cmd_count++] = trk;
  tmp = ioctl(fd, FDRAWCMD, &raw_cmd);
  if (tmp)
    printf("tmp nonzero, error = \"%s\"\n", strerror(errno));
}


x86 assembly (clang, -O0):
<seektrack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2e95(%rip),%rax
mov    (%rax),%eax
mov    0x2e9c(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x1c(%rbp)
movq   $0x0,-0x10(%rbp)
mov    0x2e70(%rip),%rax
mov    (%rax),%edx
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x10(%rbp)
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
movl   $0x0,(%rax,%rcx,4)
mov    -0x8(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x10(%rbp)
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%edi
mov    0x2e0b(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11f2 <seektrack+0xc2>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    %rax,%rsi
lea    0xe13(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
LLVM IR (-O0):
%struct.floppy_raw_cmd = type { i32, i32, i32*, i64 }
@FD_RAW_INTR = global i32 0
@FD_RAW_NEED_SEEK = global i32 0
@FD_SEEK = global i32 0
@FDRAWCMD = global i32 0
@.str = [27 x i8] c"tmp nonzero, error = \22%s\22\0A\00"
@errno = global i32 0
define void @seektrack(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.floppy_raw_cmd
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = getelementptr inbounds %struct.floppy_raw_cmd, %struct.floppy_raw_cmd* %5, i32 0, i32 0
store i32 %8, i32* %9
%10 = load i32, i32* @FD_RAW_INTR
%11 = load i32, i32* @FD_RAW_NEED_SEEK
%12 = or i32 %10, %11
%13 = getelementptr inbounds %struct.floppy_raw_cmd, %struct.floppy_raw_cmd* %5, i32 0, i32 1
store i32 %12, i32* %13
%14 = getelementptr inbounds %struct.floppy_raw_cmd, %struct.floppy_raw_cmd* %5, i32 0, i32 3
store i64 0, i64* %14
%15 = load i32, i32* @FD_SEEK
%16 = getelementptr inbounds %struct.floppy_raw_cmd, %struct.floppy_raw_cmd* %5, i32 0, i32 2
%17 = load i32*, i32** %16
%18 = getelementptr inbounds %struct.floppy_raw_cmd, %struct.floppy_raw_cmd* %5, i32 0, i32 3
%19 = load i64, i64* %18
%20 = add nsw i64 %19, 1
store i64 %20, i64* %18
%21 = getelementptr inbounds i32, i32* %17, i64 %19
store i32 %15, i32* %21
%22 = getelementptr inbounds %struct.floppy_raw_cmd, %struct.floppy_raw_cmd* %5, i32 0, i32 2
%23 = load i32*, i32** %22
%24 = getelementptr inbounds %struct.floppy_raw_cmd, %struct.floppy_raw_cmd* %5, i32 0, i32 3
%25 = load i64, i64* %24
%26 = add nsw i64 %25, 1
store i64 %26, i64* %24
%27 = getelementptr inbounds i32, i32* %23, i64 %25
store i32 0, i32* %27
%28 = load i32, i32* %4
%29 = getelementptr inbounds %struct.floppy_raw_cmd, %struct.floppy_raw_cmd* %5, i32 0, i32 2
%30 = load i32*, i32** %29
%31 = getelementptr inbounds %struct.floppy_raw_cmd, %struct.floppy_raw_cmd* %5, i32 0, i32 3
%32 = load i64, i64* %31
%33 = add nsw i64 %32, 1
store i64 %33, i64* %31
%34 = getelementptr inbounds i32, i32* %30, i64 %32
store i32 %28, i32* %34
%35 = load i32, i32* %3
%36 = load i32, i32* @FDRAWCMD
%37 = call i32 @ioctl(i32 %35, i32 %36, %struct.floppy_raw_cmd* %5)
store i32 %37, i32* %6
%38 = load i32, i32* %6
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %2
%41 = load i32, i32* @errno
%42 = call i8* @strerror(i32 %41)
%43 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %40, %2
ret void
}

LLVM IR (-O2):