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


x86 assembly (clang, -O0):
<handle_leave>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
jne    113e <handle_leave+0x2e>
xor    %eax,%eax
mov    %eax,-0x20(%rbp)
jmp    1196 <handle_leave+0x86>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    116c <handle_leave+0x5c>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x8(%rbp),%rcx
lea    0xea3(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x24(%rbp)
jmp    1190 <handle_leave+0x80>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
add    $0x1,%r8
lea    0xe84(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_leave>:
cmpb   $0x0,(%rdi)
je     113d <handle_leave+0x2d>
mov    %rsi,%r8
mov    %rdi,%rax
cmpb   $0x0,(%rsi)
je     1140 <handle_leave+0x30>
add    $0x1,%r8
lea    0xedf(%rip),%r9
mov    %rdx,%rdi
mov    %ecx,%esi
mov    %r9,%rdx
mov    %rax,%rcx
xor    %eax,%eax
jmp    1030 <snprintf@plt>
xor    %eax,%eax
ret
lea    0xeb9(%rip),%r8
mov    %rdx,%rdi
mov    %ecx,%esi
mov    %r8,%rdx
mov    %rax,%rcx
xor    %eax,%eax
jmp    1030 <snprintf@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"PART %s\0D\0A\00"
@.str.1 = [14 x i8] c"PART %s :%s\0D\0A\00"
define i32 @handle_leave(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** %5
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %4
br label %31
13: ; preds = %4
%14 = load i8*, i8** %6
%15 = load i8, i8* %14
%16 = icmp ne i8 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %13
%18 = load i8*, i8** %7
%19 = load i32, i32* %8
%20 = load i8*, i8** %5
%21 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %18, i32 %19, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %20)
br label %29
22: ; preds = %13
%23 = load i8*, i8** %7
%24 = load i32, i32* %8
%25 = load i8*, i8** %5
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %23, i32 %24, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %25, i8* %27)
br label %29
29: ; preds = %22, %17
%30 = phi i32 [ %21, %17 ], [ %28, %22 ]
br label %31
31: ; preds = %29, %12
%32 = phi i32 [ 0, %12 ], [ %30, %29 ]
ret i32 %32
}

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