#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 uint16_t;
typedef int /*<<< orphan*/ namebuf;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, int);
const char *__twopence_transaction_channel_name(uint16_t id) {
  static char namebuf[16];
  if (id == 0xFFFF)
    return "all";
  snprintf(namebuf, sizeof(namebuf), "chan%u", id);
  return namebuf;
}


x86 assembly (clang, -O0):
<__twopence_transaction_channel_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0xffff,-0xc(%rbp)
jne    1138 <__twopence_transaction_channel_name+0x28>
lea    0xed1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    115e <__twopence_transaction_channel_name+0x4e>
mov    -0xc(%rbp),%ecx
lea    0x2efe(%rip),%rdi
mov    $0x10,%esi
lea    0xeb6(%rip),%rdx
call   1030 <snprintf@plt>
lea    0x2ee6(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__twopence_transaction_channel_name>:
push   %rbx
cmp    $0xffff,%edi
jne    1122 <__twopence_transaction_channel_name+0x12>
lea    0xee0(%rip),%rbx
jmp    113f <__twopence_transaction_channel_name+0x2f>
mov    %edi,%ecx
lea    0x2f15(%rip),%rbx
lea    0xed2(%rip),%rdx
mov    %rbx,%rdi
mov    $0x10,%esi
call   1030 <snprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
@__twopence_transaction_channel_name.namebuf = internal global [16 x i8] zeroinitializer
@.str = [4 x i8] c"all\00"
@.str.1 = [7 x i8] c"chan%u\00"
define i8* @__twopence_transaction_channel_name(i32 %0) {
%2 = icmp eq i32 %0, 65535
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = tail call i32 @snprintf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__twopence_transaction_channel_name.namebuf, i64 0, i64 0), i32 16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %5
5: ; preds = %1, %3
%6 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @__twopence_transaction_channel_name.namebuf, i64 0, i64 0), %3 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %6
}