#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 t_relay_weechat_msg {
  int dummy;
};
typedef int /*<<< orphan*/ str_pointer;

/* Variables and functions */
int /*<<< orphan*/ relay_weechat_msg_add_bytes(struct t_relay_weechat_msg *,
                                               ...);
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned long);
unsigned char strlen(char *);
void relay_weechat_msg_add_pointer(struct t_relay_weechat_msg *msg,
                                   void *pointer) {
  char str_pointer[128];
  unsigned char length;
  snprintf(str_pointer, sizeof(str_pointer), "%lx", (long unsigned int)pointer);
  length = strlen(str_pointer);
  relay_weechat_msg_add_bytes(msg, &length, 1);
  relay_weechat_msg_add_bytes(msg, str_pointer, length);
}


x86 assembly (clang, -O0):
<relay_weechat_msg_add_pointer>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x80,%esi
lea    0xea6(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x90(%rbp),%rdi
call   1030 <strlen@plt>
mov    %al,-0x91(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x91(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1040 <relay_weechat_msg_add_bytes@plt>
mov    -0x8(%rbp),%rdi
lea    -0x90(%rbp),%rsi
movzbl -0x91(%rbp),%edx
mov    $0x0,%al
call   1040 <relay_weechat_msg_add_bytes@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<relay_weechat_msg_add_pointer>:
push   %r14
push   %rbx
sub    $0x98,%rsp
mov    %rsi,%rcx
mov    %rdi,%rbx
lea    0xeb9(%rip),%rdx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x80,%esi
call   1050 <snprintf@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %al,0xf(%rsp)
lea    0xf(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <relay_weechat_msg_add_bytes@plt>
movzbl 0xf(%rsp),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <relay_weechat_msg_add_bytes@plt>
add    $0x98,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.t_relay_weechat_msg = type { i32 }
@.str = [4 x i8] c"%lx\00"
define void @relay_weechat_msg_add_pointer(%struct.t_relay_weechat_msg* %0, i8* %1) {
%3 = alloca %struct.t_relay_weechat_msg*
%4 = alloca i8*
%5 = alloca [128 x i8]
%6 = alloca i8
store %struct.t_relay_weechat_msg* %0, %struct.t_relay_weechat_msg** %3
store i8* %1, i8** %4
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%8 = load i8*, i8** %4
%9 = ptrtoint i8* %8 to i64
%10 = call i32 @snprintf(i8* %7, i32 128, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %9)
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%12 = call zeroext i8 @strlen(i8* %11)
store i8 %12, i8* %6
%13 = load %struct.t_relay_weechat_msg*, %struct.t_relay_weechat_msg** %3
%14 = call i32 (%struct.t_relay_weechat_msg*, ...) @relay_weechat_msg_add_bytes(%struct.t_relay_weechat_msg* %13, i8* %6, i32 1)
%15 = load %struct.t_relay_weechat_msg*, %struct.t_relay_weechat_msg** %3
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%17 = load i8, i8* %6
%18 = zext i8 %17 to i32
%19 = call i32 (%struct.t_relay_weechat_msg*, ...) @relay_weechat_msg_add_bytes(%struct.t_relay_weechat_msg* %15, i8* %16, i32 %18)
ret void
}

LLVM IR (-O2):
%struct.t_relay_weechat_msg = type { i32 }
@.str = [4 x i8] c"%lx\00"
define void @relay_weechat_msg_add_pointer(%struct.t_relay_weechat_msg* %0, i8* %1) {
%3 = alloca [128 x i8]
%4 = alloca i8
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = ptrtoint i8* %1 to i64
%7 = call i32 @snprintf(i8* %5, i32 128, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %6)
%8 = call zeroext i8 @strlen(i8* %5)
store i8 %8, i8* %4
%9 = call i32 (%struct.t_relay_weechat_msg*, ...) @relay_weechat_msg_add_bytes(%struct.t_relay_weechat_msg* %0, i8* %4, i32 1)
%10 = load i8, i8* %4
%11 = zext i8 %10 to i32
%12 = call i32 (%struct.t_relay_weechat_msg*, ...) @relay_weechat_msg_add_bytes(%struct.t_relay_weechat_msg* %0, i8* %5, i32 %11)
ret void
}