#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*/ printf(char *, char const *, void *, char const *, int,
                          size_t);
char *strrchr(char const *, char);
void debug_print(const char *op, void *p, const char *filename, int lineno,
                 size_t size) {
  char sep = '/';
  const char *ptr = strrchr(filename, sep);
  if (sep) {
    filename = ptr + 1;
  }
  printf("%s: %p %s:%i %zu bytes\n", op, p, filename, lineno, size);
}


x86 assembly (clang, -O0):
<debug_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
movb   $0x2f,-0x29(%rbp)
mov    -0x18(%rbp),%rdi
movsbl -0x29(%rbp),%esi
call   1040 <strrchr@plt>
mov    %rax,-0x38(%rbp)
cmpb   $0x0,-0x29(%rbp)
je     1166 <debug_print+0x46>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
mov    -0x28(%rbp),%r9
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debug_print>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8,%r14
mov    %ecx,%r15d
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    %rdx,%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
lea    0x1(%rax),%rcx
lea    0xeb5(%rip),%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r15d,%r8d
mov    %r14,%r9
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"%s: %p %s:%i %zu bytes\0A\00"
define void @debug_print(i8* %0, i8* %1, i8* %2, i32 %3, i64 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i64
%11 = alloca i8
%12 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i64 %4, i64* %10
store i8 47, i8* %11
%13 = load i8*, i8** %8
%14 = load i8, i8* %11
%15 = call i8* @strrchr(i8* %13, i8 signext %14)
store i8* %15, i8** %12
%16 = load i8, i8* %11
%17 = icmp ne i8 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %5
%19 = load i8*, i8** %12
%20 = getelementptr inbounds i8, i8* %19, i64 1
store i8* %20, i8** %8
br label %21
21: ; preds = %18, %5
%22 = load i8*, i8** %6
%23 = load i8*, i8** %7
%24 = load i8*, i8** %8
%25 = load i32, i32* %9
%26 = load i64, i64* %10
%27 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %22, i8* %23, i8* %24, i32 %25, i64 %26)
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"%s: %p %s:%i %zu bytes\0A\00"
define void @debug_print(i8* %0, i8* %1, i8* %2, i32 %3, i64 %4) {
%6 = tail call i8* @strrchr(i8* dereferenceable(1) %2, i8 signext 47)
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i8* %7, i32 %3, i64 %4)
ret void
}