#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*/ print_string(char, char *, int, char);
int /*<<< orphan*/ printf(char *, ...);
void print_string_with_title(char ignore_nulls_flag, char *title, char *str,
                             int len, char hex_flag) {
  if (title == 0) {
    printf("Error:\t%s\n",
           "Null Pointer Exception - print_string_safely_with_title");
    exit(-1);
  }
  printf("%s = [", title);
  print_string(ignore_nulls_flag, str, len, hex_flag);
  printf("]\n");
}


x86 assembly (clang, -O0):
<print_string_with_title>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %r8b,%al
mov    %dil,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %al,-0x1d(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1177 <print_string_with_title+0x47>
lea    0xea1(%rip),%rdi
lea    0xea5(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rsi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1(%rbp),%al
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
movsbl %al,%edi
movsbl -0x1d(%rbp),%ecx
call   1040 <print_string@plt>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_string_with_title>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rsi,%rsi
je     118d <print_string_with_title+0x4d>
mov    %r8d,%ebp
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %edi,%ebx
lea    0xee5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl %bl,%edi
movsbl %bpl,%ecx
mov    %r15,%rsi
mov    %r14d,%edx
call   1050 <print_string@plt>
lea    0xecc(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>
lea    0xe6c(%rip),%rdi
lea    0xe70(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"Error:\09%s\0A\00"
@.str.1 = [56 x i8] c"Null Pointer Exception - print_string_safely_with_title\00"
@.str.2 = [7 x i8] c"%s = [\00"
@.str.3 = [3 x i8] c"]\0A\00"
define void @print_string_with_title(i8 signext %0, i8* %1, i8* %2, i32 %3, i8 signext %4) {
%6 = alloca i8
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8
store i8 %0, i8* %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i8 %4, i8* %10
%11 = load i8*, i8** %7
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @exit(i32 -1)
unreachable
16: ; preds = %5
%17 = load i8*, i8** %7
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = load i8, i8* %6
%20 = load i8*, i8** %8
%21 = load i32, i32* %9
%22 = load i8, i8* %10
%23 = call i32 @print_string(i8 signext %19, i8* %20, i32 %21, i8 signext %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"Error:\09%s\0A\00"
@.str.1 = [56 x i8] c"Null Pointer Exception - print_string_safely_with_title\00"
@.str.2 = [7 x i8] c"%s = [\00"
@str = [2 x i8] c"]\00"
define void @print_string_with_title(i8 signext %0, i8* %1, i8* %2, i32 %3, i8 signext %4) {
%6 = icmp eq i8* %1, null
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %5
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%12 = tail call i32 @print_string(i8 signext %0, i8* %2, i32 %3, i8 signext %4)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
}