#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*/ printf(char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, size_t);
int is_fortran_file(char *filename) {
  char *ptr;
  int length;
  int stat_F;
  int stat_f;
  int stat_fh;
  int stat_th;
  int return_value;
  length = strlen(filename);
  ptr = filename + length;
  while (1)
    if (!strncmp(ptr, ".", (size_t)1))
      break;
    else
      ptr--;
  if (0 >= 10)
    (void)printf(" is_fortran_file: ptr is <%s> \n", ptr);
  stat_F = !strcmp(ptr, ".F");
  stat_f = !strcmp(ptr, ".f");
  stat_fh = !strcmp(ptr, ".fh");
  stat_th = !strcmp(ptr, ".th");
  if (stat_F || stat_f || stat_fh || stat_th)
    return_value = 1;
  else
    return_value = 0;
  if (0 >= 10)
    (void)printf("is_fortran_file: return_value is %d\n\n", return_value);
  return return_value;
}


x86 assembly (clang, -O0):
<is_fortran_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe9e(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    117a <is_fortran_file+0x4a>
jmp    118b <is_fortran_file+0x5b>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1157 <is_fortran_file+0x27>
mov    -0x10(%rbp),%rdi
lea    0xe6c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe4f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe32(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe16(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    1233 <is_fortran_file+0x103>
cmpl   $0x0,-0x1c(%rbp)
jne    1233 <is_fortran_file+0x103>
cmpl   $0x0,-0x20(%rbp)
jne    1233 <is_fortran_file+0x103>
cmpl   $0x0,-0x24(%rbp)
je     123f <is_fortran_file+0x10f>
movl   $0x1,-0x28(%rbp)
jmp    1246 <is_fortran_file+0x116>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_fortran_file>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
add    %rax,%rbx
add    $0x1,%rbx
nopl   0x0(%rax,%rax,1)
cmpb   $0x2e,-0x1(%rbx)
lea    -0x1(%rbx),%rbx
jne    1140 <is_fortran_file+0x20>
lea    0xeaf(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
sete   %bpl
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
sete   %r14b
lea    0xe8b(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
sete   %r15b
lea    0xe7a(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
sete   %al
or     %bpl,%r14b
or     %r15b,%al
or     %r14b,%al
movzbl %al,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c".F\00"
@.str.2 = [3 x i8] c".f\00"
@.str.3 = [4 x i8] c".fh\00"
@.str.4 = [4 x i8] c".th\00"
define i32 @is_fortran_file(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sext i32 %2 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 %3
br label %5
5: ; preds = %5, %1
%6 = phi i8* [ %4, %1 ], [ %9, %5 ]
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 46
%9 = getelementptr inbounds i8, i8* %6, i64 -1
br i1 %8, label %10, label %5
10: ; preds = %5
%11 = tail call i32 @strcmp(i8* %6, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
%13 = tail call i32 @strcmp(i8* %6, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
%15 = tail call i32 @strcmp(i8* %6, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
%17 = tail call i32 @strcmp(i8* %6, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
%19 = select i1 %12, i1 true, i1 %14
%20 = select i1 %19, i1 true, i1 %16
%21 = select i1 %20, i1 true, i1 %18
%22 = zext i1 %21 to i32
ret i32 %22
}