#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 *readstat_calloc(size_t count, size_t size) {
  if (count > 0xFFF000 || size > 0xFFF000 || count * size > 0xFFF000) {
    return NULL;
  }
  if (count == 0 || size == 0) {
    return NULL;
  }
  return calloc(count, size);
}


x86 assembly (clang, -O0):
<readstat_calloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0xfff000,-0x10(%rbp)
ja     1151 <readstat_calloc+0x41>
cmpq   $0xfff000,-0x18(%rbp)
ja     1151 <readstat_calloc+0x41>
mov    -0x10(%rbp),%rax
imul   -0x18(%rbp),%rax
cmp    $0xfff000,%rax
jbe    115e <readstat_calloc+0x4e>
movq   $0x0,-0x8(%rbp)
jmp    1192 <readstat_calloc+0x82>
cmpq   $0x0,-0x10(%rbp)
je     1174 <readstat_calloc+0x64>
cmpq   $0x0,-0x18(%rbp)
jne    1181 <readstat_calloc+0x71>
movq   $0x0,-0x8(%rbp)
jmp    1192 <readstat_calloc+0x82>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <calloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readstat_calloc>:
cmp    $0xfff000,%rdi
ja     1140 <readstat_calloc+0x30>
cmp    $0xfff000,%rsi
ja     1140 <readstat_calloc+0x30>
mov    %rsi,%rax
imul   %rdi,%rax
cmp    $0xfff000,%rax
ja     1140 <readstat_calloc+0x30>
test   %rdi,%rdi
je     1140 <readstat_calloc+0x30>
test   %rsi,%rsi
je     1140 <readstat_calloc+0x30>
jmp    1030 <calloc@plt>
xor    %eax,%eax
ret

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

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