#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 INT_MAX;
int /*<<< orphan*/ glp_lib_fault(char *, int, ...);
void *glp_lib_umalloc(int);
void *glp_lib_ucalloc(int nmemb, int size) {
  if (nmemb < 1)
    glp_lib_fault("ucalloc: nmemb = %d; invalid parameter", nmemb);
  if (size < 1)
    glp_lib_fault("ucalloc: size = %d; invalid parameter", size);
  if (nmemb > INT_MAX / size)
    glp_lib_fault("ucalloc: nmemb = %d; size = %d; array too big", nmemb, size);
  return glp_lib_umalloc(nmemb * size);
}


x86 assembly (clang, -O0):
<glp_lib_ucalloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x1,-0x4(%rbp)
jge    1149 <glp_lib_ucalloc+0x29>
mov    -0x4(%rbp),%esi
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <glp_lib_fault@plt>
cmpl   $0x1,-0x8(%rbp)
jge    1164 <glp_lib_ucalloc+0x44>
mov    -0x8(%rbp),%esi
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <glp_lib_fault@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    0x2e77(%rip),%rax
mov    (%rax),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
cmp    %ecx,%eax
jle    1198 <glp_lib_ucalloc+0x78>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <glp_lib_fault@plt>
mov    -0x4(%rbp),%edi
imul   -0x8(%rbp),%edi
call   1040 <glp_lib_umalloc@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glp_lib_ucalloc>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
test   %edi,%edi
jle    1161 <glp_lib_ucalloc+0x41>
test   %ebx,%ebx
jle    1175 <glp_lib_ucalloc+0x55>
mov    0x2eb2(%rip),%rax
mov    (%rax),%eax
cltd
idiv   %ebx
cmp    %ebp,%eax
jge    1151 <glp_lib_ucalloc+0x31>
lea    0xf07(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <glp_lib_fault@plt>
imul   %ebp,%ebx
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <glp_lib_umalloc@plt>
lea    0xe98(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <glp_lib_fault@plt>
test   %ebx,%ebx
jg     112f <glp_lib_ucalloc+0xf>
lea    0xeab(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <glp_lib_fault@plt>
jmp    112f <glp_lib_ucalloc+0xf>

LLVM IR (-O0):
@.str = [39 x i8] c"ucalloc: nmemb = %d; invalid parameter\00"
@.str.1 = [38 x i8] c"ucalloc: size = %d; invalid parameter\00"
@INT_MAX = global i32 0
@.str.2 = [46 x i8] c"ucalloc: nmemb = %d; size = %d; array too big\00"
define i8* @glp_lib_ucalloc(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 1
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i32, i32* %3
%9 = call i32 (i8*, i32, ...) @glp_lib_fault(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %7, %2
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 1
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32, i32* %4
%15 = call i32 (i8*, i32, ...) @glp_lib_fault(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %13, %10
%17 = load i32, i32* %3
%18 = load i32, i32* @INT_MAX
%19 = load i32, i32* %4
%20 = sdiv i32 %18, %19
%21 = icmp sgt i32 %17, %20
br i1 %21, label %22, label %26
22: ; preds = %16
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = call i32 (i8*, i32, ...) @glp_lib_fault(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %23, i32 %24)
br label %26
26: ; preds = %22, %16
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = mul nsw i32 %27, %28
%30 = call i8* @glp_lib_umalloc(i32 %29)
ret i8* %30
}

LLVM IR (-O2):
@.str = [39 x i8] c"ucalloc: nmemb = %d; invalid parameter\00"
@.str.1 = [38 x i8] c"ucalloc: size = %d; invalid parameter\00"
@INT_MAX = global i32 0
@.str.2 = [46 x i8] c"ucalloc: nmemb = %d; size = %d; array too big\00"
define i8* @glp_lib_ucalloc(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, 1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (i8*, i32, ...) @glp_lib_fault(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %6
6: ; preds = %4, %2
%7 = icmp slt i32 %1, 1
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = tail call i32 (i8*, i32, ...) @glp_lib_fault(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %1)
br label %10
10: ; preds = %8, %6
%11 = load i32, i32* @INT_MAX
%12 = sdiv i32 %11, %1
%13 = icmp slt i32 %12, %0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = tail call i32 (i8*, i32, ...) @glp_lib_fault(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %0, i32 %1)
br label %16
16: ; preds = %14, %10
%17 = mul nsw i32 %1, %0
%18 = tail call i8* @glp_lib_umalloc(i32 %17)
ret i8* %18
}