#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*/ gmi_fail(char *);
int /*<<< orphan*/ strcmp(char const *, char const *);
char *strrchr(char const *, char);
int gmi_has_ext(const char *filename, const char *ext) {
  const char *c = strrchr(filename, '.');
  if (!c)
    gmi_fail("model file name with no extension");
  ++c;
  if (!strcmp(c, ext))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<gmi_has_ext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1169 <gmi_has_ext+0x39>
lea    0xe9c(%rip),%rdi
call   1050 <gmi_fail@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1197 <gmi_has_ext+0x67>
movl   $0x1,-0x4(%rbp)
jmp    119e <gmi_has_ext+0x6e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gmi_has_ext>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1155 <gmi_has_ext+0x25>
lea    0xeb0(%rip),%rdi
call   1050 <gmi_fail@plt>
add    $0x1,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [34 x i8] c"model file name with no extension\00"
define i32 @gmi_has_ext(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = call i8* @strrchr(i8* %7, i8 signext 46)
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = icmp ne i8* %9, null
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = call i32 @gmi_fail(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %2
%14 = load i8*, i8** %6
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %6
%16 = load i8*, i8** %6
%17 = load i8*, i8** %5
%18 = call i32 @strcmp(i8* %16, i8* %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %13
store i32 1, i32* %3
br label %22
21: ; preds = %13
store i32 0, i32* %3
br label %22
22: ; preds = %21, %20
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@.str = [34 x i8] c"model file name with no extension\00"
define i32 @gmi_has_ext(i8* %0, i8* nocapture %1) {
%3 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @gmi_fail(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %2
%8 = getelementptr inbounds i8, i8* %3, i64 1
%9 = tail call i32 @strcmp(i8* %8, i8* dereferenceable(1) %1)
%10 = icmp eq i32 %9, 0
%11 = zext i1 %10 to i32
ret i32 %11
}