#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 */
scalar_t__ isalnum(char);
scalar_t__ memcmp(char *, char *, int);
int ntohl(int);
int /*<<< orphan*/ use_config(char *, int);
void parse_config_file(char *map, size_t len) {
  int *end = (int *)(map + len);
  int *m = (int *)map + 1;
  char *p, *q;
  for (; m < end; m++) {
    if (*m == ntohl(0x434f4e46)) {
      p = (char *)m;
      goto conf;
    }
    if (*m == ntohl(0x4f4e4649)) {
      p = (char *)m - 1;
      goto conf;
    }
    if (*m == ntohl(0x4e464947)) {
      p = (char *)m - 2;
      goto conf;
    }
    if (*m == ntohl(0x4649475f)) {
      p = (char *)m - 3;
      goto conf;
    }
    continue;
  conf:
    if (p > map + len - 7)
      continue;
    if (memcmp(p, "CONFIG_", 7))
      continue;
    for (q = p + 7; q < map + len; q++) {
      if (!(isalnum(*q) || *q == '_'))
        goto found;
    }
    continue;
  found:
    if (!memcmp(q - 7, "_MODULE", 7))
      q -= 7;
    use_config(p + 7, q - p - 7);
  }
}


x86 assembly (clang, -O0):
<parse_config_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1342 <parse_config_file+0x202>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    $0x434f4e46,%edi
call   1050 <ntohl@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jne    11a3 <parse_config_file+0x63>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    123b <parse_config_file+0xfb>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    $0x4f4e4649,%edi
call   1050 <ntohl@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cmp    %ecx,%eax
jne    11d4 <parse_config_file+0x94>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
jmp    123b <parse_config_file+0xfb>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    $0x4e464947,%edi
call   1050 <ntohl@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
cmp    %ecx,%eax
jne    1205 <parse_config_file+0xc5>
mov    -0x20(%rbp),%rax
add    $0xfffffffffffffffe,%rax
mov    %rax,-0x28(%rbp)
jmp    123b <parse_config_file+0xfb>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    $0x4649475f,%edi
call   1050 <ntohl@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
cmp    %ecx,%eax
jne    1236 <parse_config_file+0xf6>
mov    -0x20(%rbp),%rax
add    $0xfffffffffffffffd,%rax
mov    %rax,-0x28(%rbp)
jmp    123b <parse_config_file+0xfb>
jmp    1331 <parse_config_file+0x1f1>
mov    -0x28(%rbp),%rax
mov    -0x8(%rbp),%rcx
add    -0x10(%rbp),%rcx
add    $0xfffffffffffffff9,%rcx
cmp    %rcx,%rax
jbe    1259 <parse_config_file+0x119>
jmp    1331 <parse_config_file+0x1f1>
mov    -0x28(%rbp),%rdi
lea    0xd9c(%rip),%rsi
mov    $0x7,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     127d <parse_config_file+0x13d>
jmp    1331 <parse_config_file+0x1f1>
mov    -0x28(%rbp),%rax
add    $0x7,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x8(%rbp),%rcx
add    -0x10(%rbp),%rcx
cmp    %rcx,%rax
jae    12df <parse_config_file+0x19f>
mov    -0x30(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
jne    12c9 <parse_config_file+0x189>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     12c9 <parse_config_file+0x189>
jmp    12e4 <parse_config_file+0x1a4>
jmp    12ce <parse_config_file+0x18e>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1289 <parse_config_file+0x149>
jmp    1331 <parse_config_file+0x1f1>
mov    -0x30(%rbp),%rdi
add    $0xfffffffffffffff9,%rdi
lea    0xd15(%rip),%rsi
mov    $0x7,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
jne    1313 <parse_config_file+0x1d3>
mov    -0x30(%rbp),%rax
add    $0xfffffffffffffff9,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
add    $0x7,%rdi
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
sub    $0x7,%rax
mov    %eax,%esi
call   1060 <use_config@plt>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
jmp    1168 <parse_config_file+0x28>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_config_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x5,%rsi
jl     128c <parse_config_file+0x14c>
mov    %rsi,%r14
mov    %rdi,%rbx
add    %rdi,%r14
add    $0x4,%rbx
mov    $0x434f4e46,%edi
call   1050 <ntohl@plt>
mov    %eax,%r13d
lea    -0x7(%r14),%rax
mov    %rax,0x10(%rsp)
jmp    118d <parse_config_file+0x4d>
nopl   (%rax)
add    $0x4,%rbx
cmp    %r14,%rbx
jae    128c <parse_config_file+0x14c>
mov    (%rbx),%ebp
cmp    %r13d,%ebp
jne    11a0 <parse_config_file+0x60>
mov    %rbx,%rbp
cmp    0x10(%rsp),%rbp
ja     1180 <parse_config_file+0x40>
jmp    1200 <parse_config_file+0xc0>
mov    $0x4f4e4649,%edi
call   1050 <ntohl@plt>
cmp    %eax,%ebp
jne    11c0 <parse_config_file+0x80>
lea    -0x1(%rbx),%rbp
cmp    0x10(%rsp),%rbp
ja     1180 <parse_config_file+0x40>
jmp    1200 <parse_config_file+0xc0>
nopl   0x0(%rax,%rax,1)
mov    $0x4e464947,%edi
call   1050 <ntohl@plt>
cmp    %eax,%ebp
jne    11db <parse_config_file+0x9b>
lea    -0x2(%rbx),%rbp
cmp    0x10(%rsp),%rbp
ja     1180 <parse_config_file+0x40>
jmp    1200 <parse_config_file+0xc0>
mov    $0x4649475f,%edi
call   1050 <ntohl@plt>
cmp    %eax,%ebp
jne    1180 <parse_config_file+0x40>
lea    -0x3(%rbx),%rbp
cmp    0x10(%rsp),%rbp
ja     1180 <parse_config_file+0x40>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rdi
lea    0xdf6(%rip),%rsi
mov    $0x7,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
jne    1180 <parse_config_file+0x40>
lea    0x7(%rbp),%r15
cmp    %r14,%r15
jae    1180 <parse_config_file+0x40>
mov    %r15,%r12
jmp    123d <parse_config_file+0xfd>
nop
add    $0x1,%r12
cmp    %r14,%r12
jae    1180 <parse_config_file+0x40>
movsbl (%r12),%edi
call   1030 <isalnum@plt>
test   %rax,%rax
jne    1230 <parse_config_file+0xf0>
cmpb   $0x5f,(%r12)
je     1230 <parse_config_file+0xf0>
lea    -0x7(%r12),%rdi
mov    %rdi,0x8(%rsp)
lea    0xda4(%rip),%rsi
mov    $0x7,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
mov    0x8(%rsp),%rsi
cmovne %r12d,%esi
sub    %ebp,%esi
add    $0xfffffff9,%esi
mov    %r15,%rdi
call   1060 <use_config@plt>
jmp    1180 <parse_config_file+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"CONFIG_\00"
@.str.1 = [8 x i8] c"_MODULE\00"
define void @parse_config_file(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %3
store i64 %1, i64* %4
%9 = load i8*, i8** %3
%10 = load i64, i64* %4
%11 = getelementptr inbounds i8, i8* %9, i64 %10
%12 = bitcast i8* %11 to i32*
store i32* %12, i32** %5
%13 = load i8*, i8** %3
%14 = bitcast i8* %13 to i32*
%15 = getelementptr inbounds i32, i32* %14, i64 1
store i32* %15, i32** %6
br label %16
16: ; preds = %113, %2
%17 = load i32*, i32** %6
%18 = load i32*, i32** %5
%19 = icmp ult i32* %17, %18
br i1 %19, label %20, label %116
20: ; preds = %16
%21 = load i32*, i32** %6
%22 = load i32, i32* %21
%23 = call i32 @ntohl(i32 1129270854)
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load i32*, i32** %6
%27 = bitcast i32* %26 to i8*
store i8* %27, i8** %7
br label %56
28: ; preds = %20
%29 = load i32*, i32** %6
%30 = load i32, i32* %29
%31 = call i32 @ntohl(i32 1330529865)
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %37
33: ; preds = %28
%34 = load i32*, i32** %6
%35 = bitcast i32* %34 to i8*
%36 = getelementptr inbounds i8, i8* %35, i64 -1
store i8* %36, i8** %7
br label %56
37: ; preds = %28
%38 = load i32*, i32** %6
%39 = load i32, i32* %38
%40 = call i32 @ntohl(i32 1313229127)
%41 = icmp eq i32 %39, %40
br i1 %41, label %42, label %46
42: ; preds = %37
%43 = load i32*, i32** %6
%44 = bitcast i32* %43 to i8*
%45 = getelementptr inbounds i8, i8* %44, i64 -2
store i8* %45, i8** %7
br label %56
46: ; preds = %37
%47 = load i32*, i32** %6
%48 = load i32, i32* %47
%49 = call i32 @ntohl(i32 1179207519)
%50 = icmp eq i32 %48, %49
br i1 %50, label %51, label %55
51: ; preds = %46
%52 = load i32*, i32** %6
%53 = bitcast i32* %52 to i8*
%54 = getelementptr inbounds i8, i8* %53, i64 -3
store i8* %54, i8** %7
br label %56
55: ; preds = %46
br label %113
56: ; preds = %51, %42, %33, %25
%57 = load i8*, i8** %7
%58 = load i8*, i8** %3
%59 = load i64, i64* %4
%60 = getelementptr inbounds i8, i8* %58, i64 %59
%61 = getelementptr inbounds i8, i8* %60, i64 -7
%62 = icmp ugt i8* %57, %61
br i1 %62, label %63, label %64
63: ; preds = %56
br label %113
64: ; preds = %56
%65 = load i8*, i8** %7
%66 = call i64 @memcmp(i8* %65, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%67 = icmp ne i64 %66, 0
br i1 %67, label %68, label %69
68: ; preds = %64
br label %113
69: ; preds = %64
%70 = load i8*, i8** %7
%71 = getelementptr inbounds i8, i8* %70, i64 7
store i8* %71, i8** %8
br label %72
72: ; preds = %90, %69
%73 = load i8*, i8** %8
%74 = load i8*, i8** %3
%75 = load i64, i64* %4
%76 = getelementptr inbounds i8, i8* %74, i64 %75
%77 = icmp ult i8* %73, %76
br i1 %77, label %78, label %93
78: ; preds = %72
%79 = load i8*, i8** %8
%80 = load i8, i8* %79
%81 = call i64 @isalnum(i8 signext %80)
%82 = icmp ne i64 %81, 0
br i1 %82, label %89, label %83
83: ; preds = %78
%84 = load i8*, i8** %8
%85 = load i8, i8* %84
%86 = sext i8 %85 to i32
%87 = icmp eq i32 %86, 95
br i1 %87, label %89, label %88
88: ; preds = %83
br label %94
89: ; preds = %83, %78
br label %90
90: ; preds = %89
%91 = load i8*, i8** %8
%92 = getelementptr inbounds i8, i8* %91, i32 1
store i8* %92, i8** %8
br label %72
93: ; preds = %72
br label %113
94: ; preds = %88
%95 = load i8*, i8** %8
%96 = getelementptr inbounds i8, i8* %95, i64 -7
%97 = call i64 @memcmp(i8* %96, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%98 = icmp ne i64 %97, 0
br i1 %98, label %102, label %99
99: ; preds = %94
%100 = load i8*, i8** %8
%101 = getelementptr inbounds i8, i8* %100, i64 -7
store i8* %101, i8** %8
br label %102
102: ; preds = %99, %94
%103 = load i8*, i8** %7
%104 = getelementptr inbounds i8, i8* %103, i64 7
%105 = load i8*, i8** %8
%106 = load i8*, i8** %7
%107 = ptrtoint i8* %105 to i64
%108 = ptrtoint i8* %106 to i64
%109 = sub i64 %107, %108
%110 = sub nsw i64 %109, 7
%111 = trunc i64 %110 to i32
%112 = call i32 @use_config(i8* %104, i32 %111)
br label %113
113: ; preds = %102, %93, %68, %63, %55
%114 = load i32*, i32** %6
%115 = getelementptr inbounds i32, i32* %114, i32 1
store i32* %115, i32** %6
br label %16
116: ; preds = %16
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"CONFIG_\00"
@.str.1 = [8 x i8] c"_MODULE\00"
define void @parse_config_file(i8* %0, i64 %1) {
%3 = getelementptr inbounds i8, i8* %0, i64 %1
%4 = bitcast i8* %3 to i32*
%5 = icmp sgt i64 %1, 4
br i1 %5, label %6, label %69
6: ; preds = %2
%7 = getelementptr inbounds i8, i8* %0, i64 4
%8 = bitcast i8* %7 to i32*
%9 = tail call i32 @ntohl(i32 1129270854)
%10 = getelementptr inbounds i8, i8* %3, i64 -7
br label %11
11: ; preds = %6, %66
%12 = phi i32* [ %8, %6 ], [ %67, %66 ]
%13 = load i32, i32* %12
%14 = icmp eq i32 %13, %9
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = bitcast i32* %12 to i8*
br label %35
17: ; preds = %11
%18 = tail call i32 @ntohl(i32 1330529865)
%19 = icmp eq i32 %13, %18
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = bitcast i32* %12 to i8*
%22 = getelementptr inbounds i8, i8* %21, i64 -1
br label %35
23: ; preds = %17
%24 = tail call i32 @ntohl(i32 1313229127)
%25 = icmp eq i32 %13, %24
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = bitcast i32* %12 to i8*
%28 = getelementptr inbounds i8, i8* %27, i64 -2
br label %35
29: ; preds = %23
%30 = tail call i32 @ntohl(i32 1179207519)
%31 = icmp eq i32 %13, %30
br i1 %31, label %32, label %66
32: ; preds = %29
%33 = bitcast i32* %12 to i8*
%34 = getelementptr inbounds i8, i8* %33, i64 -3
br label %35
35: ; preds = %32, %26, %20, %15
%36 = phi i8* [ %16, %15 ], [ %22, %20 ], [ %28, %26 ], [ %34, %32 ]
%37 = icmp ugt i8* %36, %10
br i1 %37, label %66, label %38
38: ; preds = %35
%39 = tail call i64 @memcmp(i8* %36, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %66
41: ; preds = %38
%42 = getelementptr inbounds i8, i8* %36, i64 7
%43 = icmp ult i8* %42, %3
br i1 %43, label %44, label %66
44: ; preds = %41, %52
%45 = phi i8* [ %53, %52 ], [ %42, %41 ]
%46 = load i8, i8* %45
%47 = tail call i64 @isalnum(i8 signext %46)
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %44
%50 = load i8, i8* %45
%51 = icmp eq i8 %50, 95
br i1 %51, label %52, label %55
52: ; preds = %44, %49
%53 = getelementptr inbounds i8, i8* %45, i64 1
%54 = icmp ult i8* %53, %3
br i1 %54, label %44, label %66
55: ; preds = %49
%56 = getelementptr inbounds i8, i8* %45, i64 -7
%57 = tail call i64 @memcmp(i8* %56, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%58 = icmp eq i64 %57, 0
%59 = select i1 %58, i8* %56, i8* %45
%60 = ptrtoint i8* %59 to i64
%61 = ptrtoint i8* %36 to i64
%62 = sub i64 %60, %61
%63 = trunc i64 %62 to i32
%64 = add i32 %63, -7
%65 = tail call i32 @use_config(i8* %42, i32 %64)
br label %66
66: ; preds = %52, %41, %38, %35, %29, %55
%67 = getelementptr inbounds i32, i32* %12, i64 1
%68 = icmp ult i32* %67, %4
br i1 %68, label %11, label %69
69: ; preds = %66, %2
ret void
}