#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 */
struct evbuffer {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ evbuffer_add(struct evbuffer *, char *, int);
int strlen(char *);
void irc_cmd_pong(struct evbuffer *out, char *str) {
  evbuffer_add(out, "PONG ", 5);
  if (*str == ':')
    str++;
  evbuffer_add(out, str, strlen(str));
  evbuffer_add(out, "\n", 1);
}


x86 assembly (clang, -O0):
<irc_cmd_pong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec5(%rip),%rsi
mov    $0x5,%edx
call   1040 <evbuffer_add@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    1161 <irc_cmd_pong+0x41>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
call   1040 <evbuffer_add@plt>
mov    -0x8(%rbp),%rdi
lea    0xe72(%rip),%rsi
mov    $0x1,%edx
call   1040 <evbuffer_add@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<irc_cmd_pong>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xece(%rip),%rsi
mov    $0x5,%edx
call   1040 <evbuffer_add@plt>
xor    %ebx,%ebx
cmpb   $0x3a,(%r14)
sete   %bl
add    %r14,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <evbuffer_add@plt>
lea    0xea2(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <evbuffer_add@plt>

LLVM IR (-O0):
%struct.evbuffer = type { i32 }
@.str = [6 x i8] c"PONG \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @irc_cmd_pong(%struct.evbuffer* %0, i8* %1) {
%3 = alloca %struct.evbuffer*
%4 = alloca i8*
store %struct.evbuffer* %0, %struct.evbuffer** %3
store i8* %1, i8** %4
%5 = load %struct.evbuffer*, %struct.evbuffer** %3
%6 = call i32 @evbuffer_add(%struct.evbuffer* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 58
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %4
br label %14
14: ; preds = %11, %2
%15 = load %struct.evbuffer*, %struct.evbuffer** %3
%16 = load i8*, i8** %4
%17 = load i8*, i8** %4
%18 = call i32 @strlen(i8* %17)
%19 = call i32 @evbuffer_add(%struct.evbuffer* %15, i8* %16, i32 %18)
%20 = load %struct.evbuffer*, %struct.evbuffer** %3
%21 = call i32 @evbuffer_add(%struct.evbuffer* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
ret void
}

LLVM IR (-O2):
%struct.evbuffer = type { i32 }
@.str = [6 x i8] c"PONG \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @irc_cmd_pong(%struct.evbuffer* %0, i8* %1) {
%3 = tail call i32 @evbuffer_add(%struct.evbuffer* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 58
%6 = zext i1 %5 to i64
%7 = getelementptr i8, i8* %1, i64 %6
%8 = tail call i32 @strlen(i8* %7)
%9 = tail call i32 @evbuffer_add(%struct.evbuffer* %0, i8* %7, i32 %8)
%10 = tail call i32 @evbuffer_add(%struct.evbuffer* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
ret void
}