#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*/ mapif_sendall(unsigned char *, int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int mapif_GMmessage(unsigned char *mes, int len) {
  unsigned char buf[len];
  (*(unsigned short *)(((unsigned char *)((buf))) + ((0)))) = 0x3800;
  (*(unsigned short *)(((unsigned char *)((buf))) + ((2)))) = len;
  memcpy((((unsigned char *)(buf)) + (4)), mes, len - 4);
  mapif_sendall(buf, len);
  return 0;
}


x86 assembly (clang, -O0):
<mapif_GMmessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x28(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
movw   $0x3800,(%rdi)
mov    -0xc(%rbp),%eax
mov    %ax,0x2(%rdi)
add    $0x4,%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
sub    $0x4,%edx
call   1040 <memcpy@plt>
mov    -0x28(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <mapif_sendall@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mapif_GMmessage>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rsi
mov    %r14d,%eax
mov    %rsp,%rcx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rcx,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
neg    %rax
movw   $0x3800,(%rcx,%rax,1)
mov    %r14w,0x2(%rbx)
lea    0x4(%rbx),%rdi
lea    -0x4(%r14),%edx
call   1040 <memcpy@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <mapif_sendall@plt>
xor    %eax,%eax
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @mapif_GMmessage(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %5
%10 = alloca i8, i64 %8
store i64 %8, i64* %6
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = bitcast i8* %11 to i16*
store i16 14336, i16* %12
%13 = load i32, i32* %4
%14 = trunc i32 %13 to i16
%15 = getelementptr inbounds i8, i8* %10, i64 2
%16 = bitcast i8* %15 to i16*
store i16 %14, i16* %16
%17 = getelementptr inbounds i8, i8* %10, i64 4
%18 = load i8*, i8** %3
%19 = load i32, i32* %4
%20 = sub nsw i32 %19, 4
%21 = call i32 @memcpy(i8* %17, i8* %18, i32 %20)
%22 = load i32, i32* %4
%23 = call i32 @mapif_sendall(i8* %10, i32 %22)
%24 = load i8*, i8** %5
ret i32 0
}

LLVM IR (-O2):
define i32 @mapif_GMmessage(i8* %0, i32 %1) {
%3 = zext i32 %1 to i64
%4 = alloca i8, i64 %3
%5 = bitcast i8* %4 to i16*
store i16 14336, i16* %5
%6 = trunc i32 %1 to i16
%7 = getelementptr inbounds i8, i8* %4, i64 2
%8 = bitcast i8* %7 to i16*
store i16 %6, i16* %8
%9 = getelementptr inbounds i8, i8* %4, i64 4
%10 = add nsw i32 %1, -4
%11 = call i32 @memcpy(i8* %9, i8* %0, i32 %10)
%12 = call i32 @mapif_sendall(i8* %4, i32 %1)
ret i32 0
}