#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 DebugStrbuf {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ debug_strbuf_buffer_commit(struct DebugStrbuf *, int);
int /*<<< orphan*/ debug_strbuf_buffer_get(struct DebugStrbuf *, char **,
                                           int *);
int format_ipaddress(char *, int, unsigned char const *);
const char *debug_strbuf_ipaddress(struct DebugStrbuf *buf,
                                   const unsigned char address[16]) {
  int used;
  char *p;
  int p_len;
  debug_strbuf_buffer_get(buf, &p, &p_len);
  used = format_ipaddress(p, p_len, address);
  debug_strbuf_buffer_commit(buf, used + 1);
  return p;
}


x86 assembly (clang, -O0):
<debug_strbuf_ipaddress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1030 <debug_strbuf_buffer_get@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1050 <format_ipaddress@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
call   1040 <debug_strbuf_buffer_commit@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debug_strbuf_ipaddress>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1030 <debug_strbuf_buffer_get@plt>
mov    0x10(%rsp),%rdi
mov    0xc(%rsp),%esi
mov    %r14,%rdx
call   1050 <format_ipaddress@plt>
lea    0x1(%rax),%esi
mov    %rbx,%rdi
call   1040 <debug_strbuf_buffer_commit@plt>
mov    0x10(%rsp),%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.DebugStrbuf = type { i32 }
define i8* @debug_strbuf_ipaddress(%struct.DebugStrbuf* %0, i8* %1) {
%3 = alloca %struct.DebugStrbuf*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store %struct.DebugStrbuf* %0, %struct.DebugStrbuf** %3
store i8* %1, i8** %4
%8 = load %struct.DebugStrbuf*, %struct.DebugStrbuf** %3
%9 = call i32 @debug_strbuf_buffer_get(%struct.DebugStrbuf* %8, i8** %6, i32* %7)
%10 = load i8*, i8** %6
%11 = load i32, i32* %7
%12 = load i8*, i8** %4
%13 = call i32 @format_ipaddress(i8* %10, i32 %11, i8* %12)
store i32 %13, i32* %5
%14 = load %struct.DebugStrbuf*, %struct.DebugStrbuf** %3
%15 = load i32, i32* %5
%16 = add nsw i32 %15, 1
%17 = call i32 @debug_strbuf_buffer_commit(%struct.DebugStrbuf* %14, i32 %16)
%18 = load i8*, i8** %6
ret i8* %18
}

LLVM IR (-O2):
%struct.DebugStrbuf = type { i32 }
define i8* @debug_strbuf_ipaddress(%struct.DebugStrbuf* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = bitcast i8** %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = call i32 @debug_strbuf_buffer_get(%struct.DebugStrbuf* %0, i8** %3, i32* %4)
%8 = load i8*, i8** %3
%9 = load i32, i32* %4
%10 = call i32 @format_ipaddress(i8* %8, i32 %9, i8* %1)
%11 = add nsw i32 %10, 1
%12 = call i32 @debug_strbuf_buffer_commit(%struct.DebugStrbuf* %0, i32 %11)
%13 = load i8*, i8** %3
ret i8* %13
}