#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 */
struct mmo_elemstatus {
  int dummy;
};

/* Variables and functions */
struct mmo_elemstatus *elemdb_sql_load(int);
int /*<<< orphan*/ mapif_elem_info(int, int, int, struct mmo_elemstatus const *,
                                   int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, int, int);
int mapif_load_elem(int fd, int account_id, int char_id, int elem_id) {
  const struct mmo_elemstatus *e = elemdb_sql_load(elem_id);
  if (e != NULL) {
    mapif_elem_info(fd, account_id, char_id, e, 0);
  } else {
    printf("inter elem: data load error %d %d %d\n", account_id, char_id,
           elem_id);
  }
  return 0;
}


x86 assembly (clang, -O0):
<mapif_load_elem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <elemdb_sql_load@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1175 <mapif_load_elem+0x45>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
xor    %r8d,%r8d
call   1050 <mapif_elem_info@plt>
jmp    118a <mapif_load_elem+0x5a>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mapif_load_elem>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%r15d
mov    %ecx,%edi
call   1030 <elemdb_sql_load@plt>
test   %rax,%rax
je     1162 <mapif_load_elem+0x32>
mov    %r15d,%edi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %rax,%rcx
xor    %r8d,%r8d
call   1050 <mapif_elem_info@plt>
jmp    1175 <mapif_load_elem+0x45>
lea    0xe97(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.mmo_elemstatus = type { i32 }
@.str = [38 x i8] c"inter elem: data load error %d %d %d\0A\00"
define i32 @mapif_load_elem(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.mmo_elemstatus*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %8
%11 = call %struct.mmo_elemstatus* @elemdb_sql_load(i32 %10)
store %struct.mmo_elemstatus* %11, %struct.mmo_elemstatus** %9
%12 = load %struct.mmo_elemstatus*, %struct.mmo_elemstatus** %9
%13 = icmp ne %struct.mmo_elemstatus* %12, null
br i1 %13, label %14, label %20
14: ; preds = %4
%15 = load i32, i32* %5
%16 = load i32, i32* %6
%17 = load i32, i32* %7
%18 = load %struct.mmo_elemstatus*, %struct.mmo_elemstatus** %9
%19 = call i32 @mapif_elem_info(i32 %15, i32 %16, i32 %17, %struct.mmo_elemstatus* %18, i32 0)
br label %25
20: ; preds = %4
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = load i32, i32* %8
%24 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %22, i32 %23)
br label %25
25: ; preds = %20, %14
ret i32 0
}

LLVM IR (-O2):
%struct.mmo_elemstatus = type { i32 }
@.str = [38 x i8] c"inter elem: data load error %d %d %d\0A\00"
define i32 @mapif_load_elem(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call %struct.mmo_elemstatus* @elemdb_sql_load(i32 %3)
%6 = icmp eq %struct.mmo_elemstatus* %5, null
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i32 @mapif_elem_info(i32 %0, i32 %1, i32 %2, %struct.mmo_elemstatus* %5, i32 0)
br label %11
9: ; preds = %4
%10 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2, i32 %3)
br label %11
11: ; preds = %9, %7
ret i32 0
}