#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 */
char *extonly(char *);
scalar_t__ strcmp(char *, char *);
scalar_t__ stricmp(char *, char *);
int chkext(char *nam) {
  char *p;
  if (strcmp(nam, ".") == 0)
    return 0;
  if (strcmp(nam, "..") == 0)
    return 0;
  p = extonly(nam);
  if (stricmp(p, "com") == 0)
    return 0;
  if (stricmp(p, "dll") == 0)
    return 0;
  if (stricmp(p, "obj") == 0)
    return 0;
  if (stricmp(p, "exe") == 0)
    return 0;
  if (stricmp(p, "rel") == 0)
    return 0;
  if (stricmp(p, "lzh") == 0)
    return 0;
  if (stricmp(p, "zip") == 0)
    return 0;
  if (stricmp(p, "arc") == 0)
    return 0;
  else
    return (1);
}


x86 assembly (clang, -O0):
<chkext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeba(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1162 <chkext+0x32>
movl   $0x0,-0x4(%rbp)
jmp    12cc <chkext+0x19c>
mov    -0x10(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1188 <chkext+0x58>
movl   $0x0,-0x4(%rbp)
jmp    12cc <chkext+0x19c>
mov    -0x10(%rbp),%rdi
call   1030 <extonly@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1040 <stricmp@plt>
cmp    $0x0,%rax
jne    11bb <chkext+0x8b>
movl   $0x0,-0x4(%rbp)
jmp    12cc <chkext+0x19c>
mov    -0x18(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1040 <stricmp@plt>
cmp    $0x0,%rax
jne    11e1 <chkext+0xb1>
movl   $0x0,-0x4(%rbp)
jmp    12cc <chkext+0x19c>
mov    -0x18(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1040 <stricmp@plt>
cmp    $0x0,%rax
jne    1207 <chkext+0xd7>
movl   $0x0,-0x4(%rbp)
jmp    12cc <chkext+0x19c>
mov    -0x18(%rbp),%rdi
lea    0xdfd(%rip),%rsi
call   1040 <stricmp@plt>
cmp    $0x0,%rax
jne    122d <chkext+0xfd>
movl   $0x0,-0x4(%rbp)
jmp    12cc <chkext+0x19c>
mov    -0x18(%rbp),%rdi
lea    0xddb(%rip),%rsi
call   1040 <stricmp@plt>
cmp    $0x0,%rax
jne    1253 <chkext+0x123>
movl   $0x0,-0x4(%rbp)
jmp    12cc <chkext+0x19c>
mov    -0x18(%rbp),%rdi
lea    0xdb9(%rip),%rsi
call   1040 <stricmp@plt>
cmp    $0x0,%rax
jne    1279 <chkext+0x149>
movl   $0x0,-0x4(%rbp)
jmp    12cc <chkext+0x19c>
mov    -0x18(%rbp),%rdi
lea    0xd97(%rip),%rsi
call   1040 <stricmp@plt>
cmp    $0x0,%rax
jne    129f <chkext+0x16f>
movl   $0x0,-0x4(%rbp)
jmp    12cc <chkext+0x19c>
mov    -0x18(%rbp),%rdi
lea    0xd75(%rip),%rsi
call   1040 <stricmp@plt>
cmp    $0x0,%rax
jne    12c5 <chkext+0x195>
movl   $0x0,-0x4(%rbp)
jmp    12cc <chkext+0x19c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chkext>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xec4(%rip),%rsi
call   1050 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1218 <chkext+0xe8>
lea    0xeac(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1218 <chkext+0xe8>
mov    %rbx,%rdi
call   1030 <extonly@plt>
mov    %rax,%rbx
lea    0xe8c(%rip),%rsi
mov    %rax,%rdi
call   1040 <stricmp@plt>
test   %rax,%rax
je     1218 <chkext+0xe8>
lea    0xe78(%rip),%rsi
mov    %rbx,%rdi
call   1040 <stricmp@plt>
test   %rax,%rax
je     1218 <chkext+0xe8>
lea    0xe68(%rip),%rsi
mov    %rbx,%rdi
call   1040 <stricmp@plt>
test   %rax,%rax
je     1218 <chkext+0xe8>
lea    0xe58(%rip),%rsi
mov    %rbx,%rdi
call   1040 <stricmp@plt>
test   %rax,%rax
je     1218 <chkext+0xe8>
lea    0xe48(%rip),%rsi
mov    %rbx,%rdi
call   1040 <stricmp@plt>
test   %rax,%rax
je     1218 <chkext+0xe8>
lea    0xe38(%rip),%rsi
mov    %rbx,%rdi
call   1040 <stricmp@plt>
test   %rax,%rax
je     1218 <chkext+0xe8>
lea    0xe28(%rip),%rsi
mov    %rbx,%rdi
call   1040 <stricmp@plt>
test   %rax,%rax
je     1218 <chkext+0xe8>
lea    0xe18(%rip),%rsi
mov    %rbx,%rdi
call   1040 <stricmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
@.str.1 = [3 x i8] c"..\00"
@.str.2 = [4 x i8] c"com\00"
@.str.3 = [4 x i8] c"dll\00"
@.str.4 = [4 x i8] c"obj\00"
@.str.5 = [4 x i8] c"exe\00"
@.str.6 = [4 x i8] c"rel\00"
@.str.7 = [4 x i8] c"lzh\00"
@.str.8 = [4 x i8] c"zip\00"
@.str.9 = [4 x i8] c"arc\00"
define i32 @chkext(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 0, i32* %2
br label %57
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %9
store i32 0, i32* %2
br label %57
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = call i8* @extonly(i8* %15)
store i8* %16, i8** %4
%17 = load i8*, i8** %4
%18 = call i64 @stricmp(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %14
store i32 0, i32* %2
br label %57
21: ; preds = %14
%22 = load i8*, i8** %4
%23 = call i64 @stricmp(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %21
store i32 0, i32* %2
br label %57
26: ; preds = %21
%27 = load i8*, i8** %4
%28 = call i64 @stricmp(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26
store i32 0, i32* %2
br label %57
31: ; preds = %26
%32 = load i8*, i8** %4
%33 = call i64 @stricmp(i8* %32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %31
store i32 0, i32* %2
br label %57
36: ; preds = %31
%37 = load i8*, i8** %4
%38 = call i64 @stricmp(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %36
store i32 0, i32* %2
br label %57
41: ; preds = %36
%42 = load i8*, i8** %4
%43 = call i64 @stricmp(i8* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %41
store i32 0, i32* %2
br label %57
46: ; preds = %41
%47 = load i8*, i8** %4
%48 = call i64 @stricmp(i8* %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %46
store i32 0, i32* %2
br label %57
51: ; preds = %46
%52 = load i8*, i8** %4
%53 = call i64 @stricmp(i8* %52, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %56
55: ; preds = %51
store i32 0, i32* %2
br label %57
56: ; preds = %51
store i32 1, i32* %2
br label %57
57: ; preds = %56, %55, %50, %45, %40, %35, %30, %25, %20, %13, %8
%58 = load i32, i32* %2
ret i32 %58
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
@.str.1 = [3 x i8] c"..\00"
@.str.2 = [4 x i8] c"com\00"
@.str.3 = [4 x i8] c"dll\00"
@.str.4 = [4 x i8] c"obj\00"
@.str.5 = [4 x i8] c"exe\00"
@.str.6 = [4 x i8] c"rel\00"
@.str.7 = [4 x i8] c"lzh\00"
@.str.8 = [4 x i8] c"zip\00"
@.str.9 = [4 x i8] c"arc\00"
define i32 @chkext(i8* %0) {
%2 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %33, label %4
4: ; preds = %1
%5 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %33, label %7
7: ; preds = %4
%8 = tail call i8* @extonly(i8* %0)
%9 = tail call i64 @stricmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %33, label %11
11: ; preds = %7
%12 = tail call i64 @stricmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %33, label %14
14: ; preds = %11
%15 = tail call i64 @stricmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %33, label %17
17: ; preds = %14
%18 = tail call i64 @stricmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %33, label %20
20: ; preds = %17
%21 = tail call i64 @stricmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %33, label %23
23: ; preds = %20
%24 = tail call i64 @stricmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %33, label %26
26: ; preds = %23
%27 = tail call i64 @stricmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %33, label %29
29: ; preds = %26
%30 = tail call i64 @stricmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%31 = icmp ne i64 %30, 0
%32 = zext i1 %31 to i32
br label %33
33: ; preds = %29, %26, %23, %20, %17, %14, %11, %7, %4, %1
%34 = phi i32 [ 0, %1 ], [ 0, %4 ], [ 0, %7 ], [ 0, %11 ], [ 0, %14 ], [ 0, %17 ], [ 0, %20 ], [ 0, %23 ], [ 0, %26 ], [ %32, %29 ]
ret i32 %34
}