#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*/ snprintf(char *, size_t, char *, char *, long);
void combined_name(char *buf, size_t buf_sz, long id,
                   const char *(*get_name)(long)) {
  const char *friendlyname = get_name(id);
  snprintf(buf, buf_sz, "%s{%ld}",
           (friendlyname == NULL ? "unknown" : friendlyname), id);
}


x86 assembly (clang, -O0):
<combined_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rdi
call   *%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1161 <combined_name+0x51>
lea    0xeb0(%rip),%rax
mov    %rax,-0x40(%rbp)
jmp    1169 <combined_name+0x59>
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0xe80(%rip),%rdx
call   1030 <snprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<combined_name>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rdx,%rdi
call   *%rcx
test   %rax,%rax
lea    0xedb(%rip),%rcx
cmovne %rax,%rcx
lea    0xec8(%rip),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%r8
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <snprintf@plt>

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

LLVM IR (-O2):
@.str = [8 x i8] c"%s{%ld}\00"
@.str.1 = [8 x i8] c"unknown\00"
define void @combined_name(i8* %0, i64 %1, i64 %2, i8* (i64)* nocapture %3) {
%5 = tail call i8* %3(i64 %2)
%6 = icmp eq i8* %5, null
%7 = select i1 %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %5
%8 = tail call i32 @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %7, i64 %2)
ret void
}