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

/* Variables and functions */
int /*<<< orphan*/ asprintf(char **, char *, char const *, int, int, int);
int peer_id_analysis(char const *, char const **, int *, int *, int *);
int peer_id_friendly(const char *id, char **out) {
  const char *client;
  int major, minor, patch;
  int res = peer_id_analysis(id, &client, &major, &minor, &patch);
  if (res != 0)
    return res;
  asprintf(out, "%s %d.%d.%d", client, major, minor, patch);
  return 0;
}


x86 assembly (clang, -O0):
<peer_id_friendly>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x2c(%rbp),%r8
call   1030 <peer_id_analysis@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     1161 <peer_id_friendly+0x41>
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1187 <peer_id_friendly+0x67>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
lea    0xe85(%rip),%rsi
call   1040 <asprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<peer_id_friendly>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
call   1030 <peer_id_analysis@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    116a <peer_id_friendly+0x4a>
mov    0x10(%rsp),%rdx
mov    0xc(%rsp),%ecx
mov    0x8(%rsp),%r8d
mov    0x4(%rsp),%r9d
lea    0xe9e(%rip),%rsi
mov    %rbx,%rdi
call   1040 <asprintf@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%s %d.%d.%d\00"
define i32 @peer_id_friendly(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
%11 = load i8*, i8** %4
%12 = call i32 @peer_id_analysis(i8* %11, i8** %6, i32* %7, i32* %8, i32* %9)
store i32 %12, i32* %10
%13 = load i32, i32* %10
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = load i32, i32* %10
store i32 %16, i32* %3
br label %24
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = load i8*, i8** %6
%20 = load i32, i32* %7
%21 = load i32, i32* %8
%22 = load i32, i32* %9
%23 = call i32 @asprintf(i8** %18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %19, i32 %20, i32 %21, i32 %22)
store i32 0, i32* %3
br label %24
24: ; preds = %17, %15
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@.str = [12 x i8] c"%s %d.%d.%d\00"
define i32 @peer_id_friendly(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i8** %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = call i32 @peer_id_analysis(i8* %0, i8** %3, i32* %4, i32* %5, i32* %6)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i8*, i8** %3
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = load i32, i32* %6
%18 = call i32 @asprintf(i8** %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %14, i32 %15, i32 %16, i32 %17)
br label %19
19: ; preds = %2, %13
ret i32 %11
}