#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 */
scalar_t__ strcmp(char *, char *);
char *strrchr(char *, char);
char *check_for_compression(char *name) {
  char *s;
  if (name == NULL)
    return NULL;
  s = strrchr(name, '.');
  if (s == NULL)
    return NULL;
  if (strcmp(s, ".gz") == 0)
    return s;
  if (strcmp(s, ".z") == 0)
    return s;
  if (strcmp(s, ".Z") == 0)
    return s;
  return NULL;
}


x86 assembly (clang, -O0):
<check_for_compression>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1144 <check_for_compression+0x24>
movq   $0x0,-0x8(%rbp)
jmp    11eb <check_for_compression+0xcb>
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    116e <check_for_compression+0x4e>
movq   $0x0,-0x8(%rbp)
jmp    11eb <check_for_compression+0xcb>
mov    -0x18(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1195 <check_for_compression+0x75>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11eb <check_for_compression+0xcb>
mov    -0x18(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11bc <check_for_compression+0x9c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11eb <check_for_compression+0xcb>
mov    -0x18(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11e3 <check_for_compression+0xc3>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11eb <check_for_compression+0xcb>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_for_compression>:
push   %rbx
test   %rdi,%rdi
je     117a <check_for_compression+0x5a>
mov    $0x2e,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     117a <check_for_compression+0x5a>
mov    %rax,%rbx
lea    0xec1(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     117c <check_for_compression+0x5c>
lea    0xeb1(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     117c <check_for_compression+0x5c>
lea    0xea0(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
cmovne %rcx,%rbx
jmp    117c <check_for_compression+0x5c>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c".gz\00"
@.str.1 = [3 x i8] c".z\00"
@.str.2 = [3 x i8] c".Z\00"
define i8* @check_for_compression(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %8
7: ; preds = %1
store i8* null, i8** %2
br label %33
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i8* @strrchr(i8* %9, i8 signext 46)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %8
store i8* null, i8** %2
br label %33
14: ; preds = %8
%15 = load i8*, i8** %4
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = load i8*, i8** %4
store i8* %19, i8** %2
br label %33
20: ; preds = %14
%21 = load i8*, i8** %4
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = load i8*, i8** %4
store i8* %25, i8** %2
br label %33
26: ; preds = %20
%27 = load i8*, i8** %4
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = load i8*, i8** %4
store i8* %31, i8** %2
br label %33
32: ; preds = %26
store i8* null, i8** %2
br label %33
33: ; preds = %32, %30, %24, %18, %13, %7
%34 = load i8*, i8** %2
ret i8* %34
}

LLVM IR (-O2):
@.str = [4 x i8] c".gz\00"
@.str.1 = [3 x i8] c".z\00"
@.str.2 = [3 x i8] c".Z\00"
define i8* @check_for_compression(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = tail call i8* @strrchr(i8* %0, i8 signext 46)
%5 = icmp eq i8* %4, null
br i1 %5, label %16, label %6
6: ; preds = %3
%7 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %6
%10 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
%15 = select i1 %14, i8* %4, i8* null
br label %16
16: ; preds = %12, %9, %6, %3, %1
%17 = phi i8* [ null, %1 ], [ null, %3 ], [ %4, %6 ], [ %4, %9 ], [ %15, %12 ]
ret i8* %17
}