#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*/ exit(int);
int /*<<< orphan*/ free(void *);
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ nixtrace(char *, ...);
int /*<<< orphan*/ printf(char *);
void check_free(void *palt) {
  char *p;
  long size_lfd;
  nixtrace("Start check_free\n");
  nixtrace("palt   %p \n", palt);
  if (palt == NULL) {
    printf("schrecklicher Fehler in check_free\n");
    printf("NULL-pointer erhalten\n");
    return;
  }
  p = palt;
  p -= 12;
  nixtrace("Pruefung der Integritaet\n");
  if (memcmp(p, "<0123456789>", 12) != 0) {
    printf("check_free - schrecklicher Speicherfehler\n");
    printf("Bereich vor Datenblock zerstoert\n");
    exit(20);
  }
  size_lfd = *((long *)(p + 20));
  if (memcmp(p + 24 + size_lfd, "<0123456789>", 12) != 0) {
    printf("check_free - schrecklicher Speicherfehler\n");
    printf("Bereich nach Datenblock zerstoert\n");
    exit(20);
  }
  free((void *)p);
  nixtrace("Ende check_free\n");
  return;
}


x86 assembly (clang, -O0):
<check_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1070 <nixtrace@plt>
mov    -0x8(%rbp),%rsi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1070 <nixtrace@plt>
cmpq   $0x0,-0x8(%rbp)
jne    11a4 <check_free+0x54>
lea    0xe90(%rip),%rdi
call   1040 <printf@plt>
lea    0xea8(%rip),%rdi
call   1040 <printf@plt>
jmp    1273 <check_free+0x123>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0xfffffffffffffff4,%rax
mov    %rax,-0x10(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1070 <nixtrace@plt>
mov    -0x10(%rbp),%rdi
lea    0xea2(%rip),%rsi
mov    $0xc,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     1207 <check_free+0xb7>
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb3(%rip),%rdi
call   1040 <printf@plt>
mov    $0x14,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x18,%rdi
add    -0x18(%rbp),%rdi
lea    0xe4d(%rip),%rsi
mov    $0xc,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     125c <check_free+0x10c>
lea    0xe3f(%rip),%rdi
call   1040 <printf@plt>
lea    0xe80(%rip),%rdi
call   1040 <printf@plt>
mov    $0x14,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1070 <nixtrace@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_free>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xea2(%rip),%rdi
xor    %eax,%eax
call   1070 <nixtrace@plt>
lea    0xea6(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <nixtrace@plt>
test   %rbx,%rbx
je     11e5 <check_free+0x95>
lea    -0xc(%rbx),%r14
lea    0xe98(%rip),%rdi
xor    %eax,%eax
call   1070 <nixtrace@plt>
lea    0xea4(%rip),%rsi
mov    %r14,%rdi
mov    $0xc,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    1204 <check_free+0xb4>
mov    0x8(%rbx),%rax
lea    (%rbx,%rax,1),%rdi
add    $0xc,%rdi
lea    0xe7f(%rip),%rsi
mov    $0xc,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    1219 <check_free+0xc9>
mov    %r14,%rdi
call   1030 <free@plt>
lea    0xe6e(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <nixtrace@plt>
lea    0xed7(%rip),%rdi
call   1040 <puts@plt>
lea    0xeee(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <puts@plt>
lea    0xe6d(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8b(%rip),%rdi
jmp    122c <check_free+0xdc>
lea    0xe58(%rip),%rdi
call   1040 <puts@plt>
lea    0xe2a(%rip),%rdi
call   1040 <puts@plt>
mov    $0x14,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"Start check_free\0A\00"
@.str.1 = [12 x i8] c"palt %p \0A\00"
@.str.2 = [36 x i8] c"schrecklicher Fehler in check_free\0A\00"
@.str.3 = [23 x i8] c"NULL-pointer erhalten\0A\00"
@.str.4 = [26 x i8] c"Pruefung der Integritaet\0A\00"
@.str.5 = [13 x i8] c"<0123456789>\00"
@.str.6 = [43 x i8] c"check_free - schrecklicher Speicherfehler\0A\00"
@.str.7 = [34 x i8] c"Bereich vor Datenblock zerstoert\0A\00"
@.str.8 = [35 x i8] c"Bereich nach Datenblock zerstoert\0A\00"
@.str.9 = [17 x i8] c"Ende check_free\0A\00"
define void @check_free(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %2
%5 = call i32 (i8*, ...) @nixtrace(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = load i8*, i8** %2
%7 = call i32 (i8*, ...) @nixtrace(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = load i8*, i8** %2
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %44
13: ; preds = %1
%14 = load i8*, i8** %2
store i8* %14, i8** %3
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 -12
store i8* %16, i8** %3
%17 = call i32 (i8*, ...) @nixtrace(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%18 = load i8*, i8** %3
%19 = call i64 @memcmp(i8* %18, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 12)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %13
%22 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
%24 = call i32 @exit(i32 20)
unreachable
25: ; preds = %13
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 20
%28 = bitcast i8* %27 to i64*
%29 = load i64, i64* %28
store i64 %29, i64* %4
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i64 24
%32 = load i64, i64* %4
%33 = getelementptr inbounds i8, i8* %31, i64 %32
%34 = call i64 @memcmp(i8* %33, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 12)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %25
%37 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0))
%38 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0))
%39 = call i32 @exit(i32 20)
unreachable
40: ; preds = %25
%41 = load i8*, i8** %3
%42 = call i32 @free(i8* %41)
%43 = call i32 (i8*, ...) @nixtrace(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
br label %44
44: ; preds = %40, %10
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"Start check_free\0A\00"
@.str.1 = [12 x i8] c"palt %p \0A\00"
@.str.4 = [26 x i8] c"Pruefung der Integritaet\0A\00"
@.str.5 = [13 x i8] c"<0123456789>\00"
@.str.9 = [17 x i8] c"Ende check_free\0A\00"
@str.10 = [34 x i8] c"Bereich nach Datenblock zerstoert\00"
@str.11 = [42 x i8] c"check_free - schrecklicher Speicherfehler\00"
@str.12 = [33 x i8] c"Bereich vor Datenblock zerstoert\00"
@str.13 = [35 x i8] c"schrecklicher Fehler in check_free\00"
@str.14 = [22 x i8] c"NULL-pointer erhalten\00"
define void @check_free(i8* %0) {
%2 = tail call i32 (i8*, ...) @nixtrace(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @nixtrace(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%4 = icmp eq i8* %0, null
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.13, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.14, i64 0, i64 0))
br label %32
8: ; preds = %1
%9 = getelementptr inbounds i8, i8* %0, i64 -12
%10 = tail call i32 (i8*, ...) @nixtrace(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%11 = tail call i64 @memcmp(i8* %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 12)
%12 = icmp eq i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %8
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.11, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.12, i64 0, i64 0))
%16 = tail call i32 @exit(i32 20)
unreachable
17: ; preds = %8
%18 = getelementptr inbounds i8, i8* %0, i64 8
%19 = bitcast i8* %18 to i64*
%20 = load i64, i64* %19
%21 = getelementptr inbounds i8, i8* %0, i64 12
%22 = getelementptr inbounds i8, i8* %21, i64 %20
%23 = tail call i64 @memcmp(i8* %22, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 12)
%24 = icmp eq i64 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %17
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.11, i64 0, i64 0))
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.10, i64 0, i64 0))
%28 = tail call i32 @exit(i32 20)
unreachable
29: ; preds = %17
%30 = tail call i32 @free(i8* %9)
%31 = tail call i32 (i8*, ...) @nixtrace(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
br label %32
32: ; preds = %29, %5
ret void
}