#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 usbdevfs_ioctl {
  int ifno;
  int /*<<< orphan*/ *data;
  int /*<<< orphan*/ ioctl_code;
};

/* Variables and functions */
int /*<<< orphan*/ USBDEVFS_CONNECT;
int /*<<< orphan*/ USBDEVFS_DISCONNECT;
int /*<<< orphan*/ USBDEVFS_IOCTL;
int doioctl(int /*<<< orphan*/, struct usbdevfs_ioctl *, char *);
int usb_set_connected(int ifnum, int conn) {
  struct usbdevfs_ioctl io;
  io.ifno = ifnum;
  io.ioctl_code = (conn) ? USBDEVFS_CONNECT : USBDEVFS_DISCONNECT;
  io.data = NULL;
  return doioctl(USBDEVFS_IOCTL, &io, "set_connected");
}


x86 assembly (clang, -O0):
<usb_set_connected>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     113f <usb_set_connected+0x2f>
mov    0x2eab(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    114b <usb_set_connected+0x3b>
mov    0x2e92(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
lea    0xe93(%rip),%rdx
call   1030 <doioctl@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usb_set_connected>:
sub    $0x18,%rsp
mov    %edi,(%rsp)
test   %esi,%esi
jne    1124 <usb_set_connected+0x14>
mov    0x2eb6(%rip),%rax
jmp    112b <usb_set_connected+0x1b>
mov    0x2eb5(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
movq   $0x0,0x8(%rsp)
mov    0x2ea7(%rip),%rax
mov    (%rax),%edi
lea    0xeb6(%rip),%rdx
mov    %rsp,%rsi
call   1030 <doioctl@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.usbdevfs_ioctl = type { i32, i32*, i32 }
@USBDEVFS_CONNECT = global i32 0
@USBDEVFS_DISCONNECT = global i32 0
@USBDEVFS_IOCTL = global i32 0
@.str = [14 x i8] c"set_connected\00"
define i32 @usb_set_connected(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.usbdevfs_ioctl
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = getelementptr inbounds %struct.usbdevfs_ioctl, %struct.usbdevfs_ioctl* %5, i32 0, i32 0
store i32 %6, i32* %7
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = load i32, i32* @USBDEVFS_CONNECT
br label %14
12: ; preds = %2
%13 = load i32, i32* @USBDEVFS_DISCONNECT
br label %14
14: ; preds = %12, %10
%15 = phi i32 [ %11, %10 ], [ %13, %12 ]
%16 = getelementptr inbounds %struct.usbdevfs_ioctl, %struct.usbdevfs_ioctl* %5, i32 0, i32 2
store i32 %15, i32* %16
%17 = getelementptr inbounds %struct.usbdevfs_ioctl, %struct.usbdevfs_ioctl* %5, i32 0, i32 1
store i32* null, i32** %17
%18 = load i32, i32* @USBDEVFS_IOCTL
%19 = call i32 @doioctl(i32 %18, %struct.usbdevfs_ioctl* %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
ret i32 %19
}

LLVM IR (-O2):
%struct.usbdevfs_ioctl = type { i32, i32*, i32 }
@USBDEVFS_CONNECT = global i32 0
@USBDEVFS_DISCONNECT = global i32 0
@USBDEVFS_IOCTL = global i32 0
@.str = [14 x i8] c"set_connected\00"
define i32 @usb_set_connected(i32 %0, i32 %1) {
%3 = alloca %struct.usbdevfs_ioctl
%4 = bitcast %struct.usbdevfs_ioctl* %3 to i8*
%5 = getelementptr inbounds %struct.usbdevfs_ioctl, %struct.usbdevfs_ioctl* %3, i64 0, i32 0
store i32 %0, i32* %5
%6 = icmp eq i32 %1, 0
%7 = load i32, i32* @USBDEVFS_CONNECT
%8 = load i32, i32* @USBDEVFS_DISCONNECT
%9 = select i1 %6, i32 %8, i32 %7
%10 = getelementptr inbounds %struct.usbdevfs_ioctl, %struct.usbdevfs_ioctl* %3, i64 0, i32 2
store i32 %9, i32* %10
%11 = getelementptr inbounds %struct.usbdevfs_ioctl, %struct.usbdevfs_ioctl* %3, i64 0, i32 1
store i32* null, i32** %11
%12 = load i32, i32* @USBDEVFS_IOCTL
%13 = call i32 @doioctl(i32 %12, %struct.usbdevfs_ioctl* %3, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
ret i32 %13
}