#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 */

/* Variables and functions */
int /*<<< orphan*/ USB_error(char *, int);
void *USB_malloc(int, int);
int /*<<< orphan*/ memory_counter(int);
int /*<<< orphan*/ memset(void *, int /*<<< orphan*/, int);
void *usbh_alloc_mem(int size) {
  void *p;
  p = USB_malloc(size, 16);
  if (p == NULL) {
    USB_error("usbh_alloc_mem failed! %d\n", size);
    return NULL;
  }
  memset(p, 0, size);
  memory_counter(size);
  return p;
}


x86 assembly (clang, -O0):
<usbh_alloc_mem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x10,%esi
call   1030 <USB_malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1183 <usbh_alloc_mem+0x43>
mov    -0xc(%rbp),%esi
lea    0xe8f(%rip),%rdi
call   1060 <USB_error@plt>
movq   $0x0,-0x8(%rbp)
jmp    11a1 <usbh_alloc_mem+0x61>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0xc(%rbp),%edi
call   1050 <memory_counter@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usbh_alloc_mem>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x10,%esi
call   1030 <USB_malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     116c <usbh_alloc_mem+0x2c>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1040 <memset@plt>
mov    %ebp,%edi
call   1050 <memory_counter@plt>
jmp    117a <usbh_alloc_mem+0x3a>
lea    0xe8d(%rip),%rdi
mov    %ebp,%esi
call   1060 <USB_error@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"usbh_alloc_mem failed! %d\0A\00"
define i8* @usbh_alloc_mem(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = call i8* @USB_malloc(i32 %5, i32 16)
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* %3
%11 = call i32 @USB_error(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %10)
store i8* null, i8** %2
br label %19
12: ; preds = %1
%13 = load i8*, i8** %4
%14 = load i32, i32* %3
%15 = call i32 @memset(i8* %13, i32 0, i32 %14)
%16 = load i32, i32* %3
%17 = call i32 @memory_counter(i32 %16)
%18 = load i8*, i8** %4
store i8* %18, i8** %2
br label %19
19: ; preds = %12, %9
%20 = load i8*, i8** %2
ret i8* %20
}

LLVM IR (-O2):
@.str = [27 x i8] c"usbh_alloc_mem failed! %d\0A\00"
define i8* @usbh_alloc_mem(i32 %0) {
%2 = tail call i8* @USB_malloc(i32 %0, i32 16)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @USB_error(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %9
6: ; preds = %1
%7 = tail call i32 @memset(i8* %2, i32 0, i32 %0)
%8 = tail call i32 @memory_counter(i32 %0)
br label %9
9: ; preds = %6, %4
ret i8* %2
}