#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_bulktransfer {
  int ep;
  int timeout;
  size_t len;
  void *data;
  int /*<<< orphan*/ member_0;
};

/* Variables and functions */
int /*<<< orphan*/ USBDEVFS_BULK;
int doioctl(int /*<<< orphan*/, struct usbdevfs_bulktransfer *, char const *);
int dobulk(int EndPt, void *pvBuf, size_t cbBuf, const char *pszWho) {
  struct usbdevfs_bulktransfer BulkMsg = {0};
  BulkMsg.ep = EndPt;
  BulkMsg.timeout = 1000;
  BulkMsg.len = cbBuf;
  BulkMsg.data = pvBuf;
  int rc = doioctl(USBDEVFS_BULK, &BulkMsg, pszWho);
  if (rc >= 0)
    return rc;
  return -1;
}


x86 assembly (clang, -O0):
<dobulk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x40(%rbp)
movl   $0x3e8,-0x3c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    -0x40(%rbp),%rsi
call   1040 <doioctl@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jl     1192 <dobulk+0x72>
mov    -0x44(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1199 <dobulk+0x79>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dobulk>:
sub    $0x28,%rsp
movq   $0x0,0x20(%rsp)
mov    %edi,0x8(%rsp)
movl   $0x3e8,0xc(%rsp)
mov    %rdx,0x10(%rsp)
mov    %rsi,0x18(%rsp)
mov    0x2eae(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
mov    %rcx,%rdx
call   1030 <doioctl@plt>
test   %eax,%eax
mov    $0xffffffff,%ecx
cmovs  %ecx,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.usbdevfs_bulktransfer = type { i32, i32, i64, i8*, i32 }
@USBDEVFS_BULK = global i32 0
define i32 @dobulk(i32 %0, i8* %1, i64 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca %struct.usbdevfs_bulktransfer
%11 = alloca i32
store i32 %0, i32* %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i8* %3, i8** %9
%12 = bitcast %struct.usbdevfs_bulktransfer* %10 to i8*
%13 = load i32, i32* %6
%14 = getelementptr inbounds %struct.usbdevfs_bulktransfer, %struct.usbdevfs_bulktransfer* %10, i32 0, i32 0
store i32 %13, i32* %14
%15 = getelementptr inbounds %struct.usbdevfs_bulktransfer, %struct.usbdevfs_bulktransfer* %10, i32 0, i32 1
store i32 1000, i32* %15
%16 = load i64, i64* %8
%17 = getelementptr inbounds %struct.usbdevfs_bulktransfer, %struct.usbdevfs_bulktransfer* %10, i32 0, i32 2
store i64 %16, i64* %17
%18 = load i8*, i8** %7
%19 = getelementptr inbounds %struct.usbdevfs_bulktransfer, %struct.usbdevfs_bulktransfer* %10, i32 0, i32 3
store i8* %18, i8** %19
%20 = load i32, i32* @USBDEVFS_BULK
%21 = load i8*, i8** %9
%22 = call i32 @doioctl(i32 %20, %struct.usbdevfs_bulktransfer* %10, i8* %21)
store i32 %22, i32* %11
%23 = load i32, i32* %11
%24 = icmp sge i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %4
%26 = load i32, i32* %11
store i32 %26, i32* %5
br label %28
27: ; preds = %4
store i32 -1, i32* %5
br label %28
28: ; preds = %27, %25
%29 = load i32, i32* %5
ret i32 %29
}

LLVM IR (-O2):
%struct.usbdevfs_bulktransfer = type { i32, i32, i64, i8*, i32 }
@USBDEVFS_BULK = global i32 0
define i32 @dobulk(i32 %0, i8* %1, i64 %2, i8* %3) {
%5 = alloca %struct.usbdevfs_bulktransfer
%6 = bitcast %struct.usbdevfs_bulktransfer* %5 to i8*
%7 = getelementptr inbounds %struct.usbdevfs_bulktransfer, %struct.usbdevfs_bulktransfer* %5, i64 0, i32 4
%8 = bitcast i32* %7 to i64*
store i64 0, i64* %8
%9 = getelementptr inbounds %struct.usbdevfs_bulktransfer, %struct.usbdevfs_bulktransfer* %5, i64 0, i32 0
store i32 %0, i32* %9
%10 = getelementptr inbounds %struct.usbdevfs_bulktransfer, %struct.usbdevfs_bulktransfer* %5, i64 0, i32 1
store i32 1000, i32* %10
%11 = getelementptr inbounds %struct.usbdevfs_bulktransfer, %struct.usbdevfs_bulktransfer* %5, i64 0, i32 2
store i64 %2, i64* %11
%12 = getelementptr inbounds %struct.usbdevfs_bulktransfer, %struct.usbdevfs_bulktransfer* %5, i64 0, i32 3
store i8* %1, i8** %12
%13 = load i32, i32* @USBDEVFS_BULK
%14 = call i32 @doioctl(i32 %13, %struct.usbdevfs_bulktransfer* %5, i8* %3)
%15 = icmp sgt i32 %14, -1
%16 = select i1 %15, i32 %14, i32 -1
ret i32 %16
}