#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 guild {
  int dummy;
};

/* Variables and functions */
scalar_t__ guild_check_empty(struct guild const *);
int /*<<< orphan*/ guilddb_sql_delete(int);
struct guild *guilddb_sql_load_num(int);
int /*<<< orphan*/ mapif_guild_info(int, struct guild const *);
int /*<<< orphan*/ mapif_guild_noinfo(int, int);
int mapif_parse_GuildInfo(int fd, int guild_id) {
  const struct guild *g = guilddb_sql_load_num(guild_id);
  if (g == NULL) {
    mapif_guild_noinfo(fd, guild_id);
  } else if (guild_check_empty(g)) {
    guilddb_sql_delete(guild_id);
    mapif_guild_noinfo(fd, guild_id);
    return 0;
  } else {
    mapif_guild_info(fd, g);
  }
  return 0;
}


x86 assembly (clang, -O0):
<mapif_parse_GuildInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <guilddb_sql_load_num@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1185 <mapif_parse_GuildInfo+0x35>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <mapif_guild_noinfo@plt>
jmp    11c8 <mapif_parse_GuildInfo+0x78>
mov    -0x18(%rbp),%rdi
call   1050 <guild_check_empty@plt>
cmp    $0x0,%rax
je     11b7 <mapif_parse_GuildInfo+0x67>
mov    -0xc(%rbp),%edi
call   1070 <guilddb_sql_delete@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <mapif_guild_noinfo@plt>
movl   $0x0,-0x4(%rbp)
jmp    11cf <mapif_parse_GuildInfo+0x7f>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1060 <mapif_guild_info@plt>
jmp    11c8 <mapif_parse_GuildInfo+0x78>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mapif_parse_GuildInfo>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%r14d
mov    %esi,%edi
call   1040 <guilddb_sql_load_num@plt>
test   %rax,%rax
je     117c <mapif_parse_GuildInfo+0x2c>
mov    %rax,%rbp
mov    %rax,%rdi
call   1050 <guild_check_empty@plt>
test   %rax,%rax
je     1188 <mapif_parse_GuildInfo+0x38>
mov    %ebx,%edi
call   1070 <guilddb_sql_delete@plt>
mov    %r14d,%edi
mov    %ebx,%esi
call   1030 <mapif_guild_noinfo@plt>
jmp    1193 <mapif_parse_GuildInfo+0x43>
mov    %r14d,%edi
mov    %rbp,%rsi
call   1060 <mapif_guild_info@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.guild = type { i32 }
define i32 @mapif_parse_GuildInfo(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.guild*
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %5
%8 = call %struct.guild* @guilddb_sql_load_num(i32 %7)
store %struct.guild* %8, %struct.guild** %6
%9 = load %struct.guild*, %struct.guild** %6
%10 = icmp eq %struct.guild* %9, null
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* %4
%13 = load i32, i32* %5
%14 = call i32 @mapif_guild_noinfo(i32 %12, i32 %13)
br label %30
15: ; preds = %2
%16 = load %struct.guild*, %struct.guild** %6
%17 = call i64 @guild_check_empty(%struct.guild* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %15
%20 = load i32, i32* %5
%21 = call i32 @guilddb_sql_delete(i32 %20)
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = call i32 @mapif_guild_noinfo(i32 %22, i32 %23)
store i32 0, i32* %3
br label %31
25: ; preds = %15
%26 = load i32, i32* %4
%27 = load %struct.guild*, %struct.guild** %6
%28 = call i32 @mapif_guild_info(i32 %26, %struct.guild* %27)
br label %29
29: ; preds = %25
br label %30
30: ; preds = %29, %11
store i32 0, i32* %3
br label %31
31: ; preds = %30, %19
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
%struct.guild = type { i32 }
define i32 @mapif_parse_GuildInfo(i32 %0, i32 %1) {
%3 = tail call %struct.guild* @guilddb_sql_load_num(i32 %1)
%4 = icmp eq %struct.guild* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @mapif_guild_noinfo(i32 %0, i32 %1)
br label %15
7: ; preds = %2
%8 = tail call i64 @guild_check_empty(%struct.guild* %3)
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = tail call i32 @guilddb_sql_delete(i32 %1)
%12 = tail call i32 @mapif_guild_noinfo(i32 %0, i32 %1)
br label %15
13: ; preds = %7
%14 = tail call i32 @mapif_guild_info(i32 %0, %struct.guild* %3)
br label %15
15: ; preds = %5, %13, %10
ret i32 0
}