#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 const *);
int /*<<< orphan*/ putchar(char const);
int show_message(const char *p) {
  if (NULL == p) {
    printf("p is NULL\n");
    return -1;
  }
  printf(p);
  int i = 0;
  for (i = 0; p[i] != '\0'; i++) {
    putchar(p[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<show_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    1150 <show_message+0x30>
lea    0xec1(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a2 <show_message+0x82>
mov    -0x10(%rbp),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     119b <show_message+0x7b>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1167 <show_message+0x47>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_message>:
push   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     1165 <show_message+0x35>
mov    %rdi,%rbx
call   1050 <printf@plt>
mov    (%rbx),%al
xor    %ebp,%ebp
test   %al,%al
je     1176 <show_message+0x46>
add    $0x1,%rbx
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1150 <show_message+0x20>
jmp    1176 <show_message+0x46>
lea    0xe94(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@str = [10 x i8] c"p is NULL\00"
define i32 @show_message(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
br label %17
5: ; preds = %1
%6 = tail call i32 @printf(i8* %0)
%7 = load i8, i8* %0
%8 = icmp eq i8 %7, 0
br i1 %8, label %17, label %9
9: ; preds = %5, %9
%10 = phi i64 [ %13, %9 ], [ 0, %5 ]
%11 = phi i8 [ %15, %9 ], [ %7, %5 ]
%12 = tail call i32 @putchar(i8 signext %11)
%13 = add nuw i64 %10, 1
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %9
17: ; preds = %9, %5, %3
%18 = phi i32 [ -1, %3 ], [ 0, %5 ], [ 0, %9 ]
ret i32 %18
}