#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 is_tex_file(char *filename) {
  char *ptr;
  int length;
  int return_value;
  length = strlen(filename);
  if (length < 5)
    ptr = filename;
  else
    ptr = filename + length - 4;
  if (0 >= 10)
    (void)printf(".... is_tex_file .... \nfilename: <%s>\nptr     : <%s>\n",
                 filename, ptr);
  if (length > 4 && !strcmp(ptr, ".tex"))
    return_value = 1;
  else
    return_value = 0;
  if (0 >= 10)
    (void)printf("is_tex_file: return_value is %d\n\n", return_value);
  return return_value;
}


x86 assembly (clang, -O0):
<is_tex_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    114f <is_tex_file+0x2f>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1162 <is_tex_file+0x42>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x4,-0x14(%rbp)
jle    1191 <is_tex_file+0x71>
mov    -0x10(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1191 <is_tex_file+0x71>
movl   $0x1,-0x18(%rbp)
jmp    1198 <is_tex_file+0x78>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_tex_file>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x5,%eax
jl     1148 <is_tex_file+0x28>
mov    %eax,%eax
lea    (%rbx,%rax,1),%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xec1(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     114c <is_tex_file+0x2c>
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c".tex\00"
define i32 @is_tex_file(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 4
br i1 %3, label %4, label %10
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 i32 @strcmp(i8* dereferenceable(1) %7, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %4, %1
br label %11
11: ; preds = %4, %10
%12 = phi i32 [ 0, %10 ], [ 1, %4 ]
ret i32 %12
}