#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 *, ...);
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 if (server)
    snprintf(buffer, sizeof(buffer), "server.%s", server);
  else
    snprintf(buffer, sizeof(buffer), "%s", 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    11e6 <irc_buffer_build_name+0xd6>
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    11db <irc_buffer_build_name+0xcb>
cmpq   $0x0,-0x10(%rbp)
je     11b8 <irc_buffer_build_name+0xa8>
mov    -0x10(%rbp),%rcx
lea    0x2ea0(%rip),%rdi
mov    $0x80,%esi
lea    0xe5a(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    11d6 <irc_buffer_build_name+0xc6>
mov    -0x18(%rbp),%rcx
lea    0x2e7d(%rip),%rdi
mov    $0x80,%esi
lea    0xe3e(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    11db <irc_buffer_build_name+0xcb>
lea    0x2e5e(%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     117c <irc_buffer_build_name+0x6c>
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    117c <irc_buffer_build_name+0x6c>
lea    0x2eed(%rip),%rdi
test   %rcx,%rcx
je     1166 <irc_buffer_build_name+0x56>
lea    0xea7(%rip),%rdx
mov    $0x80,%esi
jmp    1175 <irc_buffer_build_name+0x65>
lea    0xea0(%rip),%rdx
mov    $0x80,%esi
mov    %r8,%rcx
xor    %eax,%eax
call   1030 <snprintf@plt>
lea    0x2ebd(%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 = [10 x i8] c"server.%s\00"
@.str.2 = [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 %28
25: ; preds = %22
%26 = load i8*, i8** %4
%27 = 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 ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %26)
br label %31
28: ; preds = %22
%29 = load i8*, i8** %5
%30 = 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.2, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %28, %25
br label %32
32: ; preds = %31, %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 = [10 x i8] c"server.%s\00"
@.str.2 = [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 %15
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 %15
10: ; preds = %6
br i1 %3, label %11, label %13
11: ; preds = %10
%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 ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %15
13: ; preds = %10
%14 = 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.2, i64 0, i64 0), i8* %1)
br label %15
15: ; preds = %8, %13, %11, %2
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @irc_buffer_build_name.buffer, i64 0, i64 0)
}