#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 /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
char *to_str(int);
void send_last_packet(int socket, int event) {
  char *packet = malloc(10);
  strcpy(packet, to_str(4));
  strcat(packet, " ");
  strcat(packet, to_str(event));
  send(socket, packet, strlen(packet), 0);
  free(packet);
}


x86 assembly (clang, -O0):
<send_last_packet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0xa,%edi
call   1080 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x4,%edi
call   1050 <to_str@plt>
mov    -0x30(%rbp),%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1090 <strcat@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <to_str@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rsi
call   1090 <strcat@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_last_packet>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %edi,%r14d
mov    $0xa,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    $0x4,%edi
call   1050 <to_str@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
lea    0xe5e(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcat@plt>
mov    %ebp,%edi
call   1050 <to_str@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1090 <strcat@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
define void @send_last_packet(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = call i8* @malloc(i32 10)
store i8* %6, i8** %5
%7 = load i8*, i8** %5
%8 = call i8* @to_str(i32 4)
%9 = call i32 @strcpy(i8* %7, i8* %8)
%10 = load i8*, i8** %5
%11 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = load i8*, i8** %5
%13 = load i32, i32* %4
%14 = call i8* @to_str(i32 %13)
%15 = call i32 @strcat(i8* %12, i8* %14)
%16 = load i32, i32* %3
%17 = load i8*, i8** %5
%18 = load i8*, i8** %5
%19 = call i32 @strlen(i8* %18)
%20 = call i32 @send(i32 %16, i8* %17, i32 %19, i32 0)
%21 = load i8*, i8** %5
%22 = call i32 @free(i8* %21)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define void @send_last_packet(i32 %0, i32 %1) {
%3 = tail call dereferenceable_or_null(10) i8* @malloc(i32 10)
%4 = tail call i8* @to_str(i32 4)
%5 = tail call i32 @strcpy(i8* %3, i8* %4)
%6 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = tail call i8* @to_str(i32 %1)
%8 = tail call i32 @strcat(i8* %3, i8* %7)
%9 = tail call i32 @strlen(i8* %3)
%10 = tail call i32 @send(i32 %0, i8* %3, i32 %9, i32 0)
%11 = tail call i32 @free(i8* %3)
ret void
}