#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 *malloc(int);
int malloc_usable_size(void *);
int main(void) {
  int *x = malloc(99);
  assert(104 == malloc_usable_size(x) || 112 == malloc_usable_size(x));
  assert(0 == malloc_usable_size(NULL));
  assert(0 == malloc_usable_size((void *)0xdeadbeef));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x63,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <malloc_usable_size@plt>
mov    %eax,%edx
mov    $0x1,%al
mov    $0x68,%ecx
cmp    %edx,%ecx
mov    %al,-0x11(%rbp)
je     1182 <main+0x52>
mov    -0x10(%rbp),%rdi
call   1030 <malloc_usable_size@plt>
mov    %eax,%ecx
mov    $0x70,%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1030 <malloc_usable_size@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    $0xdeadbeef,%edi
call   1030 <malloc_usable_size@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x63,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <malloc_usable_size@plt>
mov    $0x1,%edi
cmp    $0x68,%eax
je     1161 <main+0x31>
mov    %rbx,%rdi
call   1030 <malloc_usable_size@plt>
xor    %edi,%edi
cmp    $0x70,%eax
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
call   1030 <malloc_usable_size@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
mov    $0xdeadbeef,%edi
call   1030 <malloc_usable_size@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
%3 = call i32* @malloc(i32 99)
store i32* %3, i32** %2
%4 = load i32*, i32** %2
%5 = bitcast i32* %4 to i8*
%6 = call i32 @malloc_usable_size(i8* %5)
%7 = icmp eq i32 104, %6
br i1 %7, label %13, label %8
8: ; preds = %0
%9 = load i32*, i32** %2
%10 = bitcast i32* %9 to i8*
%11 = call i32 @malloc_usable_size(i8* %10)
%12 = icmp eq i32 112, %11
br label %13
13: ; preds = %8, %0
%14 = phi i1 [ true, %0 ], [ %12, %8 ]
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = call i32 @malloc_usable_size(i8* null)
%18 = icmp eq i32 0, %17
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = call i32 @malloc_usable_size(i8* inttoptr (i64 3735928559 to i8*))
%22 = icmp eq i32 0, %21
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32* @malloc(i32 99)
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @malloc_usable_size(i8* %2)
%4 = icmp eq i32 %3, 104
br i1 %4, label %9, label %5
5: ; preds = %0
%6 = tail call i32 @malloc_usable_size(i8* %2)
%7 = icmp eq i32 %6, 112
%8 = zext i1 %7 to i32
br label %9
9: ; preds = %5, %0
%10 = phi i32 [ 1, %0 ], [ %8, %5 ]
%11 = tail call i32 @assert(i32 %10)
%12 = tail call i32 @malloc_usable_size(i8* null)
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = tail call i32 @malloc_usable_size(i8* inttoptr (i64 3735928559 to i8*))
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
%19 = tail call i32 @assert(i32 %18)
ret i32 0
}