#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 */
size_t SIZE_MAX;
int /*<<< orphan*/ hz_abort(char *, ...);
void hz_check_size(size_t num, size_t size) {
  if (size == 0) {
    hz_abort("Unit size is zero");
  } else if (num > SIZE_MAX / size) {
    hz_abort("Size is too large: %zu * %zu", num, size);
  }
}


x86 assembly (clang, -O0):
<hz_check_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113e <hz_check_size+0x2e>
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <hz_abort@plt>
jmp    1183 <hz_check_size+0x73>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
cmp    %rcx,%rax
jbe    117e <hz_check_size+0x6e>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <hz_abort@plt>
jmp    1183 <hz_check_size+0x73>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hz_check_size>:
mov    %rsi,%rcx
test   %rsi,%rsi
je     114c <hz_check_size+0x3c>
mov    %rdi,%rsi
mov    0x2eb6(%rip),%rax
mov    (%rax),%rax
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
je     115a <hz_check_size+0x4a>
xor    %edx,%edx
div    %rcx
cmp    %rsi,%rax
jae    1163 <hz_check_size+0x53>
lea    0xed0(%rip),%rdi
mov    %rcx,%rdx
xor    %eax,%eax
jmp    1030 <hz_abort@plt>
lea    0xead(%rip),%rdi
xor    %eax,%eax
jmp    1030 <hz_abort@plt>
xor    %edx,%edx
div    %ecx
cmp    %rsi,%rax
jb     113b <hz_check_size+0x2b>
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Unit size is zero\00"
@SIZE_MAX = global i64 0
@.str.1 = [29 x i8] c"Size is too large: %zu * %zu\00"
define void @hz_check_size(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%5 = load i64, i64* %4
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = call i32 (i8*, ...) @hz_abort(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %20
9: ; preds = %2
%10 = load i64, i64* %3
%11 = load i64, i64* @SIZE_MAX
%12 = load i64, i64* %4
%13 = udiv i64 %11, %12
%14 = icmp ugt i64 %10, %13
br i1 %14, label %15, label %19
15: ; preds = %9
%16 = load i64, i64* %3
%17 = load i64, i64* %4
%18 = call i32 (i8*, ...) @hz_abort(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i64 %16, i64 %17)
br label %19
19: ; preds = %15, %9
br label %20
20: ; preds = %19, %7
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"Unit size is zero\00"
@SIZE_MAX = global i64 0
@.str.1 = [29 x i8] c"Size is too large: %zu * %zu\00"
define void @hz_check_size(i64 %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (i8*, ...) @hz_abort(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %12
6: ; preds = %2
%7 = load i64, i64* @SIZE_MAX
%8 = udiv i64 %7, %1
%9 = icmp ult i64 %8, %0
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 (i8*, ...) @hz_abort(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i64 %0, i64 %1)
br label %12
12: ; preds = %6, %10, %4
ret void
}