#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*/ __u32;

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, int, int, int);
int tipc_cluster(int /*<<< orphan*/);
int tipc_node(int /*<<< orphan*/);
int tipc_zone(int /*<<< orphan*/);
const char *addr2str(__u32 addr) {
  static char addr_area[2][16];
  static int addr_crs = 0;
  addr_crs = !addr_crs;
  sprintf(&addr_area[addr_crs][0], "<%u.%u.%u>", tipc_zone(addr),
          tipc_cluster(addr), tipc_node(addr));
  return &addr_area[addr_crs][0];
}


x86 assembly (clang, -O0):
<addr2str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,0x2f1e(%rip)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,0x2f0e(%rip)
movslq 0x2f07(%rip),%rcx
lea    0x2ee0(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <tipc_zone@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <tipc_cluster@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <tipc_node@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    %eax,%r8d
lea    0xe53(%rip),%rsi
call   1050 <sprintf@plt>
movslq 0x2eb7(%rip),%rcx
lea    0x2e90(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addr2str>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%ebp
xor    %ebx,%ebx
cmpl   $0x0,0x2f1d(%rip)
sete   %bl
mov    %ebx,0x2f14(%rip)
shl    $0x4,%rbx
lea    0x2ee9(%rip),%r12
add    %r12,%rbx
call   1040 <tipc_zone@plt>
mov    %eax,%r14d
mov    %ebp,%edi
call   1060 <tipc_cluster@plt>
mov    %eax,%r15d
mov    %ebp,%edi
call   1030 <tipc_node@plt>
lea    0xe76(%rip),%rsi
mov    %rbx,%rdi
mov    %r14d,%edx
mov    %r15d,%ecx
mov    %eax,%r8d
call   1050 <sprintf@plt>
mov    0x2ecf(%rip),%eax
shl    $0x4,%rax
add    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@addr2str.addr_area = internal global [2 x [16 x i8]] zeroinitializer
@addr2str.addr_crs = internal global i32 0
@.str = [11 x i8] c"<%u.%u.%u>\00"
define i8* @addr2str(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* @addr2str.addr_crs
%4 = icmp ne i32 %3, 0
%5 = xor i1 %4, true
%6 = zext i1 %5 to i32
store i32 %6, i32* @addr2str.addr_crs
%7 = load i32, i32* @addr2str.addr_crs
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [2 x [16 x i8]], [2 x [16 x i8]]* @addr2str.addr_area, i64 0, i64 %8
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%11 = load i32, i32* %2
%12 = call i32 @tipc_zone(i32 %11)
%13 = load i32, i32* %2
%14 = call i32 @tipc_cluster(i32 %13)
%15 = load i32, i32* %2
%16 = call i32 @tipc_node(i32 %15)
%17 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %14, i32 %16)
%18 = load i32, i32* @addr2str.addr_crs
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [2 x [16 x i8]], [2 x [16 x i8]]* @addr2str.addr_area, i64 0, i64 %19
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %20, i64 0, i64 0
ret i8* %21
}

LLVM IR (-O2):
@addr2str.addr_area = internal global [2 x [16 x i8]] zeroinitializer
@addr2str.addr_crs = internal unnamed_addr global i32 0
@.str = [11 x i8] c"<%u.%u.%u>\00"
define i8* @addr2str(i32 %0) {
%2 = load i32, i32* @addr2str.addr_crs
%3 = icmp eq i32 %2, 0
%4 = zext i1 %3 to i32
store i32 %4, i32* @addr2str.addr_crs
%5 = zext i1 %3 to i64
%6 = getelementptr inbounds [2 x [16 x i8]], [2 x [16 x i8]]* @addr2str.addr_area, i64 0, i64 %5, i64 0
%7 = tail call i32 @tipc_zone(i32 %0)
%8 = tail call i32 @tipc_cluster(i32 %0)
%9 = tail call i32 @tipc_node(i32 %0)
%10 = tail call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8, i32 %9)
%11 = load i32, i32* @addr2str.addr_crs
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds [2 x [16 x i8]], [2 x [16 x i8]]* @addr2str.addr_area, i64 0, i64 %12, i64 0
ret i8* %13
}