#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(scalar_t__);
int /*<<< orphan*/ send_msg(char *, char *);
int /*<<< orphan*/ snprintf(char *, scalar_t__, char *, char const *);
scalar_t__ strlen(char const *);
int send_user(void *room_data, void *user_data, const char *message) {
  char *nm = malloc(strlen(message) + 2);
  snprintf(nm, strlen(message) + 2, "u%s", message);
  send_msg((char *)user_data, nm);
  free(nm);
  return 1;
}


x86 assembly (clang, -O0):
<send_user>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x2,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rsi
add    $0x2,%rsi
mov    -0x18(%rbp),%rcx
lea    0xe5c(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <send_msg@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_user>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdx,%rdi
call   1040 <strlen@plt>
lea    0x2(%rax),%r12
mov    %r12,%rdi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe84(%rip),%rdx
mov    %rax,%rdi
mov    %r12,%rsi
mov    %r15,%rcx
call   1050 <snprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <send_msg@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"u%s\00"
define i32 @send_user(i8* nocapture readnone %0, i8* %1, i8* %2) {
%4 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%5 = add nsw i64 %4, 2
%6 = tail call i8* @malloc(i64 %5)
%7 = tail call i32 @snprintf(i8* %6, i64 %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
%8 = tail call i32 @send_msg(i8* %1, i8* %6)
%9 = tail call i32 @free(i8* %6)
ret i32 1
}