#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__ memcmp(char const *, char *, int);
char *strstr(char const *, char *);
int /*<<< orphan*/ use_config(char const *, int);
void parse_config_file(const char *p) {
  const char *q, *r;
  while ((p = strstr(p, "CONFIG_"))) {
    p += 7;
    q = p;
    while (*q && (isalnum(*q) || *q == '_'))
      q++;
    if (memcmp(q - 7, "_MODULE", 7) == 0)
      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    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
je     1255 <parse_config_file+0x115>
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),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     11c7 <parse_config_file+0x87>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x1a(%rbp)
jne    11c1 <parse_config_file+0x81>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
sete   %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11d7 <parse_config_file+0x97>
jmp    11e8 <parse_config_file+0xa8>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    117e <parse_config_file+0x3e>
mov    -0x10(%rbp),%rdi
add    $0xfffffffffffffff9,%rdi
lea    0xe11(%rip),%rsi
mov    $0x7,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
jne    121c <parse_config_file+0xdc>
mov    -0x10(%rbp),%rax
add    $0xfffffffffffffff9,%rax
mov    %rax,-0x18(%rbp)
jmp    1224 <parse_config_file+0xe4>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jbe    1248 <parse_config_file+0x108>
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    114c <parse_config_file+0xc>
add    $0x20,%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
lea    0xeae(%rip),%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     1202 <parse_config_file+0xc2>
mov    %rax,%rbx
lea    0xe96(%rip),%r15
jmp    1183 <parse_config_file+0x43>
nopl   0x0(%rax)
mov    %r13,%rdi
mov    %r15,%rsi
call   1060 <strstr@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1202 <parse_config_file+0xc2>
lea    0x7(%rbx),%r12
mov    0x7(%rbx),%al
mov    $0x7,%r14d
test   %al,%al
jne    11ae <parse_config_file+0x6e>
mov    %r12,%r13
jmp    11c6 <parse_config_file+0x86>
nopl   0x0(%rax)
movzbl 0x1(%rbx,%r14,1),%eax
add    $0x1,%r14
test   %al,%al
je     11c2 <parse_config_file+0x82>
movsbl %al,%edi
call   1030 <isalnum@plt>
test   %rax,%rax
jne    11a0 <parse_config_file+0x60>
cmpb   $0x5f,(%rbx,%r14,1)
je     11a0 <parse_config_file+0x60>
lea    (%rbx,%r14,1),%r13
lea    -0x7(%r14),%rbp
lea    (%rbx,%r14,1),%rdi
add    $0xfffffffffffffff9,%rdi
lea    0xe2f(%rip),%rsi
mov    $0x7,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
cmovne %r14,%rbp
cmp    $0x8,%rbp
jl     1170 <parse_config_file+0x30>
add    $0xfffffff9,%ebp
mov    %r12,%rdi
mov    %ebp,%esi
call   1050 <use_config@plt>
jmp    1170 <parse_config_file+0x30>
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*
store i8* %0, i8** %2
br label %5
5: ; preds = %58, %1
%6 = load i8*, i8** %2
%7 = call i8* @strstr(i8* %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %2
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %60
9: ; preds = %5
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i64 7
store i8* %11, i8** %2
%12 = load i8*, i8** %2
store i8* %12, i8** %3
br label %13
13: ; preds = %32, %9
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %30
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = load i8, i8* %19
%21 = call i64 @isalnum(i8 signext %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %28, label %23
23: ; preds = %18
%24 = load i8*, i8** %3
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 95
br label %28
28: ; preds = %23, %18
%29 = phi i1 [ true, %18 ], [ %27, %23 ]
br label %30
30: ; preds = %28, %13
%31 = phi i1 [ false, %13 ], [ %29, %28 ]
br i1 %31, label %32, label %35
32: ; preds = %30
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %3
br label %13
35: ; preds = %30
%36 = load i8*, i8** %3
%37 = getelementptr inbounds i8, i8* %36, i64 -7
%38 = call i64 @memcmp(i8* %37, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %35
%41 = load i8*, i8** %3
%42 = getelementptr inbounds i8, i8* %41, i64 -7
store i8* %42, i8** %4
br label %45
43: ; preds = %35
%44 = load i8*, i8** %3
store i8* %44, i8** %4
br label %45
45: ; preds = %43, %40
%46 = load i8*, i8** %4
%47 = load i8*, i8** %2
%48 = icmp ugt i8* %46, %47
br i1 %48, label %49, label %58
49: ; preds = %45
%50 = load i8*, i8** %2
%51 = load i8*, i8** %4
%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 i32 @use_config(i8* %50, i32 %56)
br label %58
58: ; preds = %49, %45
%59 = load i8*, i8** %3
store i8* %59, i8** %2
br label %5
60: ; preds = %5
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 %39, label %4
4: ; preds = %1, %36
%5 = phi i8* [ %37, %36 ], [ %2, %1 ]
%6 = getelementptr inbounds i8, i8* %5, i64 7
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %23, label %9
9: ; preds = %4, %18
%10 = phi i8 [ %21, %18 ], [ %7, %4 ]
%11 = phi i8* [ %20, %18 ], [ %6, %4 ]
%12 = phi i64 [ %19, %18 ], [ 7, %4 ]
%13 = tail call i64 @isalnum(i8 signext %10)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = load i8, i8* %11
%17 = icmp eq i8 %16, 95
br i1 %17, label %18, label %23
18: ; preds = %9, %15
%19 = add nuw nsw i64 %12, 1
%20 = getelementptr inbounds i8, i8* %5, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %9
23: ; preds = %15, %18, %4
%24 = phi i64 [ 7, %4 ], [ %19, %18 ], [ %12, %15 ]
%25 = phi i8* [ %6, %4 ], [ %20, %18 ], [ %11, %15 ]
%26 = add nsw i64 %24, -7
%27 = getelementptr inbounds i8, i8* %5, i64 %26
%28 = tail call i64 @memcmp(i8* %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%29 = icmp eq i64 %28, 0
%30 = select i1 %29, i64 %26, i64 %24
%31 = icmp sgt i64 %30, 7
br i1 %31, label %32, label %36
32: ; preds = %23
%33 = trunc i64 %30 to i32
%34 = add i32 %33, -7
%35 = tail call i32 @use_config(i8* %6, i32 %34)
br label %36
36: ; preds = %32, %23
%37 = tail call i8* @strstr(i8* dereferenceable(1) %25, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %4
39: ; preds = %36, %1
ret void
}