#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;
  while ((p = strstr(p, "CONFIG_"))) {
    p += 7;
    q = p;
    while (*q && (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    $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     1259 <parse_config_file+0x119>
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   1040 <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    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
lea    0xe08(%rip),%rdx
call   1030 <str_ends_with@plt>
cmp    $0x0,%rax
je     1220 <parse_config_file+0xe0>
mov    -0x10(%rbp),%rax
add    $0xfffffffffffffff9,%rax
mov    %rax,-0x18(%rbp)
jmp    1228 <parse_config_file+0xe8>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jbe    124c <parse_config_file+0x10c>
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   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
lea    0xeb0(%rip),%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     1205 <parse_config_file+0xc5>
mov    %rax,%r13
lea    0xea0(%rip),%r14
lea    0xe91(%rip),%r15
jmp    1193 <parse_config_file+0x53>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r15,%rsi
call   1060 <strstr@plt>
mov    %rax,%r13
test   %rax,%rax
je     1205 <parse_config_file+0xc5>
lea    0x7(%r13),%r12
mov    0x7(%r13),%al
mov    $0x7,%ebx
test   %al,%al
jne    11be <parse_config_file+0x7e>
mov    %r12,%r13
jmp    11d6 <parse_config_file+0x96>
nopl   0x0(%rax)
movzbl 0x1(%r13,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
je     11d3 <parse_config_file+0x93>
movsbl %al,%edi
call   1040 <isalnum@plt>
test   %rax,%rax
jne    11b0 <parse_config_file+0x70>
cmpb   $0x5f,0x0(%r13,%rbx,1)
je     11b0 <parse_config_file+0x70>
add    %rbx,%r13
lea    -0x7(%rbx),%esi
mov    %r12,%rdi
mov    %r14,%rdx
call   1030 <str_ends_with@plt>
lea    -0x7(%rbx),%rsi
test   %rax,%rax
cmove  %rbx,%rsi
cmp    $0x8,%rsi
jl     1180 <parse_config_file+0x40>
add    $0xfffffff9,%esi
mov    %r12,%rdi
call   1050 <use_config@plt>
jmp    1180 <parse_config_file+0x40>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
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 = %63, %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 %65
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** %2
%37 = load i8*, i8** %3
%38 = load i8*, i8** %2
%39 = ptrtoint i8* %37 to i64
%40 = ptrtoint i8* %38 to i64
%41 = sub i64 %39, %40
%42 = trunc i64 %41 to i32
%43 = call i64 @str_ends_with(i8* %36, i32 %42, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %35
%46 = load i8*, i8** %3
%47 = getelementptr inbounds i8, i8* %46, i64 -7
store i8* %47, i8** %4
br label %50
48: ; preds = %35
%49 = load i8*, i8** %3
store i8* %49, i8** %4
br label %50
50: ; preds = %48, %45
%51 = load i8*, i8** %4
%52 = load i8*, i8** %2
%53 = icmp ugt i8* %51, %52
br i1 %53, label %54, label %63
54: ; preds = %50
%55 = load i8*, i8** %2
%56 = load i8*, i8** %4
%57 = load i8*, i8** %2
%58 = ptrtoint i8* %56 to i64
%59 = ptrtoint i8* %57 to i64
%60 = sub i64 %58, %59
%61 = trunc i64 %60 to i32
%62 = call i32 @use_config(i8* %55, i32 %61)
br label %63
63: ; preds = %54, %50
%64 = load i8*, i8** %3
store i8* %64, i8** %2
br label %5
65: ; 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 %40, label %4
4: ; preds = %1, %37
%5 = phi i8* [ %38, %37 ], [ %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 = trunc i64 %24 to i32
%27 = add i32 %26, -7
%28 = tail call i64 @str_ends_with(i8* %6, i32 %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
%30 = add nsw i64 %24, -7
%31 = select i1 %29, i64 %24, i64 %30
%32 = icmp sgt i64 %31, 7
br i1 %32, label %33, label %37
33: ; preds = %23
%34 = trunc i64 %31 to i32
%35 = add i32 %34, -7
%36 = tail call i32 @use_config(i8* %6, i32 %35)
br label %37
37: ; preds = %33, %23
%38 = tail call i8* @strstr(i8* dereferenceable(1) %25, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%39 = icmp eq i8* %38, null
br i1 %39, label %40, label %4
40: ; preds = %37, %1
ret void
}