#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*/ text;
typedef int /*<<< orphan*/ format;
typedef int /*<<< orphan*/ address;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned long);
const char *format_address(unsigned long address) {
  static char format[10], text[200];
  if (!*format)
    snprintf(format, sizeof(format), "%%0%dlx", 2 * sizeof(address));
  snprintf(text, sizeof(text), format, address);
  return (text);
}


x86 assembly (clang, -O0):
<format_address>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpb   $0x0,0x2f1d(%rip)
jne    1146 <format_address+0x36>
lea    0x2f10(%rip),%rdi
mov    $0xa,%esi
lea    0xec4(%rip),%rdx
mov    $0x10,%ecx
call   1030 <snprintf@plt>
mov    -0x8(%rbp),%rcx
lea    0x2eff(%rip),%rdi
mov    $0xc8,%esi
lea    0x2ee3(%rip),%rdx
call   1030 <snprintf@plt>
lea    0x2ee7(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_address>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
cmpb   $0x0,0x2f22(%rip)
jne    113d <format_address+0x2d>
lea    0x2f19(%rip),%rdi
lea    0xed2(%rip),%rdx
mov    $0x10,%ecx
mov    $0xa,%esi
call   1030 <snprintf@plt>
lea    0x2f0c(%rip),%rbx
lea    0x2ef5(%rip),%rdx
mov    %rbx,%rdi
mov    $0xc8,%esi
mov    %r14,%rcx
call   1030 <snprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@format_address.format = internal global [10 x i8] zeroinitializer
@format_address.text = internal global [200 x i8] zeroinitializer
@.str = [8 x i8] c"%%0%dlx\00"
define i8* @format_address(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @format_address.format, i64 0, i64 0)
%4 = icmp ne i8 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = call i32 @snprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @format_address.format, i64 0, i64 0), i32 10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 16)
br label %7
7: ; preds = %5, %1
%8 = load i64, i64* %2
%9 = call i32 @snprintf(i8* getelementptr inbounds ([200 x i8], [200 x i8]* @format_address.text, i64 0, i64 0), i32 200, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @format_address.format, i64 0, i64 0), i64 %8)
ret i8* getelementptr inbounds ([200 x i8], [200 x i8]* @format_address.text, i64 0, i64 0)
}

LLVM IR (-O2):
@format_address.format = internal global [10 x i8] zeroinitializer
@format_address.text = internal global [200 x i8] zeroinitializer
@.str = [8 x i8] c"%%0%dlx\00"
define i8* @format_address(i64 %0) {
%2 = load i8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @format_address.format, i64 0, i64 0)
%3 = icmp eq i8 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @snprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @format_address.format, i64 0, i64 0), i32 10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 16)
br label %6
6: ; preds = %4, %1
%7 = tail call i32 @snprintf(i8* getelementptr inbounds ([200 x i8], [200 x i8]* @format_address.text, i64 0, i64 0), i32 200, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @format_address.format, i64 0, i64 0), i64 %0)
ret i8* getelementptr inbounds ([200 x i8], [200 x i8]* @format_address.text, i64 0, i64 0)
}