#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*/ strcmp(char const *, char const *);
int strlen(char const *);
int /*<<< orphan*/ strncmp(char const *, char const *, int);
int file_name_has_suffix(const char *str, const char *suffix) {
  int l = strlen(str), k = strlen(suffix), d = l - k;
  if (d < 0)
    return 0;
  if (!strcmp(str + d, suffix))
    return 1;
  if (d - 3 >= 0 && !strcmp(str + l - 3, ".gz") &&
      !strncmp(str + d - 3, suffix, k))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<file_name_has_suffix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1177 <file_name_has_suffix+0x47>
movl   $0x0,-0x4(%rbp)
jmp    120a <file_name_has_suffix+0xda>
mov    -0x10(%rbp),%rdi
movslq -0x24(%rbp),%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11a0 <file_name_has_suffix+0x70>
movl   $0x1,-0x4(%rbp)
jmp    120a <file_name_has_suffix+0xda>
mov    -0x24(%rbp),%eax
sub    $0x3,%eax
cmp    $0x0,%eax
jl     1203 <file_name_has_suffix+0xd3>
mov    -0x10(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xe3b(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1203 <file_name_has_suffix+0xd3>
mov    -0x10(%rbp),%rdi
movslq -0x24(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffd,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1203 <file_name_has_suffix+0xd3>
movl   $0x1,-0x4(%rbp)
jmp    120a <file_name_has_suffix+0xda>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_name_has_suffix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%rbp
call   1040 <strlen@plt>
mov    %eax,%r14d
mov    %r15,%rdi
call   1040 <strlen@plt>
xor    %r12d,%r12d
mov    %r14d,%r13d
sub    %eax,%r13d
js     11b6 <file_name_has_suffix+0x86>
mov    %eax,0x4(%rsp)
mov    %r13d,%ebx
add    %rbp,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
mov    $0x1,%r12d
test   %eax,%eax
je     11b6 <file_name_has_suffix+0x86>
cmp    $0x3,%r13d
jb     11b3 <file_name_has_suffix+0x83>
movslq %r14d,%rax
lea    (%rax,%rbp,1),%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xe6d(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    11b3 <file_name_has_suffix+0x83>
add    $0xfffffffffffffffd,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    0x4(%rsp),%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11b6 <file_name_has_suffix+0x86>
xor    %r12d,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c".gz\00"
define i32 @file_name_has_suffix(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @strlen(i8* %1)
%5 = sub nsw i32 %3, %4
%6 = icmp slt i32 %5, 0
br i1 %6, label %25, label %7
7: ; preds = %2
%8 = zext i32 %5 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(1) %1)
%11 = icmp eq i32 %10, 0
br i1 %11, label %25, label %12
12: ; preds = %7
%13 = icmp ugt i32 %5, 2
br i1 %13, label %14, label %24
14: ; preds = %12
%15 = sext i32 %3 to i64
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = getelementptr inbounds i8, i8* %16, i64 -3
%18 = tail call i32 @strcmp(i8* %17, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %14
%21 = getelementptr inbounds i8, i8* %9, i64 -3
%22 = tail call i32 @strncmp(i8* %21, i8* %1, i32 %4)
%23 = icmp eq i32 %22, 0
br i1 %23, label %25, label %24
24: ; preds = %20, %14, %12
br label %25
25: ; preds = %20, %7, %2, %24
%26 = phi i32 [ 0, %24 ], [ 0, %2 ], [ 1, %7 ], [ 1, %20 ]
ret i32 %26
}