#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 */
void *calloc(size_t, size_t);
void *malloc(int);
int /*<<< orphan*/ solv_oom(size_t, size_t);
void *solv_calloc(size_t num, size_t len) {
  void *r;
  if (num == 0 || len == 0)
    r = malloc(1);
  else
    r = calloc(num, len);
  if (!r)
    solv_oom(num, len);
  return r;
}


x86 assembly (clang, -O0):
<solv_calloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1156 <solv_calloc+0x26>
cmpq   $0x0,-0x10(%rbp)
jne    1169 <solv_calloc+0x39>
mov    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
jmp    117a <solv_calloc+0x4a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1192 <solv_calloc+0x62>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <solv_oom@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solv_calloc>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
test   %rdi,%rdi
je     1152 <solv_calloc+0x22>
test   %r14,%r14
je     1152 <solv_calloc+0x22>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <calloc@plt>
jmp    115c <solv_calloc+0x2c>
mov    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    116f <solv_calloc+0x3f>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <solv_oom@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @solv_calloc(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i8*
store i64 %0, i64* %3
store i64 %1, i64* %4
%6 = load i64, i64* %3
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i64, i64* %4
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8, %2
%12 = call i8* @malloc(i32 1)
store i8* %12, i8** %5
br label %17
13: ; preds = %8
%14 = load i64, i64* %3
%15 = load i64, i64* %4
%16 = call i8* @calloc(i64 %14, i64 %15)
store i8* %16, i8** %5
br label %17
17: ; preds = %13, %11
%18 = load i8*, i8** %5
%19 = icmp ne i8* %18, null
br i1 %19, label %24, label %20
20: ; preds = %17
%21 = load i64, i64* %3
%22 = load i64, i64* %4
%23 = call i32 @solv_oom(i64 %21, i64 %22)
br label %24
24: ; preds = %20, %17
%25 = load i8*, i8** %5
ret i8* %25
}

LLVM IR (-O2):
define i8* @solv_calloc(i64 %0, i64 %1) {
%3 = icmp eq i64 %0, 0
%4 = icmp eq i64 %1, 0
%5 = or i1 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call dereferenceable_or_null(1) i8* @malloc(i32 1)
br label %10
8: ; preds = %2
%9 = tail call i8* @calloc(i64 %0, i64 %1)
br label %10
10: ; preds = %8, %6
%11 = phi i8* [ %7, %6 ], [ %9, %8 ]
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @solv_oom(i64 %0, i64 %1)
br label %15
15: ; preds = %13, %10
ret i8* %11
}