#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 snprintf(char *, int const, char *, char *, ...);
int handle_topic(char *channel, char *params, char *mesg, const int mesg_len) {
  return (*params)
             ? snprintf(mesg, mesg_len, "TOPIC %s :%s\r\n", channel, params + 1)
             : snprintf(mesg, mesg_len, "TOPIC %s\r\n", channel);
}


x86 assembly (clang, -O0):
<handle_topic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1160 <handle_topic+0x50>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
add    $0x1,%r8
lea    0xeaf(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x20(%rbp)
jmp    117c <handle_topic+0x6c>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x8(%rbp),%rcx
lea    0xe9d(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_topic>:
mov    %ecx,%r9d
mov    %rdx,%rax
mov    %rdi,%rcx
cmpb   $0x0,(%rsi)
je     1139 <handle_topic+0x29>
mov    %rsi,%r8
add    $0x1,%r8
lea    0xed4(%rip),%rdx
mov    %rax,%rdi
mov    %r9d,%esi
xor    %eax,%eax
jmp    1030 <snprintf@plt>
lea    0xecf(%rip),%rdx
mov    %rax,%rdi
mov    %r9d,%esi
xor    %eax,%eax
jmp    1030 <snprintf@plt>

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

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