#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_struct {
  int /*<<< orphan*/ *name;
  void *fmt_gap;
  void *spec1;
  void *rate;
  void *gap;
  void *stretch;
  void *track;
  void *head;
  void *sect;
  void *size;
};

/* Variables and functions */
void *convert(char *);
int /*<<< orphan*/ exit(int);
scalar_t__ ioctl(int, int, struct floppy_struct *);
int /*<<< orphan*/ perror(char *);
void set_params(int cmd, int fd, char **params) {
  struct floppy_struct ft;
  ft.size = convert(params[0]);
  ft.sect = convert(params[1]);
  ft.head = convert(params[2]);
  ft.track = convert(params[3]);
  ft.stretch = convert(params[4]);
  ft.gap = convert(params[5]);
  ft.rate = convert(params[6]);
  ft.spec1 = convert(params[7]);
  ft.fmt_gap = convert(params[8]);
  ft.name = NULL;
  if (ioctl(fd, cmd, &ft) >= 0)
    exit(0);
  perror("ioctl");
  exit(1);
}


x86 assembly (clang, -O0):
<set_params>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <convert@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <convert@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <convert@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <convert@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1030 <convert@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   1030 <convert@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
call   1030 <convert@plt>
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%rdi
call   1030 <convert@plt>
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    0x40(%rax),%rdi
call   1030 <convert@plt>
mov    %rax,-0x58(%rbp)
movq   $0x0,-0x60(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x4(%rbp),%esi
lea    -0x60(%rbp),%rdx
call   1040 <ioctl@plt>
cmp    $0x0,%rax
jl     1212 <set_params+0xd2>
xor    %edi,%edi
call   1060 <exit@plt>
lea    0xde7(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<set_params>:
push   %rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %edi,%r14d
mov    (%rdx),%rdi
call   1030 <convert@plt>
mov    %rax,0x48(%rsp)
mov    0x8(%rbx),%rdi
call   1030 <convert@plt>
mov    %rax,0x40(%rsp)
mov    0x10(%rbx),%rdi
call   1030 <convert@plt>
mov    %rax,0x38(%rsp)
mov    0x18(%rbx),%rdi
call   1030 <convert@plt>
mov    %rax,0x30(%rsp)
mov    0x20(%rbx),%rdi
call   1030 <convert@plt>
mov    %rax,0x28(%rsp)
mov    0x28(%rbx),%rdi
call   1030 <convert@plt>
mov    %rax,0x20(%rsp)
mov    0x30(%rbx),%rdi
call   1030 <convert@plt>
mov    %rax,0x18(%rsp)
mov    0x38(%rbx),%rdi
call   1030 <convert@plt>
mov    %rax,0x10(%rsp)
mov    0x40(%rbx),%rdi
call   1030 <convert@plt>
mov    %rax,0x8(%rsp)
movq   $0x0,(%rsp)
mov    %rsp,%rdx
mov    %ebp,%edi
mov    %r14d,%esi
call   1040 <ioctl@plt>
test   %rax,%rax
js     11ee <set_params+0xae>
xor    %edi,%edi
call   1060 <exit@plt>
lea    0xe0b(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.floppy_struct = type { i32*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* }
@.str = [6 x i8] c"ioctl\00"
define void @set_params(i32 %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca %struct.floppy_struct
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8** %2, i8*** %6
%8 = load i8**, i8*** %6
%9 = getelementptr inbounds i8*, i8** %8, i64 0
%10 = load i8*, i8** %9
%11 = call i8* @convert(i8* %10)
%12 = getelementptr inbounds %struct.floppy_struct, %struct.floppy_struct* %7, i32 0, i32 9
store i8* %11, i8** %12
%13 = load i8**, i8*** %6
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i8* @convert(i8* %15)
%17 = getelementptr inbounds %struct.floppy_struct, %struct.floppy_struct* %7, i32 0, i32 8
store i8* %16, i8** %17
%18 = load i8**, i8*** %6
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = call i8* @convert(i8* %20)
%22 = getelementptr inbounds %struct.floppy_struct, %struct.floppy_struct* %7, i32 0, i32 7
store i8* %21, i8** %22
%23 = load i8**, i8*** %6
%24 = getelementptr inbounds i8*, i8** %23, i64 3
%25 = load i8*, i8** %24
%26 = call i8* @convert(i8* %25)
%27 = getelementptr inbounds %struct.floppy_struct, %struct.floppy_struct* %7, i32 0, i32 6
store i8* %26, i8** %27
%28 = load i8**, i8*** %6
%29 = getelementptr inbounds i8*, i8** %28, i64 4
%30 = load i8*, i8** %29
%31 = call i8* @convert(i8* %30)
%32 = getelementptr inbounds %struct.floppy_struct, %struct.floppy_struct* %7, i32 0, i32 5
store i8* %31, i8** %32
%33 = load i8**, i8*** %6
%34 = getelementptr inbounds i8*, i8** %33, i64 5
%35 = load i8*, i8** %34
%36 = call i8* @convert(i8* %35)
%37 = getelementptr inbounds %struct.floppy_struct, %struct.floppy_struct* %7, i32 0, i32 4
store i8* %36, i8** %37
%38 = load i8**, i8*** %6
%39 = getelementptr inbounds i8*, i8** %38, i64 6
%40 = load i8*, i8** %39
%41 = call i8* @convert(i8* %40)
%42 = getelementptr inbounds %struct.floppy_struct, %struct.floppy_struct* %7, i32 0, i32 3
store i8* %41, i8** %42
%43 = load i8**, i8*** %6
%44 = getelementptr inbounds i8*, i8** %43, i64 7
%45 = load i8*, i8** %44
%46 = call i8* @convert(i8* %45)
%47 = getelementptr inbounds %struct.floppy_struct, %struct.floppy_struct* %7, i32 0, i32 2
store i8* %46, i8** %47
%48 = load i8**, i8*** %6
%49 = getelementptr inbounds i8*, i8** %48, i64 8
%50 = load i8*, i8** %49
%51 = call i8* @convert(i8* %50)
%52 = getelementptr inbounds %struct.floppy_struct, %struct.floppy_struct* %7, i32 0, i32 1
store i8* %51, i8** %52
%53 = getelementptr inbounds %struct.floppy_struct, %struct.floppy_struct* %7, i32 0, i32 0
store i32* null, i32** %53
%54 = load i32, i32* %5
%55 = load i32, i32* %4
%56 = call i64 @ioctl(i32 %54, i32 %55, %struct.floppy_struct* %7)
%57 = icmp sge i64 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %3
%59 = call i32 @exit(i32 0)
unreachable
60: ; preds = %3
%61 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%62 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
%struct.floppy_struct = type { i32*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8* }
@.str = [6 x i8] c"ioctl\00"
define void @set_params(i32 %0, i32 %1, i8** nocapture %2) {
%4 = alloca %struct.floppy_struct
%5 = bitcast %struct.floppy_struct* %4 to i8*
%6 = load i8*, i8** %2
%7 = tail call i8* @convert(i8* %6)
%8 = getelementptr inbounds %struct.floppy_struct, %struct.floppy_struct* %4, i64 0, i32 9
store i8* %7, i8** %8
%9 = getelementptr inbounds i8*, i8** %2, i64 1
%10 = load i8*, i8** %9
%11 = tail call i8* @convert(i8* %10)
%12 = getelementptr inbounds %struct.floppy_struct, %struct.floppy_struct* %4, i64 0, i32 8
store i8* %11, i8** %12
%13 = getelementptr inbounds i8*, i8** %2, i64 2
%14 = load i8*, i8** %13
%15 = tail call i8* @convert(i8* %14)
%16 = getelementptr inbounds %struct.floppy_struct, %struct.floppy_struct* %4, i64 0, i32 7
store i8* %15, i8** %16
%17 = getelementptr inbounds i8*, i8** %2, i64 3
%18 = load i8*, i8** %17
%19 = tail call i8* @convert(i8* %18)
%20 = getelementptr inbounds %struct.floppy_struct, %struct.floppy_struct* %4, i64 0, i32 6
store i8* %19, i8** %20
%21 = getelementptr inbounds i8*, i8** %2, i64 4
%22 = load i8*, i8** %21
%23 = tail call i8* @convert(i8* %22)
%24 = getelementptr inbounds %struct.floppy_struct, %struct.floppy_struct* %4, i64 0, i32 5
store i8* %23, i8** %24
%25 = getelementptr inbounds i8*, i8** %2, i64 5
%26 = load i8*, i8** %25
%27 = tail call i8* @convert(i8* %26)
%28 = getelementptr inbounds %struct.floppy_struct, %struct.floppy_struct* %4, i64 0, i32 4
store i8* %27, i8** %28
%29 = getelementptr inbounds i8*, i8** %2, i64 6
%30 = load i8*, i8** %29
%31 = tail call i8* @convert(i8* %30)
%32 = getelementptr inbounds %struct.floppy_struct, %struct.floppy_struct* %4, i64 0, i32 3
store i8* %31, i8** %32
%33 = getelementptr inbounds i8*, i8** %2, i64 7
%34 = load i8*, i8** %33
%35 = tail call i8* @convert(i8* %34)
%36 = getelementptr inbounds %struct.floppy_struct, %struct.floppy_struct* %4, i64 0, i32 2
store i8* %35, i8** %36
%37 = getelementptr inbounds i8*, i8** %2, i64 8
%38 = load i8*, i8** %37
%39 = tail call i8* @convert(i8* %38)
%40 = getelementptr inbounds %struct.floppy_struct, %struct.floppy_struct* %4, i64 0, i32 1
store i8* %39, i8** %40
%41 = getelementptr inbounds %struct.floppy_struct, %struct.floppy_struct* %4, i64 0, i32 0
store i32* null, i32** %41
%42 = call i64 @ioctl(i32 %1, i32 %0, %struct.floppy_struct* %4)
%43 = icmp sgt i64 %42, -1
br i1 %43, label %44, label %46
44: ; preds = %3
%45 = call i32 @exit(i32 0)
unreachable
46: ; preds = %3
%47 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%48 = call i32 @exit(i32 1)
unreachable
}