#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 */
typedef int /*<<< orphan*/ regex_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int regcomp(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int regexec(int /*<<< orphan*/ *, char const *, int /*<<< orphan*/,
            int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int has_gz_extension(const char *s) {
  regex_t regex;
  int reti;
  reti = regcomp(&regex, ".gz$", 0);
  if (reti) {
    fprintf(stderr, "\nInternal error: Could not compile regex\n");
    exit(2);
  }
  reti = regexec(&regex, s, 0, 0, 0);
  regfree(&regex);
  return (!reti);
}


x86 assembly (clang, -O0):
<has_gz_extension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
lea    0xe99(%rip),%rsi
xor    %edx,%edx
call   1040 <regcomp@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     119a <has_gz_extension+0x4a>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x2,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1060 <regexec@plt>
mov    %eax,-0x10(%rbp)
lea    -0xc(%rbp),%rdi
call   1030 <regfree@plt>
cmpl   $0x0,-0x10(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<has_gz_extension>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xea2(%rip),%rsi
lea    0x4(%rsp),%rdi
xor    %edx,%edx
call   1040 <regcomp@plt>
test   %eax,%eax
jne    119e <has_gz_extension+0x4e>
lea    0x4(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1060 <regexec@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <regfree@plt>
xor    %eax,%eax
test   %ebx,%ebx
sete   %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
lea    0xe57(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x2,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c".gz$\00"
@stderr = global i32 0
@.str.1 = [42 x i8] c"\0AInternal error: Could not compile regex\0A\00"
define i32 @has_gz_extension(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i32 @regcomp(i32* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 0)
store i32 %5, i32* %4
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @exit(i32 2)
unreachable
12: ; preds = %1
%13 = load i8*, i8** %2
%14 = call i32 @regexec(i32* %3, i8* %13, i32 0, i32 0, i32 0)
store i32 %14, i32* %4
%15 = call i32 @regfree(i32* %3)
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 0
%18 = xor i1 %17, true
%19 = zext i1 %18 to i32
ret i32 %19
}

LLVM IR (-O2):
@.str = [5 x i8] c".gz$\00"
@stderr = global i32 0
@.str.1 = [42 x i8] c"\0AInternal error: Could not compile regex\0A\00"
define i32 @has_gz_extension(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @regcomp(i32* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @exit(i32 2)
unreachable
10: ; preds = %1
%11 = call i32 @regexec(i32* %2, i8* %0, i32 0, i32 0, i32 0)
%12 = call i32 @regfree(i32* %2)
%13 = icmp eq i32 %11, 0
%14 = zext i1 %13 to i32
ret i32 %14
}