#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 *);
int strlen(char const *);
const char *catExec(const char *path) {
  int strl = strlen(path);
  return (!strcmp(path + strl - 3, ".gz"))    ? "gzip -f"
         : (!strcmp(path + strl - 4, ".bam")) ? "samtools view -bS"
                                              : NULL;
}


x86 assembly (clang, -O0):
<catExec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xeb2(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    116c <catExec+0x4c>
lea    0xea1(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11a4 <catExec+0x84>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe8a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
setne  %dl
xor    $0xff,%dl
xor    %eax,%eax
lea    0xe78(%rip),%rcx
test   $0x1,%dl
cmovne %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<catExec>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <strlen@plt>
movslq %eax,%r14
lea    (%rbx,%r14,1),%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xec2(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1170 <catExec+0x50>
add    %r14,%rbx
add    $0xfffffffffffffffc,%rbx
lea    0xeb7(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
lea    0xea7(%rip),%rcx
cmove  %rcx,%rax
jmp    1177 <catExec+0x57>
lea    0xe8d(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c".gz\00"
@.str.1 = [8 x i8] c"gzip -f\00"
@.str.2 = [5 x i8] c".bam\00"
@.str.3 = [18 x i8] c"samtools view -bS\00"
define i8* @catExec(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @strlen(i8* %4)
store i32 %5, i32* %3
%6 = load i8*, i8** %2
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = getelementptr inbounds i8, i8* %9, i64 -3
%11 = call i32 @strcmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %1
br label %25
14: ; preds = %1
%15 = load i8*, i8** %2
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = getelementptr inbounds i8, i8* %18, i64 -4
%20 = call i32 @strcmp(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp ne i32 %20, 0
%22 = xor i1 %21, true
%23 = zext i1 %22 to i64
%24 = select i1 %22, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* null
br label %25
25: ; preds = %14, %13
%26 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %13 ], [ %24, %14 ]
ret i8* %26
}

LLVM IR (-O2):
@.str = [4 x i8] c".gz\00"
@.str.1 = [8 x i8] c"gzip -f\00"
@.str.2 = [5 x i8] c".bam\00"
@.str.3 = [18 x i8] c"samtools view -bS\00"
define i8* @catExec(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sext i32 %2 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = getelementptr inbounds i8, i8* %4, i64 -3
%6 = tail call i32 @strcmp(i8* %5, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %1
%9 = getelementptr inbounds i8, i8* %4, i64 -4
%10 = tail call i32 @strcmp(i8* %9, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* null
br label %13
13: ; preds = %1, %8
%14 = phi i8* [ %12, %8 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %1 ]
ret i8* %14
}