#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*/ free(int *);
void malloc_assert_failed(char *, char const *, int, char const *, char *);
void slurm_xfree(void **item, const char *file, int line, const char *func) {
  if (*item != NULL) {
    int *p = (int *)*item - 2;
    (void)({
      (p[0] == 0x42)
          ? ((void)(0))
          : malloc_assert_failed("p[0] == 0x42", file, line, func, "");
    });
    p[0] = 0;
    ;
    free(p);
    ;
    *item = NULL;
  }
}


x86 assembly (clang, -O0):
<slurm_xfree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     11a2 <slurm_xfree+0x82>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpl   $0x42,(%rax)
jne    1166 <slurm_xfree+0x46>
jmp    1184 <slurm_xfree+0x64>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
lea    0xe88(%rip),%rdi
lea    0xe8d(%rip),%r8
call   1040 <malloc_assert_failed@plt>
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<slurm_xfree>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%rax
test   %rax,%rax
je     1162 <slurm_xfree+0x42>
mov    %rdi,%rbx
lea    -0x8(%rax),%r14
cmpl   $0x42,-0x8(%rax)
je     114c <slurm_xfree+0x2c>
lea    0xec0(%rip),%rdi
lea    0xec5(%rip),%r8
call   1040 <malloc_assert_failed@plt>
movl   $0x0,(%r14)
mov    %r14,%rdi
call   1030 <free@plt>
movq   $0x0,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"p[0] == 0x42\00"
@.str.1 = [1 x i8] zeroinitializer
define void @slurm_xfree(i8** %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32*
store i8** %0, i8*** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%10 = load i8**, i8*** %5
%11 = load i8*, i8** %10
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %33
13: ; preds = %4
%14 = load i8**, i8*** %5
%15 = load i8*, i8** %14
%16 = bitcast i8* %15 to i32*
%17 = getelementptr inbounds i32, i32* %16, i64 -2
store i32* %17, i32** %9
%18 = load i32*, i32** %9
%19 = getelementptr inbounds i32, i32* %18, i64 0
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 66
br i1 %21, label %22, label %23
22: ; preds = %13
br label %27
23: ; preds = %13
%24 = load i8*, i8** %6
%25 = load i32, i32* %7
%26 = load i8*, i8** %8
br label %27
27: ; preds = %23, %22
%28 = load i32*, i32** %9
%29 = getelementptr inbounds i32, i32* %28, i64 0
store i32 0, i32* %29
%30 = load i32*, i32** %9
%31 = call i32 @free(i32* %30)
%32 = load i8**, i8*** %5
store i8* null, i8** %32
br label %33
33: ; preds = %27, %4
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"p[0] == 0x42\00"
@.str.1 = [1 x i8] zeroinitializer
define void @slurm_xfree(i8** nocapture %0, i8* %1, i32 %2, i8* %3) {
%5 = load i8*, i8** %0
%6 = icmp eq i8* %5, null
br i1 %6, label %15, label %7
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %5, i64 -8
%9 = bitcast i8* %8 to i32*
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 66
br i1 %11, label %13, label %12
12: ; preds = %7
tail call void @malloc_assert_failed(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %2, i8* %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %7, %12
store i32 0, i32* %9
%14 = tail call i32 @free(i32* %9)
store i8* null, i8** %0
br label %15
15: ; preds = %13, %4
ret void
}