#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 /*<<< orphan*/ ERANGE;
size_t SIZE_MAX;
void *calloc(size_t, size_t);
int /*<<< orphan*/ errno;
void multimap_failed(char *, char *, int);
void *multimap_calloc(size_t count, size_t size) {
  ((count) ? ((void)0)
           : multimap_failed("count",
                             "/scratch/repos/new/home/jordi_armengol_estape/"
                             "c-scraper/outputs/2022-01-22/02-19-57/repos/"
                             "tregon/multimap/refs/heads/develop/src/malloc.c",
                             30));
  ((size) ? ((void)0)
          : multimap_failed("size",
                            "/scratch/repos/new/home/jordi_armengol_estape/"
                            "c-scraper/outputs/2022-01-22/02-19-57/repos/"
                            "tregon/multimap/refs/heads/develop/src/malloc.c",
                            31));
  if (count > SIZE_MAX / size) {
    errno = ERANGE;
    return NULL;
  }
  return calloc(count, size);
}


x86 assembly (clang, -O0):
<multimap_calloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1140 <multimap_calloc+0x20>
jmp    1158 <multimap_calloc+0x38>
lea    0xeb9(%rip),%rdi
lea    0xeb8(%rip),%rsi
mov    $0x1e,%edx
call   1030 <multimap_failed@plt>
cmpq   $0x0,-0x18(%rbp)
je     1168 <multimap_calloc+0x48>
jmp    1180 <multimap_calloc+0x60>
lea    0xf21(%rip),%rdi
lea    0xe90(%rip),%rsi
mov    $0x1f,%edx
call   1030 <multimap_failed@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e39(%rip),%rax
mov    (%rax),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jbe    11c9 <multimap_calloc+0xa9>
mov    0x2e37(%rip),%rax
mov    (%rax),%ecx
mov    0x2e1e(%rip),%rax
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    11da <multimap_calloc+0xba>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <calloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<multimap_calloc>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
test   %rdi,%rdi
je     1170 <multimap_calloc+0x50>
test   %rbx,%rbx
je     118d <multimap_calloc+0x6d>
mov    0x2e8d(%rip),%rax
mov    (%rax),%rax
mov    %rax,%rcx
or     %rbx,%rcx
shr    $0x20,%rcx
je     11a7 <multimap_calloc+0x87>
xor    %edx,%edx
div    %rbx
cmp    %r14,%rax
jae    11b0 <multimap_calloc+0x90>
mov    0x2e8d(%rip),%rax
mov    (%rax),%eax
mov    0x2e74(%rip),%rcx
mov    %eax,(%rcx)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe89(%rip),%rdi
lea    0xe88(%rip),%rsi
mov    $0x1e,%edx
call   1030 <multimap_failed@plt>
test   %rbx,%rbx
jne    1134 <multimap_calloc+0x14>
lea    0xefc(%rip),%rdi
lea    0xe6b(%rip),%rsi
mov    $0x1f,%edx
call   1030 <multimap_failed@plt>
jmp    1134 <multimap_calloc+0x14>
xor    %edx,%edx
div    %ebx
cmp    %r14,%rax
jb     1154 <multimap_calloc+0x34>
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <calloc@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"count\00"
@.str.1 = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/tregon/multimap/refs/heads/develop/src/malloc.c\00"
@.str.2 = [5 x i8] c"size\00"
@SIZE_MAX = global i64 0
@ERANGE = global i32 0
@errno = global i32 0
define i8* @multimap_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 ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %2
br label %10
9: ; preds = %2
br label %10
10: ; preds = %9, %8
%11 = load i64, i64* %5
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10
br label %15
14: ; preds = %10
br label %15
15: ; preds = %14, %13
%16 = load i64, i64* %4
%17 = load i64, i64* @SIZE_MAX
%18 = load i64, i64* %5
%19 = udiv i64 %17, %18
%20 = icmp ugt i64 %16, %19
br i1 %20, label %21, label %23
21: ; preds = %15
%22 = load i32, i32* @ERANGE
store i32 %22, i32* @errno
store i8* null, i8** %3
br label %27
23: ; preds = %15
%24 = load i64, i64* %4
%25 = load i64, i64* %5
%26 = call i8* @calloc(i64 %24, i64 %25)
store i8* %26, i8** %3
br label %27
27: ; preds = %23, %21
%28 = load i8*, i8** %3
ret i8* %28
}

LLVM IR (-O2):
@.str = [6 x i8] c"count\00"
@.str.1 = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/tregon/multimap/refs/heads/develop/src/malloc.c\00"
@.str.2 = [5 x i8] c"size\00"
@SIZE_MAX = global i64 0
@ERANGE = global i32 0
@errno = global i32 0
define noalias i8* @multimap_calloc(i64 %0, i64 %1) {
%3 = icmp eq i64 %0, 0
br i1 %3, label %4, label %5
4: ; preds = %2
tail call void @multimap_failed(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.1, i64 0, i64 0), i32 30)
br label %5
5: ; preds = %2, %4
%6 = icmp eq i64 %1, 0
br i1 %6, label %7, label %8
7: ; preds = %5
tail call void @multimap_failed(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.1, i64 0, i64 0), i32 31)
br label %8
8: ; preds = %5, %7
%9 = load i64, i64* @SIZE_MAX
%10 = udiv i64 %9, %1
%11 = icmp ult i64 %10, %0
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = load i32, i32* @ERANGE
store i32 %13, i32* @errno
br label %16
14: ; preds = %8
%15 = tail call i8* @calloc(i64 %0, i64 %1)
br label %16
16: ; preds = %14, %12
%17 = phi i8* [ null, %12 ], [ %15, %14 ]
ret i8* %17
}