#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 /*<<< orphan*/ str_tolower(char *);
scalar_t__ strcmp(int /*<<< orphan*/, char *);
char *strtok(char *, char *);
int IsConfExt(char filename[]) {
  char *pch = NULL;
  int i = 0, valid = 0;
  pch = strtok(filename, ".");
  while (pch != NULL) {
    if (i == 1 && strcmp(str_tolower(pch), "conf") == 0)
      valid = 1;
    else if (i == 2)
      valid = 0;
    pch = strtok(NULL, ".");
    i++;
  }
  return valid;
}


x86 assembly (clang, -O0):
<IsConfExt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11e0 <IsConfExt+0xb0>
cmpl   $0x1,-0x14(%rbp)
jne    11a8 <IsConfExt+0x78>
mov    -0x10(%rbp),%rdi
call   1050 <str_tolower@plt>
mov    %eax,%edi
lea    0xe75(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11a8 <IsConfExt+0x78>
movl   $0x1,-0x18(%rbp)
jmp    11be <IsConfExt+0x8e>
cmpl   $0x2,-0x14(%rbp)
jne    11b9 <IsConfExt+0x89>
movl   $0x0,-0x18(%rbp)
jmp    11be <IsConfExt+0x8e>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe37(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1166 <IsConfExt+0x36>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IsConfExt>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xec1(%rip),%rsi
call   1040 <strtok@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     11a9 <IsConfExt+0x79>
lea    0xeae(%rip),%r14
lea    0xea9(%rip),%r15
mov    $0x1,%r12d
xor    %ebp,%ebp
jmp    1184 <IsConfExt+0x54>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %ebx,%ebx
xor    %edi,%edi
mov    %r14,%rsi
call   1040 <strtok@plt>
add    $0x1,%ebp
test   %rax,%rax
je     11a9 <IsConfExt+0x79>
cmp    $0x2,%ebp
je     1170 <IsConfExt+0x40>
cmp    $0x1,%ebp
jne    1172 <IsConfExt+0x42>
mov    %rax,%rdi
call   1050 <str_tolower@plt>
mov    %eax,%edi
mov    %r15,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
cmove  %r12d,%ebx
jmp    1172 <IsConfExt+0x42>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
@.str.1 = [5 x i8] c"conf\00"
define i32 @IsConfExt(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
store i8* null, i8** %3
store i32 0, i32* %4
store i32 0, i32* %5
%6 = load i8*, i8** %2
%7 = call i8* @strtok(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %3
br label %8
8: ; preds = %25, %1
%9 = load i8*, i8** %3
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %29
11: ; preds = %8
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = load i8*, i8** %3
%16 = call i32 @str_tolower(i8* %15)
%17 = call i64 @strcmp(i32 %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 1, i32* %5
br label %25
20: ; preds = %14, %11
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 2
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 0, i32* %5
br label %24
24: ; preds = %23, %20
br label %25
25: ; preds = %24, %19
%26 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %26, i8** %3
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %8
29: ; preds = %8
%30 = load i32, i32* %5
ret i32 %30
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
@.str.1 = [5 x i8] c"conf\00"
define i32 @IsConfExt(i8* %0) {
%2 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %19, label %4
4: ; preds = %1, %14
%5 = phi i32 [ %15, %14 ], [ 0, %1 ]
%6 = phi i32 [ %17, %14 ], [ 0, %1 ]
%7 = phi i8* [ %16, %14 ], [ %2, %1 ]
switch i32 %6, label %14 [
i32 1, label %8
i32 2, label %13
]
8: ; preds = %4
%9 = tail call i32 @str_tolower(i8* %7)
%10 = tail call i64 @strcmp(i32 %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, i32 1, i32 %5
br label %14
13: ; preds = %4
br label %14
14: ; preds = %8, %4, %13
%15 = phi i32 [ 0, %13 ], [ %5, %4 ], [ %12, %8 ]
%16 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = add nuw nsw i32 %6, 1
%18 = icmp eq i8* %16, null
br i1 %18, label %19, label %4
19: ; preds = %14, %1
%20 = phi i32 [ 0, %1 ], [ %15, %14 ]
ret i32 %20
}