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

/* Variables and functions */
int atoi(char const *);
int /*<<< orphan*/ pc_memo(struct map_session_data *, scalar_t__);
atcommand_memo(const int fd, struct map_session_data *sd, const char *command,
               const char *message) {
  int position = 0;
  if (!message || !*message)
    return -1;
  position = atoi(message);
  if (position < 0 || position > 2)
    position = 0;
  pc_memo(sd, position + 0);
  return 0;
}


x86 assembly (clang, -O0):
<atcommand_memo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1156 <atcommand_memo+0x36>
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1162 <atcommand_memo+0x42>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a2 <atcommand_memo+0x82>
mov    -0x20(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     1182 <atcommand_memo+0x62>
cmpl   $0x2,-0x24(%rbp)
jle    1189 <atcommand_memo+0x69>
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    $0x0,%eax
movslq %eax,%rsi
call   1030 <pc_memo@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atcommand_memo>:
push   %r14
push   %rbx
push   %rax
mov    $0xffffffff,%ebx
test   %rcx,%rcx
je     1151 <atcommand_memo+0x31>
cmpb   $0x0,(%rcx)
je     1151 <atcommand_memo+0x31>
mov    %rsi,%r14
mov    %rcx,%rdi
call   1040 <atoi@plt>
xor    %ebx,%ebx
cmp    $0x3,%eax
cmovae %ebx,%eax
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <pc_memo@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.map_session_data = type { i32 }
define i32 @atcommand_memo(i32 %0, %struct.map_session_data* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.map_session_data*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i32 %0, i32* %6
store %struct.map_session_data* %1, %struct.map_session_data** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32 0, i32* %10
%11 = load i8*, i8** %9
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %17
13: ; preds = %4
%14 = load i8*, i8** %9
%15 = load i8, i8* %14
%16 = icmp ne i8 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %13, %4
store i32 -1, i32* %5
br label %33
18: ; preds = %13
%19 = load i8*, i8** %9
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %10
%21 = load i32, i32* %10
%22 = icmp slt i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %18
%24 = load i32, i32* %10
%25 = icmp sgt i32 %24, 2
br i1 %25, label %26, label %27
26: ; preds = %23, %18
store i32 0, i32* %10
br label %27
27: ; preds = %26, %23
%28 = load %struct.map_session_data*, %struct.map_session_data** %7
%29 = load i32, i32* %10
%30 = add nsw i32 %29, 0
%31 = sext i32 %30 to i64
%32 = call i32 @pc_memo(%struct.map_session_data* %28, i64 %31)
store i32 0, i32* %5
br label %33
33: ; preds = %27, %17
%34 = load i32, i32* %5
ret i32 %34
}

LLVM IR (-O2):
%struct.map_session_data = type { i32 }
define i32 @atcommand_memo(i32 %0, %struct.map_session_data* %1, i8* nocapture readnone %2, i8* %3) {
%5 = icmp eq i8* %3, null
br i1 %5, label %15, label %6
6: ; preds = %4
%7 = load i8, i8* %3
%8 = icmp eq i8 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %6
%10 = tail call i32 @atoi(i8* %3)
%11 = icmp ugt i32 %10, 2
%12 = select i1 %11, i32 0, i32 %10
%13 = zext i32 %12 to i64
%14 = tail call i32 @pc_memo(%struct.map_session_data* %1, i64 %13)
br label %15
15: ; preds = %4, %6, %9
%16 = phi i32 [ 0, %9 ], [ -1, %6 ], [ -1, %4 ]
ret i32 %16
}