#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 map_mapname2mapid(char *);
scalar_t__ npc_set_mapflag(int, char const *, char const *);
int /*<<< orphan*/ printf(char *, char const *, int);
int sscanf(char const *, char *, char *);
scalar_t__ strlen(char const *);
int npc_parse_mapflag(const char *w1, const char *w2, const char *w3,
                      const char *w4, int lines) {
  int m;
  char mapname[4096];
  if (sscanf(w1, "%4095[^,]", mapname) != 1 || strlen(w1) != strlen(mapname)) {
    printf("bad mapflag declaration : %s line %d\a\n", w3, lines);
    return 0;
  }
  m = map_mapname2mapid(mapname);
  if (m < 0)
    return 0;
  if (npc_set_mapflag(m, w3, w4) < 0) {
    printf("npc_parse_mapflag: mapflag \"%s\" not exist!! line %d\a\n", w3,
           lines);
  }
  return 0;
}


x86 assembly (clang, -O0):
<npc_parse_mapflag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1040,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x1030(%rbp),%rdx
lea    0xe7f(%rip),%rsi
call   1060 <sscanf@plt>
cmp    $0x1,%eax
jne    11be <npc_parse_mapflag+0x6e>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x1038(%rbp)
lea    -0x1030(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x1038(%rbp),%rax
cmp    %rcx,%rax
je     11dd <npc_parse_mapflag+0x8d>
mov    -0x20(%rbp),%rsi
mov    -0x2c(%rbp),%edx
lea    0xe3e(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1236 <npc_parse_mapflag+0xe6>
lea    -0x1030(%rbp),%rdi
call   1030 <map_mapname2mapid@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jge    1202 <npc_parse_mapflag+0xb2>
movl   $0x0,-0x4(%rbp)
jmp    1236 <npc_parse_mapflag+0xe6>
mov    -0x30(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1070 <npc_set_mapflag@plt>
cmp    $0x0,%rax
jge    122f <npc_parse_mapflag+0xdf>
mov    -0x20(%rbp),%rsi
mov    -0x2c(%rbp),%edx
lea    0xe07(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<npc_parse_mapflag>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1000,%rsp
mov    %r8d,%r15d
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rdi,%rbx
lea    0xe8e(%rip),%rsi
mov    %rsp,%rdx
call   1060 <sscanf@plt>
lea    0xe89(%rip),%rbp
cmp    $0x1,%eax
jne    11c3 <npc_parse_mapflag+0x73>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
call   1040 <strlen@plt>
cmp    %rax,%rbx
jne    11c3 <npc_parse_mapflag+0x73>
mov    %rsp,%rdi
call   1030 <map_mapname2mapid@plt>
test   %eax,%eax
js     11d1 <npc_parse_mapflag+0x81>
mov    %eax,%edi
mov    %r12,%rsi
mov    %r14,%rdx
call   1070 <npc_set_mapflag@plt>
test   %rax,%rax
jns    11d1 <npc_parse_mapflag+0x81>
lea    0xe6e(%rip),%rbp
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x1000,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%4095[^,]\00"
@.str.1 = [39 x i8] c"bad mapflag declaration : %s line %d\07\0A\00"
@.str.2 = [54 x i8] c"npc_parse_mapflag: mapflag \22%s\22 not exist!! line %d\07\0A\00"
define i32 @npc_parse_mapflag(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca [4096 x i8]
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i32 %4, i32* %11
%14 = load i8*, i8** %7
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%16 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = icmp ne i32 %16, 1
br i1 %17, label %24, label %18
18: ; preds = %5
%19 = load i8*, i8** %7
%20 = call i64 @strlen(i8* %19)
%21 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%22 = call i64 @strlen(i8* %21)
%23 = icmp ne i64 %20, %22
br i1 %23, label %24, label %28
24: ; preds = %18, %5
%25 = load i8*, i8** %9
%26 = load i32, i32* %11
%27 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* %25, i32 %26)
store i32 0, i32* %6
br label %45
28: ; preds = %18
%29 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%30 = call i32 @map_mapname2mapid(i8* %29)
store i32 %30, i32* %12
%31 = load i32, i32* %12
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %28
store i32 0, i32* %6
br label %45
34: ; preds = %28
%35 = load i32, i32* %12
%36 = load i8*, i8** %9
%37 = load i8*, i8** %10
%38 = call i64 @npc_set_mapflag(i32 %35, i8* %36, i8* %37)
%39 = icmp slt i64 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %34
%41 = load i8*, i8** %9
%42 = load i32, i32* %11
%43 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), i8* %41, i32 %42)
br label %44
44: ; preds = %40, %34
store i32 0, i32* %6
br label %45
45: ; preds = %44, %33, %24
%46 = load i32, i32* %6
ret i32 %46
}

LLVM IR (-O2):
@.str = [10 x i8] c"%4095[^,]\00"
@.str.1 = [39 x i8] c"bad mapflag declaration : %s line %d\07\0A\00"
@.str.2 = [54 x i8] c"npc_parse_mapflag: mapflag \22%s\22 not exist!! line %d\07\0A\00"
define i32 @npc_parse_mapflag(i8* nocapture %0, i8* nocapture readnone %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca [4096 x i8]
%7 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%8 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %20
10: ; preds = %5
%11 = call i64 @strlen(i8* dereferenceable(1) %0)
%12 = call i64 @strlen(i8* %7)
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %20
14: ; preds = %10
%15 = call i32 @map_mapname2mapid(i8* %7)
%16 = icmp slt i32 %15, 0
br i1 %16, label %23, label %17
17: ; preds = %14
%18 = call i64 @npc_set_mapflag(i32 %15, i8* %2, i8* %3)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17, %5, %10
%21 = phi i8* [ getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), %10 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), %17 ]
%22 = call i32 @printf(i8* %21, i8* %2, i32 %4)
br label %23
23: ; preds = %20, %17, %14
ret i32 0
}