#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*/ assert(int);
int /*<<< orphan*/ memset(void *, int /*<<< orphan*/, int);
void *sqlite3_malloc(int);
void *idxMalloc(int *pRc, int nByte) {
  void *pRet;
  assert(*pRc == 0);
  assert(nByte > 0);
  pRet = sqlite3_malloc(nByte);
  if (pRet) {
    memset(pRet, 0, nByte);
  } else {
    *pRc = 7;
  }
  return pRet;
}


x86 assembly (clang, -O0):
<idxMalloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0x0,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpl   $0x0,-0xc(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0xc(%rbp),%edi
call   1050 <sqlite3_malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     118e <idxMalloc+0x5e>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
xor    %esi,%esi
call   1030 <memset@plt>
jmp    1198 <idxMalloc+0x68>
mov    -0x8(%rbp),%rax
movl   $0x7,(%rax)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<idxMalloc>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
xor    %edi,%edi
cmpl   $0x0,(%r14)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
test   %ebp,%ebp
setg   %dil
call   1040 <assert@plt>
mov    %ebp,%edi
call   1050 <sqlite3_malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1172 <idxMalloc+0x42>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1030 <memset@plt>
jmp    1179 <idxMalloc+0x49>
movl   $0x7,(%r14)
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i8* @idxMalloc(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8*
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32*, i32** %3
%7 = load i32, i32* %6
%8 = icmp eq i32 %7, 0
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i32, i32* %4
%16 = call i8* @sqlite3_malloc(i32 %15)
store i8* %16, i8** %5
%17 = load i8*, i8** %5
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %23
19: ; preds = %2
%20 = load i8*, i8** %5
%21 = load i32, i32* %4
%22 = call i32 @memset(i8* %20, i32 0, i32 %21)
br label %25
23: ; preds = %2
%24 = load i32*, i32** %3
store i32 7, i32* %24
br label %25
25: ; preds = %23, %19
%26 = load i8*, i8** %5
ret i8* %26
}

LLVM IR (-O2):
define i8* @idxMalloc(i32* nocapture %0, i32 %1) {
%3 = load i32, i32* %0
%4 = icmp eq i32 %3, 0
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = icmp sgt i32 %1, 0
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = tail call i8* @sqlite3_malloc(i32 %1)
%11 = icmp eq i8* %10, null
br i1 %11, label %14, label %12
12: ; preds = %2
%13 = tail call i32 @memset(i8* %10, i32 0, i32 %1)
br label %15
14: ; preds = %2
store i32 7, i32* %0
br label %15
15: ; preds = %14, %12
ret i8* %10
}