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


x86 assembly (clang, -O0):
<handle_away>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1158 <handle_away+0x48>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rcx
add    $0x1,%rcx
lea    0xeb7(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x18(%rbp)
jmp    1170 <handle_away+0x60>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xea5(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_away>:
cmpb   $0x0,(%rdi)
je     1132 <handle_away+0x22>
mov    %rdi,%rcx
add    $0x1,%rcx
lea    0xedd(%rip),%rax
mov    %rsi,%rdi
mov    %edx,%esi
mov    %rax,%rdx
xor    %eax,%eax
jmp    1030 <snprintf@plt>
lea    0xed2(%rip),%rax
mov    %rsi,%rdi
mov    %edx,%esi
mov    %rax,%rdx
xor    %eax,%eax
jmp    1030 <snprintf@plt>

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

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