#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 irc_printf(int, char *, char const *, ...);
int irc_join(int fd, const char *channel, const char *key) {
  if (key && *key) {
    return irc_printf(fd, "JOIN %s :%s\r\n", channel, key);
  } else {
    return irc_printf(fd, "JOIN %s\r\n", channel);
  }
}


x86 assembly (clang, -O0):
<irc_join>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     115f <irc_join+0x4f>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     115f <irc_join+0x4f>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xeb0(%rip),%rsi
mov    $0x0,%al
call   1030 <irc_printf@plt>
mov    %eax,-0x4(%rbp)
jmp    1177 <irc_join+0x67>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rdx
lea    0xea1(%rip),%rsi
mov    $0x0,%al
call   1030 <irc_printf@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<irc_join>:
mov    %rdx,%rcx
mov    %rsi,%rdx
test   %rcx,%rcx
je     112e <irc_join+0x1e>
cmpb   $0x0,(%rcx)
je     112e <irc_join+0x1e>
lea    0xed9(%rip),%rsi
xor    %eax,%eax
jmp    1030 <irc_printf@plt>
lea    0xed9(%rip),%rsi
xor    %eax,%eax
jmp    1030 <irc_printf@plt>

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

LLVM IR (-O2):
@.str = [14 x i8] c"JOIN %s :%s\0D\0A\00"
@.str.1 = [10 x i8] c"JOIN %s\0D\0A\00"
define i32 @irc_join(i32 %0, i8* %1, i8* %2) {
%4 = icmp eq i8* %2, null
br i1 %4, label %10, label %5
5: ; preds = %3
%6 = load i8, i8* %2
%7 = icmp eq i8 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 (i32, i8*, i8*, ...) @irc_printf(i32 %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
br label %12
10: ; preds = %5, %3
%11 = tail call i32 (i32, i8*, i8*, ...) @irc_printf(i32 %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %12
12: ; preds = %10, %8
%13 = phi i32 [ %9, %8 ], [ %11, %10 ]
ret i32 %13
}