#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 *xil_malloc(size_t);
void *xil_calloc(size_t number, size_t size) {
  long *longptr;
  void *blockptr;
  size_t temp = number * size + sizeof(long) - 1;
  temp -= temp % sizeof(long);
  blockptr = xil_malloc(temp);
  if (blockptr != 0) {
    longptr = (long *)blockptr;
    temp /= sizeof(long);
    while (temp-- > 0) {
      *longptr++ = 0;
    }
  }
  return blockptr;
}


x86 assembly (clang, -O0):
<xil_calloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
imul   -0x10(%rbp),%rax
add    $0x8,%rax
sub    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rcx
and    $0x7,%rcx
mov    -0x28(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <xil_malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11ad <xil_calloc+0x9d>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rax
shr    $0x3,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x28(%rbp)
cmp    $0x0,%rax
jbe    11a8 <xil_calloc+0x98>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x18(%rbp)
movq   $0x0,(%rax)
jmp    1174 <xil_calloc+0x64>
jmp    11ad <xil_calloc+0x9d>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xil_calloc>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
imul   %rsi,%rbx
add    $0x7,%rbx
mov    %rbx,%r15
and    $0xfffffffffffffff8,%r15
mov    %r15,%rdi
call   1030 <xil_malloc@plt>
mov    %rax,%r14
test   %rax,%rax
je     115a <xil_calloc+0x3a>
cmp    $0x8,%rbx
jb     115a <xil_calloc+0x3a>
mov    %r14,%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   1040 <memset@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @xil_calloc(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64*
%6 = alloca i8*
%7 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%8 = load i64, i64* %3
%9 = load i64, i64* %4
%10 = mul i64 %8, %9
%11 = add i64 %10, 8
%12 = sub i64 %11, 1
store i64 %12, i64* %7
%13 = load i64, i64* %7
%14 = urem i64 %13, 8
%15 = load i64, i64* %7
%16 = sub i64 %15, %14
store i64 %16, i64* %7
%17 = load i64, i64* %7
%18 = call i8* @xil_malloc(i64 %17)
store i8* %18, i8** %6
%19 = load i8*, i8** %6
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %34
21: ; preds = %2
%22 = load i8*, i8** %6
%23 = bitcast i8* %22 to i64*
store i64* %23, i64** %5
%24 = load i64, i64* %7
%25 = udiv i64 %24, 8
store i64 %25, i64* %7
br label %26
26: ; preds = %30, %21
%27 = load i64, i64* %7
%28 = add i64 %27, -1
store i64 %28, i64* %7
%29 = icmp ugt i64 %27, 0
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i64*, i64** %5
%32 = getelementptr inbounds i64, i64* %31, i32 1
store i64* %32, i64** %5
store i64 0, i64* %31
br label %26
33: ; preds = %26
br label %34
34: ; preds = %33, %2
%35 = load i8*, i8** %6
ret i8* %35
}

LLVM IR (-O2):
define i8* @xil_calloc(i64 %0, i64 %1) {
%3 = mul i64 %1, %0
%4 = add i64 %3, 7
%5 = and i64 %4, -8
%6 = tail call i8* @xil_malloc(i64 %5)
%7 = icmp eq i8* %6, null
%8 = icmp ult i64 %4, 8
%9 = or i1 %7, %8
br i1 %9, label %12, label %10
10: ; preds = %2
%11 = and i64 %4, -8
br label %12
12: ; preds = %10, %2
ret i8* %6
}