#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 */
struct list_node {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           struct list_node const *, unsigned int,
                           struct list_node const *);
int /*<<< orphan*/ stderr;
void *corrupt(const char *abortstr, const struct list_node *head,
              const struct list_node *node, unsigned int count) {
  if (abortstr) {
    fprintf(stderr, "%s: prev corrupt in node %p (%u) of %p\n", abortstr, node,
            count, head);
    abort();
  }
  return NULL;
}


x86 assembly (clang, -O0):
<corrupt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     116e <corrupt+0x4e>
mov    0x2e97(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
mov    -0x10(%rbp),%r9
lea    0xe9e(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<corrupt>:
test   %rdi,%rdi
jne    1128 <corrupt+0x8>
xor    %eax,%eax
ret
push   %rax
mov    %ecx,%r8d
mov    %rdx,%rcx
mov    %rsi,%r9
mov    %rdi,%rdx
mov    0x2ea4(%rip),%rax
mov    (%rax),%edi
lea    0xebb(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.list_node = type { i32 }
@stderr = global i32 0
@.str = [40 x i8] c"%s: prev corrupt in node %p (%u) of %p\0A\00"
define i8* @corrupt(i8* %0, %struct.list_node* %1, %struct.list_node* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca %struct.list_node*
%7 = alloca %struct.list_node*
%8 = alloca i32
store i8* %0, i8** %5
store %struct.list_node* %1, %struct.list_node** %6
store %struct.list_node* %2, %struct.list_node** %7
store i32 %3, i32* %8
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %19
11: ; preds = %4
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %5
%14 = load %struct.list_node*, %struct.list_node** %7
%15 = load i32, i32* %8
%16 = load %struct.list_node*, %struct.list_node** %6
%17 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %13, %struct.list_node* %14, i32 %15, %struct.list_node* %16)
%18 = call i32 (...) @abort()
unreachable
19: ; preds = %4
ret i8* null
}

LLVM IR (-O2):
%struct.list_node = type { i32 }
@stderr = global i32 0
@.str = [40 x i8] c"%s: prev corrupt in node %p (%u) of %p\0A\00"
define noalias i8* @corrupt(i8* %0, %struct.list_node* %1, %struct.list_node* %2, i32 %3) {
%5 = icmp eq i8* %0, null
br i1 %5, label %10, label %6
6: ; preds = %4
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %0, %struct.list_node* %2, i32 %3, %struct.list_node* %1)
%9 = tail call i32 (...) @abort()
unreachable
10: ; preds = %4
ret i8* null
}