#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);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, size_t);
int /*<<< orphan*/ stderr;
void *ts_calloc_default(size_t count, size_t size) {
  void *result = calloc(count, size);
  if (count > 0 && !result) {
    fprintf(stderr, "tree-sitter failed to allocate %zu bytes", count * size);
    exit(1);
  }
  return result;
}


x86 assembly (clang, -O0):
<ts_calloc_default>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
jbe    118f <ts_calloc_default+0x5f>
cmpq   $0x0,-0x18(%rbp)
jne    118f <ts_calloc_default+0x5f>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
imul   -0x10(%rbp),%rdx
lea    0xe80(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ts_calloc_default>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <calloc@plt>
test   %rbx,%rbx
je     1149 <ts_calloc_default+0x19>
test   %rax,%rax
je     1151 <ts_calloc_default+0x21>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
imul   %rbx,%r14
lea    0xe9b(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [41 x i8] c"tree-sitter failed to allocate %zu bytes\00"
define i8* @ts_calloc_default(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 = load i64, i64* %4
%8 = call i8* @calloc(i64 %6, i64 %7)
store i8* %8, i8** %5
%9 = load i64, i64* %3
%10 = icmp ugt i64 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %21, label %14
14: ; preds = %11
%15 = load i32, i32* @stderr
%16 = load i64, i64* %3
%17 = load i64, i64* %4
%18 = mul i64 %16, %17
%19 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i64 %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %11, %2
%22 = load i8*, i8** %5
ret i8* %22
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [41 x i8] c"tree-sitter failed to allocate %zu bytes\00"
define noalias i8* @ts_calloc_default(i64 %0, i64 %1) {
%3 = tail call i8* @calloc(i64 %0, i64 %1)
%4 = icmp eq i64 %0, 0
%5 = icmp ne i8* %3, null
%6 = or i1 %4, %5
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = mul i64 %1, %0
%10 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i64 %9)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
ret i8* %3
}