#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 */
typedef int /*<<< orphan*/ pointer_str;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned long);
char *strdup(char *);
char *plugin_script_ptr2str(void *pointer) {
  char pointer_str[128];
  if (!pointer)
    return strdup("");
  snprintf(pointer_str, sizeof(pointer_str), "0x%lx",
           (long unsigned int)pointer);
  return strdup(pointer_str);
}


x86 assembly (clang, -O0):
<plugin_script_ptr2str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114f <plugin_script_ptr2str+0x2f>
lea    0xec4(%rip),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    117b <plugin_script_ptr2str+0x5b>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x80,%esi
lea    0xe9a(%rip),%rdx
call   1030 <snprintf@plt>
lea    -0x90(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<plugin_script_ptr2str>:
test   %rdi,%rdi
je     1158 <plugin_script_ptr2str+0x38>
push   %rbx
sub    $0x80,%rsp
mov    %rdi,%rcx
lea    0xec9(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1030 <snprintf@plt>
mov    %rbx,%rdi
call   1040 <strdup@plt>
add    $0x80,%rsp
pop    %rbx
ret
lea    0xea6(%rip),%rdi
jmp    1040 <strdup@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [6 x i8] c"0x%lx\00"
define i8* @plugin_script_ptr2str(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [128 x i8]
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %2
br label %16
9: ; preds = %1
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%11 = load i8*, i8** %3
%12 = ptrtoint i8* %11 to i64
%13 = call i32 @snprintf(i8* %10, i32 128, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %12)
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%15 = call i8* @strdup(i8* %14)
store i8* %15, i8** %2
br label %16
16: ; preds = %9, %7
%17 = load i8*, i8** %2
ret i8* %17
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [6 x i8] c"0x%lx\00"
define noalias i8* @plugin_script_ptr2str(i8* %0) {
%2 = alloca [128 x i8]
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%4 = icmp eq i8* %0, null
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call dereferenceable_or_null(1) i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %11
7: ; preds = %1
%8 = ptrtoint i8* %0 to i64
%9 = call i32 @snprintf(i8* %3, i32 128, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %8)
%10 = call i8* @strdup(i8* %3)
br label %11
11: ; preds = %7, %5
%12 = phi i8* [ %10, %7 ], [ %6, %5 ]
ret i8* %12
}