#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 mapif_guild_castle_datasave(int castle_id, int idx, int value) {
  unsigned char buf[16];
  (*(unsigned short *)(((unsigned char *)(buf)) + (0))) = 0x3841;
  (*(unsigned short *)(((unsigned char *)(buf)) + (2))) = castle_id;
  (*(unsigned char *)(((unsigned char *)(buf)) + (4))) = idx;
  (*(unsigned int *)(((unsigned char *)(buf)) + (5))) = value;
  mapif_sendall(buf, 9);
  return 0;
}


x86 assembly (clang, -O0):
<mapif_guild_castle_datasave>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movw   $0x3841,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    %ax,-0x1e(%rbp)
mov    -0x8(%rbp),%eax
mov    %al,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1b(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x9,%esi
call   1030 <mapif_sendall@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mapif_guild_castle_datasave>:
sub    $0x18,%rsp
movw   $0x3841,(%rsp)
mov    %di,0x2(%rsp)
mov    %sil,0x4(%rsp)
mov    %edx,0x5(%rsp)
mov    %rsp,%rdi
mov    $0x9,%esi
call   1030 <mapif_sendall@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @mapif_guild_castle_datasave(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [16 x i8]
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = bitcast i8* %9 to i16*
store i16 14401, i16* %10
%11 = load i32, i32* %4
%12 = trunc i32 %11 to i16
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%14 = getelementptr inbounds i8, i8* %13, i64 2
%15 = bitcast i8* %14 to i16*
store i16 %12, i16* %15
%16 = load i32, i32* %5
%17 = trunc i32 %16 to i8
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%19 = getelementptr inbounds i8, i8* %18, i64 4
store i8 %17, i8* %19
%20 = load i32, i32* %6
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%22 = getelementptr inbounds i8, i8* %21, i64 5
%23 = bitcast i8* %22 to i32*
store i32 %20, i32* %23
%24 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%25 = call i32 @mapif_sendall(i8* %24, i32 9)
ret i32 0
}

LLVM IR (-O2):
define i32 @mapif_guild_castle_datasave(i32 %0, i32 %1, i32 %2) {
%4 = alloca [16 x i8]
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%6 = bitcast [16 x i8]* %4 to i16*
store i16 14401, i16* %6
%7 = trunc i32 %0 to i16
%8 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 2
%9 = bitcast i8* %8 to i16*
store i16 %7, i16* %9
%10 = trunc i32 %1 to i8
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 4
store i8 %10, i8* %11
%12 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 5
%13 = bitcast i8* %12 to i32*
store i32 %2, i32* %13
%14 = call i32 @mapif_sendall(i8* %5, i32 9)
ret i32 0
}