#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ create_message(int /*<<< orphan*/ *, char *,
                                  int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ send_message_and_free(int, int /*<<< orphan*/);
int /*<<< orphan*/ strcat(char *, char *);
void send_privmsg(int fd, char *target, char *message) {
  char *buf = (char *)calloc(513, sizeof(char));
  strcat(buf, target);
  strcat(buf, " :");
  strcat(buf, message);
  send_message_and_free(fd, create_message(NULL, "PRIVMSG", 0, buf));
  free(buf);
}


x86 assembly (clang, -O0):
<send_privmsg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x201,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x20(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%edi
lea    0xe4e(%rip),%rsi
xor    %edx,%edx
call   1040 <create_message@plt>
mov    -0x24(%rbp),%edi
mov    %eax,%esi
call   1060 <send_message_and_free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_privmsg>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%rbp
mov    %edi,%r14d
mov    $0x201,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
lea    0xe7c(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <strcat@plt>
lea    0xe65(%rip),%rsi
xor    %edi,%edi
xor    %edx,%edx
mov    %rbx,%rcx
call   1040 <create_message@plt>
mov    %r14d,%edi
mov    %eax,%esi
call   1060 <send_message_and_free@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [3 x i8] c" :\00"
@.str.1 = [8 x i8] c"PRIVMSG\00"
define void @send_privmsg(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = call i64 @calloc(i32 513, i32 1)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %7
%10 = load i8*, i8** %7
%11 = load i8*, i8** %5
%12 = call i32 @strcat(i8* %10, i8* %11)
%13 = load i8*, i8** %7
%14 = call i32 @strcat(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%15 = load i8*, i8** %7
%16 = load i8*, i8** %6
%17 = call i32 @strcat(i8* %15, i8* %16)
%18 = load i32, i32* %4
%19 = load i8*, i8** %7
%20 = call i32 @create_message(i32* null, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 0, i8* %19)
%21 = call i32 @send_message_and_free(i32 %18, i32 %20)
%22 = load i8*, i8** %7
%23 = call i32 @free(i8* %22)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c" :\00"
@.str.1 = [8 x i8] c"PRIVMSG\00"
define void @send_privmsg(i32 %0, i8* %1, i8* %2) {
%4 = tail call i64 @calloc(i32 513, i32 1)
%5 = inttoptr i64 %4 to i8*
%6 = tail call i32 @strcat(i8* %5, i8* %1)
%7 = tail call i32 @strcat(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @strcat(i8* %5, i8* %2)
%9 = tail call i32 @create_message(i32* null, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 0, i8* %5)
%10 = tail call i32 @send_message_and_free(i32 %0, i32 %9)
%11 = tail call i32 @free(i8* %5)
ret void
}