#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 */
typedef scalar_t__ uint16_t;
typedef scalar_t__ int16_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void skl_ddb_check_last_allocation(int16_t cursor) {
  uint16_t last_offset = 896 - 4;
  if (cursor < last_offset)
    printf("warning: %d blocks not allocated\n", last_offset - cursor);
  else if (cursor > last_offset)
    printf("error: allocation greater than available space\n");
}


x86 assembly (clang, -O0):
<skl_ddb_check_last_allocation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x37c,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    114d <skl_ddb_check_last_allocation+0x3d>
mov    -0x10(%rbp),%rsi
sub    -0x8(%rbp),%rsi
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    116e <skl_ddb_check_last_allocation+0x5e>
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jle    1169 <skl_ddb_check_last_allocation+0x59>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    116e <skl_ddb_check_last_allocation+0x5e>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skl_ddb_check_last_allocation>:
cmp    $0x37b,%rdi
jg     113f <skl_ddb_check_last_allocation+0x1f>
mov    $0x37c,%esi
sub    %rdi,%rsi
lea    0xec8(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
cmp    $0x37c,%rdi
jne    1149 <skl_ddb_check_last_allocation+0x29>
ret
lea    0xed2(%rip),%rdi
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"warning: %d blocks not allocated\0A\00"
@.str.1 = [48 x i8] c"error: allocation greater than available space\0A\00"
define void @skl_ddb_check_last_allocation(i64 %0) {
%2 = alloca i64
%3 = alloca i64
store i64 %0, i64* %2
store i64 892, i64* %3
%4 = load i64, i64* %2
%5 = load i64, i64* %3
%6 = icmp slt i64 %4, %5
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i64, i64* %3
%9 = load i64, i64* %2
%10 = sub nsw i64 %8, %9
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i64 %10)
br label %19
12: ; preds = %1
%13 = load i64, i64* %2
%14 = load i64, i64* %3
%15 = icmp sgt i64 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %12
br label %19
19: ; preds = %18, %7
ret void
}

LLVM IR (-O2):
@.str = [34 x i8] c"warning: %d blocks not allocated\0A\00"
@str = [47 x i8] c"error: allocation greater than available space\00"
define void @skl_ddb_check_last_allocation(i64 %0) {
%2 = icmp slt i64 %0, 892
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = sub nsw i64 892, %0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i64 %4)
br label %10
6: ; preds = %1
%7 = icmp eq i64 %0, 892
br i1 %7, label %10, label %8
8: ; preds = %6
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %6, %8, %3
ret void
}