#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*/ sqlite3FailedMalloc();
void *sqlite3GenericMalloc(int);
int /*<<< orphan*/ sqlite3MallocFailed();
void *sqlite3MallocRaw(int n, int doMemManage) {
  void *p = 0;
  if (n > 0 && !sqlite3MallocFailed() && (!doMemManage || 1)) {
    while ((p = sqlite3GenericMalloc(n)) == 0 && 0) {
    }
    if (!p) {
      sqlite3FailedMalloc();
      ;
    } else if (doMemManage) {
      ;
    }
  }
  return p;
}


x86 assembly (clang, -O0):
<sqlite3MallocRaw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    11eb <sqlite3MallocRaw+0xbb>
mov    $0x0,%al
call   1030 <sqlite3MallocFailed@plt>
cmp    $0x0,%eax
jne    11eb <sqlite3MallocRaw+0xbb>
cmpl   $0x0,-0x8(%rbp)
je     1179 <sqlite3MallocRaw+0x49>
mov    $0x1,%al
test   $0x1,%al
jne    1179 <sqlite3MallocRaw+0x49>
jmp    11eb <sqlite3MallocRaw+0xbb>
jmp    117e <sqlite3MallocRaw+0x4e>
mov    -0x4(%rbp),%edi
call   1050 <sqlite3GenericMalloc@plt>
mov    %rax,%rcx
mov    %rcx,-0x10(%rbp)
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
jne    11a6 <sqlite3MallocRaw+0x76>
xor    %eax,%eax
mov    %al,-0x11(%rbp)
jmp    11a6 <sqlite3MallocRaw+0x76>
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11b6 <sqlite3MallocRaw+0x86>
jmp    11bb <sqlite3MallocRaw+0x8b>
jmp    117e <sqlite3MallocRaw+0x4e>
cmpq   $0x0,-0x10(%rbp)
jne    11d2 <sqlite3MallocRaw+0xa2>
mov    $0x0,%al
call   1040 <sqlite3FailedMalloc@plt>
jmp    11e6 <sqlite3MallocRaw+0xb6>
cmpl   $0x0,-0x8(%rbp)
je     11e1 <sqlite3MallocRaw+0xb1>
jmp    11e1 <sqlite3MallocRaw+0xb1>
jmp    11e6 <sqlite3MallocRaw+0xb6>
jmp    11eb <sqlite3MallocRaw+0xbb>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqlite3MallocRaw>:
push   %rbp
push   %rbx
push   %rax
test   %edi,%edi
jle    1160 <sqlite3MallocRaw+0x30>
mov    %edi,%ebp
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <sqlite3MallocFailed@plt>
test   %eax,%eax
jne    1162 <sqlite3MallocRaw+0x32>
mov    %ebp,%edi
call   1050 <sqlite3GenericMalloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1162 <sqlite3MallocRaw+0x32>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <sqlite3FailedMalloc@plt>
jmp    1162 <sqlite3MallocRaw+0x32>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i8* @sqlite3MallocRaw(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
store i8* null, i8** %5
%6 = load i32, i32* %3
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %35
8: ; preds = %2
%9 = call i32 (...) @sqlite3MallocFailed()
%10 = icmp ne i32 %9, 0
br i1 %10, label %35, label %11
11: ; preds = %8
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11
br i1 true, label %15, label %35
15: ; preds = %14, %11
br label %16
16: ; preds = %23, %15
%17 = load i32, i32* %3
%18 = call i8* @sqlite3GenericMalloc(i32 %17)
store i8* %18, i8** %5
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %21
20: ; preds = %16
br label %21
21: ; preds = %20, %16
%22 = phi i1 [ false, %16 ], [ false, %20 ]
br i1 %22, label %23, label %24
23: ; preds = %21
br label %16
24: ; preds = %21
%25 = load i8*, i8** %5
%26 = icmp ne i8* %25, null
br i1 %26, label %29, label %27
27: ; preds = %24
%28 = call i32 (...) @sqlite3FailedMalloc()
br label %34
29: ; preds = %24
%30 = load i32, i32* %4
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %29
br label %33
33: ; preds = %32, %29
br label %34
34: ; preds = %33, %27
br label %35
35: ; preds = %34, %14, %8, %2
%36 = load i8*, i8** %5
ret i8* %36
}

LLVM IR (-O2):
define i8* @sqlite3MallocRaw(i32 %0, i32 %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %12
4: ; preds = %2
%5 = tail call i32 (...) @sqlite3MallocFailed()
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %4
%8 = tail call i8* @sqlite3GenericMalloc(i32 %0)
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 (...) @sqlite3FailedMalloc()
br label %12
12: ; preds = %7, %10, %4, %2
%13 = phi i8* [ null, %4 ], [ null, %10 ], [ null, %2 ], [ %8, %7 ]
ret i8* %13
}