#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 const);
scalar_t__ str_ends_with(char const *, int, char *);
char *strstr(char const *, char *);
int /*<<< orphan*/ use_config(char const *, int);
void parse_config_file(const char *p) {
  const char *q, *r;
  const char *start = p;
  while ((p = strstr(p, "CONFIG_"))) {
    if (p > start && (isalnum(p[-1]) || p[-1] == '_')) {
      p += 7;
      continue;
    }
    p += 7;
    q = p;
    while (isalnum(*q) || *q == '_')
      q++;
    if (str_ends_with(p, q - p, "_MODULE"))
      r = q - 7;
    else
      r = q;
    if (r > p)
      use_config(p, r - p);
    p = q;
  }
}


x86 assembly (clang, -O0):
<parse_config_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
je     128d <parse_config_file+0x14d>
mov    -0x8(%rbp),%rax
cmp    -0x20(%rbp),%rax
jbe    11b9 <parse_config_file+0x79>
mov    -0x8(%rbp),%rax
movsbl -0x1(%rax),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%rax
jne    11a8 <parse_config_file+0x68>
mov    -0x8(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x5f,%eax
jne    11b9 <parse_config_file+0x79>
mov    -0x8(%rbp),%rax
add    $0x7,%rax
mov    %rax,-0x8(%rbp)
jmp    1154 <parse_config_file+0x14>
mov    -0x8(%rbp),%rax
add    $0x7,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalnum@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x21(%rbp)
jne    11fb <parse_config_file+0xbb>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    120b <parse_config_file+0xcb>
jmp    121c <parse_config_file+0xdc>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11cd <parse_config_file+0x8d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
lea    0xdd4(%rip),%rdx
call   1030 <str_ends_with@plt>
cmp    $0x0,%rax
je     1254 <parse_config_file+0x114>
mov    -0x10(%rbp),%rax
add    $0xfffffffffffffff9,%rax
mov    %rax,-0x18(%rbp)
jmp    125c <parse_config_file+0x11c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jbe    1280 <parse_config_file+0x140>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
call   1050 <use_config@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1154 <parse_config_file+0x14>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_config_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xeab(%rip),%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     120b <parse_config_file+0xcb>
mov    %rax,%r13
lea    0xe93(%rip),%r15
lea    0xe94(%rip),%r12
jmp    11a6 <parse_config_file+0x66>
cs nopw 0x0(%rax,%rax,1)
movsbl -0x1(%r13),%edi
call   1040 <isalnum@plt>
test   %rax,%rax
je     1202 <parse_config_file+0xc2>
add    $0x7,%r13
mov    %r13,%rdi
mov    %r15,%rsi
call   1060 <strstr@plt>
mov    %rax,%r13
test   %rax,%rax
je     120b <parse_config_file+0xcb>
cmp    %r14,%r13
ja     1180 <parse_config_file+0x40>
xor    %ebx,%ebx
jmp    11b4 <parse_config_file+0x74>
nop
add    $0x1,%rbx
movsbl 0x7(%r13,%rbx,1),%edi
call   1040 <isalnum@plt>
test   %rax,%rax
jne    11b0 <parse_config_file+0x70>
cmpb   $0x5f,0x7(%r13,%rbx,1)
je     11b0 <parse_config_file+0x70>
lea    0x7(%r13),%rbp
mov    %rbp,%rdi
mov    %ebx,%esi
mov    %r12,%rdx
call   1030 <str_ends_with@plt>
lea    0x7(%rbx),%rsi
test   %rax,%rax
cmovne %rbx,%rsi
add    %rbx,%r13
add    $0x7,%r13
cmp    $0x8,%rsi
jl     1193 <parse_config_file+0x53>
add    $0xfffffff9,%esi
mov    %rbp,%rdi
call   1050 <use_config@plt>
jmp    1193 <parse_config_file+0x53>
cmpb   $0x5f,-0x1(%r13)
je     118f <parse_config_file+0x4f>
jmp    11ab <parse_config_file+0x6b>
add    $0x8,%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) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
store i8* %6, i8** %5
br label %7
7: ; preds = %77, %27, %1
%8 = load i8*, i8** %2
%9 = call i8* @strstr(i8* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %2
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %79
11: ; preds = %7
%12 = load i8*, i8** %2
%13 = load i8*, i8** %5
%14 = icmp ugt i8* %12, %13
br i1 %14, label %15, label %30
15: ; preds = %11
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i64 -1
%18 = load i8, i8* %17
%19 = call i64 @isalnum(i8 signext %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %27, label %21
21: ; preds = %15
%22 = load i8*, i8** %2
%23 = getelementptr inbounds i8, i8* %22, i64 -1
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 95
br i1 %26, label %27, label %30
27: ; preds = %21, %15
%28 = load i8*, i8** %2
%29 = getelementptr inbounds i8, i8* %28, i64 7
store i8* %29, i8** %2
br label %7
30: ; preds = %21, %11
%31 = load i8*, i8** %2
%32 = getelementptr inbounds i8, i8* %31, i64 7
store i8* %32, i8** %2
%33 = load i8*, i8** %2
store i8* %33, i8** %3
br label %34
34: ; preds = %46, %30
%35 = load i8*, i8** %3
%36 = load i8, i8* %35
%37 = call i64 @isalnum(i8 signext %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %44, label %39
39: ; preds = %34
%40 = load i8*, i8** %3
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 95
br label %44
44: ; preds = %39, %34
%45 = phi i1 [ true, %34 ], [ %43, %39 ]
br i1 %45, label %46, label %49
46: ; preds = %44
%47 = load i8*, i8** %3
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %3
br label %34
49: ; preds = %44
%50 = load i8*, i8** %2
%51 = load i8*, i8** %3
%52 = load i8*, i8** %2
%53 = ptrtoint i8* %51 to i64
%54 = ptrtoint i8* %52 to i64
%55 = sub i64 %53, %54
%56 = trunc i64 %55 to i32
%57 = call i64 @str_ends_with(i8* %50, i32 %56, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %49
%60 = load i8*, i8** %3
%61 = getelementptr inbounds i8, i8* %60, i64 -7
store i8* %61, i8** %4
br label %64
62: ; preds = %49
%63 = load i8*, i8** %3
store i8* %63, i8** %4
br label %64
64: ; preds = %62, %59
%65 = load i8*, i8** %4
%66 = load i8*, i8** %2
%67 = icmp ugt i8* %65, %66
br i1 %67, label %68, label %77
68: ; preds = %64
%69 = load i8*, i8** %2
%70 = load i8*, i8** %4
%71 = load i8*, i8** %2
%72 = ptrtoint i8* %70 to i64
%73 = ptrtoint i8* %71 to i64
%74 = sub i64 %72, %73
%75 = trunc i64 %74 to i32
%76 = call i32 @use_config(i8* %69, i32 %75)
br label %77
77: ; preds = %68, %64
%78 = load i8*, i8** %3
store i8* %78, i8** %2
br label %7
79: ; preds = %7
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) {
%2 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %46, label %4
4: ; preds = %1, %18
%5 = phi i8* [ %20, %18 ], [ %2, %1 ]
%6 = icmp ugt i8* %5, %0
br i1 %6, label %8, label %7
7: ; preds = %13, %4
br label %22
8: ; preds = %4
%9 = getelementptr inbounds i8, i8* %5, i64 -1
%10 = load i8, i8* %9
%11 = tail call i64 @isalnum(i8 signext %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i8, i8* %9
%15 = icmp eq i8 %14, 95
br i1 %15, label %16, label %7
16: ; preds = %13, %8
%17 = getelementptr inbounds i8, i8* %5, i64 7
br label %18
18: ; preds = %33, %42, %16
%19 = phi i8* [ %17, %16 ], [ %24, %42 ], [ %24, %33 ]
%20 = tail call i8* @strstr(i8* dereferenceable(1) %19, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i8* %20, null
br i1 %21, label %46, label %4
22: ; preds = %7, %31
%23 = phi i64 [ %32, %31 ], [ 7, %7 ]
%24 = getelementptr inbounds i8, i8* %5, i64 %23
%25 = load i8, i8* %24
%26 = tail call i64 @isalnum(i8 signext %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = load i8, i8* %24
%30 = icmp eq i8 %29, 95
br i1 %30, label %31, label %33
31: ; preds = %22, %28
%32 = add nuw nsw i64 %23, 1
br label %22
33: ; preds = %28
%34 = getelementptr inbounds i8, i8* %5, i64 7
%35 = trunc i64 %23 to i32
%36 = add i32 %35, -7
%37 = tail call i64 @str_ends_with(i8* %34, i32 %36, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
%39 = add nsw i64 %23, -7
%40 = select i1 %38, i64 %23, i64 %39
%41 = icmp sgt i64 %40, 7
br i1 %41, label %42, label %18
42: ; preds = %33
%43 = trunc i64 %40 to i32
%44 = add i32 %43, -7
%45 = tail call i32 @use_config(i8* %34, i32 %44)
br label %18
46: ; preds = %18, %1
ret void
}