#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*/ isalnum(char);
scalar_t__ isalpha(char);
scalar_t__ isdigit(char);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int valid_log_name(char *fname) {
  int len = strlen(fname);
  if (len < 18)
    return 0;
  if (strcmp(fname + len - 4, ".log")) {
    return 0;
  }
  if (!isalnum(*fname))
    return 0;
  for (; *fname; fname++) {
    if (isalpha(*fname))
      continue;
    if (isdigit(*fname))
      continue;
    if (*fname == '-')
      continue;
    if (*fname == '_')
      continue;
    if (*fname == '.')
      continue;
  }
  return 1;
}


x86 assembly (clang, -O0):
<valid_log_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x12,-0x14(%rbp)
jge    117e <valid_log_name+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    1274 <valid_log_name+0x124>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe6c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     11af <valid_log_name+0x5f>
movl   $0x0,-0x4(%rbp)
jmp    1274 <valid_log_name+0x124>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isalnum@plt>
cmp    $0x0,%eax
jne    11d0 <valid_log_name+0x80>
movl   $0x0,-0x4(%rbp)
jmp    1274 <valid_log_name+0x124>
jmp    11d5 <valid_log_name+0x85>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     126d <valid_log_name+0x11d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1070 <isalpha@plt>
cmp    $0x0,%rax
je     11fd <valid_log_name+0xad>
jmp    125c <valid_log_name+0x10c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1218 <valid_log_name+0xc8>
jmp    125c <valid_log_name+0x10c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    122d <valid_log_name+0xdd>
jmp    125c <valid_log_name+0x10c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
jne    1242 <valid_log_name+0xf2>
jmp    125c <valid_log_name+0x10c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1257 <valid_log_name+0x107>
jmp    125c <valid_log_name+0x10c>
jmp    125c <valid_log_name+0x10c>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11d5 <valid_log_name+0x85>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valid_log_name>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <strlen@plt>
xor    %ebp,%ebp
cmp    $0x12,%eax
jl     117d <valid_log_name+0x2d>
mov    %eax,%eax
lea    (%rbx,%rax,1),%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe8d(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1186 <valid_log_name+0x36>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
movsbl (%rbx),%edi
call   1050 <isalnum@plt>
test   %eax,%eax
je     117d <valid_log_name+0x2d>
mov    (%rbx),%al
mov    $0x1,%ebp
test   %al,%al
je     117d <valid_log_name+0x2d>
add    $0x1,%rbx
jmp    11bb <valid_log_name+0x6b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     117d <valid_log_name+0x2d>
movsbl %al,%edi
call   1070 <isalpha@plt>
test   %rax,%rax
jne    11b0 <valid_log_name+0x60>
movsbl -0x1(%rbx),%edi
call   1030 <isdigit@plt>
jmp    11b0 <valid_log_name+0x60>

LLVM IR (-O0):
@.str = [5 x i8] c".log\00"
define i32 @valid_log_name(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strlen(i8* %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 18
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 0, i32* %2
br label %65
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = getelementptr inbounds i8, i8* %14, i64 -4
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %10
store i32 0, i32* %2
br label %65
19: ; preds = %10
%20 = load i8*, i8** %3
%21 = load i8, i8* %20
%22 = call i32 @isalnum(i8 signext %21)
%23 = icmp ne i32 %22, 0
br i1 %23, label %25, label %24
24: ; preds = %19
store i32 0, i32* %2
br label %65
25: ; preds = %19
br label %26
26: ; preds = %61, %25
%27 = load i8*, i8** %3
%28 = load i8, i8* %27
%29 = icmp ne i8 %28, 0
br i1 %29, label %30, label %64
30: ; preds = %26
%31 = load i8*, i8** %3
%32 = load i8, i8* %31
%33 = call i64 @isalpha(i8 signext %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %30
br label %61
36: ; preds = %30
%37 = load i8*, i8** %3
%38 = load i8, i8* %37
%39 = call i64 @isdigit(i8 signext %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %36
br label %61
42: ; preds = %36
%43 = load i8*, i8** %3
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 45
br i1 %46, label %47, label %48
47: ; preds = %42
br label %61
48: ; preds = %42
%49 = load i8*, i8** %3
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 95
br i1 %52, label %53, label %54
53: ; preds = %48
br label %61
54: ; preds = %48
%55 = load i8*, i8** %3
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 46
br i1 %58, label %59, label %60
59: ; preds = %54
br label %61
60: ; preds = %54
br label %61
61: ; preds = %60, %59, %53, %47, %41, %35
%62 = load i8*, i8** %3
%63 = getelementptr inbounds i8, i8* %62, i32 1
store i8* %63, i8** %3
br label %26
64: ; preds = %26
store i32 1, i32* %2
br label %65
65: ; preds = %64, %24, %18, %9
%66 = load i32, i32* %2
ret i32 %66
}

LLVM IR (-O2):
@.str = [5 x i8] c".log\00"
define i32 @valid_log_name(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp slt i32 %2, 18
br i1 %3, label %29, label %4
4: ; preds = %1
%5 = zext i32 %2 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = getelementptr inbounds i8, i8* %6, i64 -4
%8 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %29
10: ; preds = %4
%11 = load i8, i8* %0
%12 = tail call i32 @isalnum(i8 signext %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %29, label %14
14: ; preds = %10
%15 = load i8, i8* %0
%16 = icmp eq i8 %15, 0
br i1 %16, label %29, label %17
17: ; preds = %14, %25
%18 = phi i8 [ %27, %25 ], [ %15, %14 ]
%19 = phi i8* [ %26, %25 ], [ %0, %14 ]
%20 = tail call i64 @isalpha(i8 signext %18)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = load i8, i8* %19
%24 = tail call i64 @isdigit(i8 signext %23)
br label %25
25: ; preds = %22, %17
%26 = getelementptr inbounds i8, i8* %19, i64 1
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 0
br i1 %28, label %29, label %17
29: ; preds = %25, %14, %10, %4, %1
%30 = phi i32 [ 0, %1 ], [ 0, %4 ], [ 0, %10 ], [ 1, %14 ], [ 1, %25 ]
ret i32 %30
}