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

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, ...);
char *irc_buffer_build_name(const char *server, const char *channel) {
  static char buffer[128];
  buffer[0] = '\0';
  if (!server && !channel)
    return buffer;
  if (server && channel)
    snprintf(buffer, sizeof(buffer), "%s.%s", server, channel);
  else
    snprintf(buffer, sizeof(buffer), "%s", (server) ? server : channel);
  return buffer;
}


x86 assembly (clang, -O0):
<irc_buffer_build_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movb   $0x0,0x2f19(%rip)
cmpq   $0x0,-0x10(%rbp)
jne    114d <irc_buffer_build_name+0x3d>
cmpq   $0x0,-0x18(%rbp)
jne    114d <irc_buffer_build_name+0x3d>
lea    0x2efc(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d3 <irc_buffer_build_name+0xc3>
cmpq   $0x0,-0x10(%rbp)
je     118a <irc_buffer_build_name+0x7a>
cmpq   $0x0,-0x18(%rbp)
je     118a <irc_buffer_build_name+0x7a>
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0x2ece(%rip),%rdi
mov    $0x80,%esi
lea    0xe82(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    11c8 <irc_buffer_build_name+0xb8>
cmpq   $0x0,-0x10(%rbp)
je     11a2 <irc_buffer_build_name+0x92>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    11aa <irc_buffer_build_name+0x9a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
lea    0x2e8b(%rip),%rdi
mov    $0x80,%esi
lea    0xe42(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
lea    0x2e71(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<irc_buffer_build_name>:
push   %rax
movb   $0x0,0x2f28(%rip)
mov    %rdi,%rax
or     %rsi,%rax
je     1170 <irc_buffer_build_name+0x60>
mov    %rsi,%r8
mov    %rdi,%rcx
test   %rdi,%rdi
je     114c <irc_buffer_build_name+0x3c>
test   %r8,%r8
je     114c <irc_buffer_build_name+0x3c>
lea    0x2f09(%rip),%rdi
lea    0xec2(%rip),%rdx
mov    $0x80,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
jmp    1170 <irc_buffer_build_name+0x60>
test   %rcx,%rcx
cmovne %rcx,%r8
lea    0x2ee6(%rip),%rdi
lea    0xea2(%rip),%rdx
mov    $0x80,%esi
mov    %r8,%rcx
xor    %eax,%eax
call   1030 <snprintf@plt>
lea    0x2ec9(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@irc_buffer_build_name.buffer = internal global [128 x i8] zeroinitializer
@.str = [6 x i8] c"%s.%s\00"
@.str.1 = [3 x i8] c"%s\00"
define i8* @irc_buffer_build_name(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8 0, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @irc_buffer_build_name.buffer, i64 0, i64 0)
%6 = load i8*, i8** %4
%7 = icmp ne i8* %6, null
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %12, label %11
11: ; preds = %8
store i8* getelementptr inbounds ([128 x i8], [128 x i8]* @irc_buffer_build_name.buffer, i64 0, i64 0), i8** %3
br label %33
12: ; preds = %8, %2
%13 = load i8*, i8** %4
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i8*, i8** %5
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i8*, i8** %4
%20 = load i8*, i8** %5
%21 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @irc_buffer_build_name.buffer, i64 0, i64 0), i32 128, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %19, i8* %20)
br label %32
22: ; preds = %15, %12
%23 = load i8*, i8** %4
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = load i8*, i8** %4
br label %29
27: ; preds = %22
%28 = load i8*, i8** %5
br label %29
29: ; preds = %27, %25
%30 = phi i8* [ %26, %25 ], [ %28, %27 ]
%31 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @irc_buffer_build_name.buffer, i64 0, i64 0), i32 128, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %29, %18
store i8* getelementptr inbounds ([128 x i8], [128 x i8]* @irc_buffer_build_name.buffer, i64 0, i64 0), i8** %3
br label %33
33: ; preds = %32, %11
%34 = load i8*, i8** %3
ret i8* %34
}

LLVM IR (-O2):
@irc_buffer_build_name.buffer = internal global [128 x i8] zeroinitializer
@.str = [6 x i8] c"%s.%s\00"
@.str.1 = [3 x i8] c"%s\00"
define i8* @irc_buffer_build_name(i8* %0, i8* %1) {
store i8 0, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @irc_buffer_build_name.buffer, i64 0, i64 0)
%3 = icmp ne i8* %0, null
%4 = icmp ne i8* %1, null
%5 = or i1 %3, %4
br i1 %5, label %6, label %13
6: ; preds = %2
%7 = and i1 %3, %4
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = tail call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @irc_buffer_build_name.buffer, i64 0, i64 0), i32 128, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
br label %13
10: ; preds = %6
%11 = select i1 %3, i8* %0, i8* %1
%12 = tail call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @irc_buffer_build_name.buffer, i64 0, i64 0), i32 128, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %8, %10, %2
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @irc_buffer_build_name.buffer, i64 0, i64 0)
}