#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__ FILENAME_CMP(char *, char *);
unsigned int strlen(char *);
char *xstrdup(char *);
char *strip_info_suffix(char *fname) {
  char *ret = xstrdup(fname);
  unsigned len = strlen(ret);
  if (len > 3 && FILENAME_CMP(ret + len - 3, ".gz") == 0) {
    len -= 3;
    ret[len] = 0;
  } else if (len > 4 && FILENAME_CMP(ret + len - 4, ".bz2") == 0) {
    len -= 4;
    ret[len] = 0;
  }
  if (len > 5 && FILENAME_CMP(ret + len - 5, ".info") == 0) {
    len -= 5;
    ret[len] = 0;
  } else if (len > 4 && FILENAME_CMP(ret + len - 4, ".inf") == 0) {
    len -= 4;
    ret[len] = 0;
  }
  return ret;
}


x86 assembly (clang, -O0):
<strip_info_suffix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <xstrdup@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jbe    119c <strip_info_suffix+0x6c>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    %rax,%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xe8c(%rip),%rsi
call   1050 <FILENAME_CMP@plt>
cmp    $0x0,%rax
jne    119c <strip_info_suffix+0x6c>
mov    -0x14(%rbp),%eax
sub    $0x3,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movb   $0x0,(%rax,%rcx,1)
jmp    11e3 <strip_info_suffix+0xb3>
cmpl   $0x4,-0x14(%rbp)
jbe    11de <strip_info_suffix+0xae>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    %rax,%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe49(%rip),%rsi
call   1050 <FILENAME_CMP@plt>
cmp    $0x0,%rax
jne    11de <strip_info_suffix+0xae>
mov    -0x14(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movb   $0x0,(%rax,%rcx,1)
jmp    11e3 <strip_info_suffix+0xb3>
cmpl   $0x5,-0x14(%rbp)
jbe    122a <strip_info_suffix+0xfa>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    %rax,%rdi
add    $0xfffffffffffffffb,%rdi
lea    0xe07(%rip),%rsi
call   1050 <FILENAME_CMP@plt>
cmp    $0x0,%rax
jne    122a <strip_info_suffix+0xfa>
mov    -0x14(%rbp),%eax
sub    $0x5,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movb   $0x0,(%rax,%rcx,1)
jmp    1271 <strip_info_suffix+0x141>
cmpl   $0x4,-0x14(%rbp)
jbe    126c <strip_info_suffix+0x13c>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    %rax,%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xdc6(%rip),%rsi
call   1050 <FILENAME_CMP@plt>
cmp    $0x0,%rax
jne    126c <strip_info_suffix+0x13c>
mov    -0x14(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movb   $0x0,(%rax,%rcx,1)
jmp    1271 <strip_info_suffix+0x141>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strip_info_suffix>:
push   %r15
push   %r14
push   %rbx
call   1040 <xstrdup@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1030 <strlen@plt>
cmp    $0x4,%eax
jb     11f5 <strip_info_suffix+0xc5>
mov    %eax,%ebx
mov    %eax,%r15d
lea    (%r14,%r15,1),%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xe9e(%rip),%rsi
call   1050 <FILENAME_CMP@plt>
test   %rax,%rax
je     1197 <strip_info_suffix+0x67>
cmp    $0x5,%ebx
jb     11f5 <strip_info_suffix+0xc5>
add    %r14,%r15
add    $0xfffffffffffffffc,%r15
lea    0xe81(%rip),%rsi
mov    %r15,%rdi
call   1050 <FILENAME_CMP@plt>
test   %rax,%rax
jne    11a3 <strip_info_suffix+0x73>
mov    $0xfffffffc,%eax
jmp    119c <strip_info_suffix+0x6c>
mov    $0xfffffffd,%eax
add    %eax,%ebx
movb   $0x0,(%r14,%rbx,1)
mov    %ebx,%r15d
cmp    $0x6,%ebx
jb     11cb <strip_info_suffix+0x9b>
lea    (%r14,%r15,1),%rdi
add    $0xfffffffffffffffb,%rdi
lea    0xe4f(%rip),%rsi
call   1050 <FILENAME_CMP@plt>
test   %rax,%rax
jne    11d0 <strip_info_suffix+0xa0>
mov    $0xfffffffb,%eax
jmp    11ee <strip_info_suffix+0xbe>
cmp    $0x5,%ebx
jne    11f5 <strip_info_suffix+0xc5>
lea    (%r14,%r15,1),%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe30(%rip),%rsi
call   1050 <FILENAME_CMP@plt>
test   %rax,%rax
jne    11f5 <strip_info_suffix+0xc5>
mov    $0xfffffffc,%eax
add    %eax,%ebx
movb   $0x0,(%r14,%rbx,1)
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c".gz\00"
@.str.1 = [5 x i8] c".bz2\00"
@.str.2 = [6 x i8] c".info\00"
@.str.3 = [5 x i8] c".inf\00"
define i8* @strip_info_suffix(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @xstrdup(i8* %5)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = icmp ugt i32 %9, 3
br i1 %10, label %11, label %26
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = load i32, i32* %4
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = getelementptr inbounds i8, i8* %15, i64 -3
%17 = call i64 @FILENAME_CMP(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %11
%20 = load i32, i32* %4
%21 = sub i32 %20, 3
store i32 %21, i32* %4
%22 = load i8*, i8** %3
%23 = load i32, i32* %4
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8 0, i8* %25
br label %45
26: ; preds = %11, %1
%27 = load i32, i32* %4
%28 = icmp ugt i32 %27, 4
br i1 %28, label %29, label %44
29: ; preds = %26
%30 = load i8*, i8** %3
%31 = load i32, i32* %4
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = getelementptr inbounds i8, i8* %33, i64 -4
%35 = call i64 @FILENAME_CMP(i8* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %44
37: ; preds = %29
%38 = load i32, i32* %4
%39 = sub i32 %38, 4
store i32 %39, i32* %4
%40 = load i8*, i8** %3
%41 = load i32, i32* %4
%42 = zext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
store i8 0, i8* %43
br label %44
44: ; preds = %37, %29, %26
br label %45
45: ; preds = %44, %19
%46 = load i32, i32* %4
%47 = icmp ugt i32 %46, 5
br i1 %47, label %48, label %63
48: ; preds = %45
%49 = load i8*, i8** %3
%50 = load i32, i32* %4
%51 = zext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
%53 = getelementptr inbounds i8, i8* %52, i64 -5
%54 = call i64 @FILENAME_CMP(i8* %53, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %63
56: ; preds = %48
%57 = load i32, i32* %4
%58 = sub i32 %57, 5
store i32 %58, i32* %4
%59 = load i8*, i8** %3
%60 = load i32, i32* %4
%61 = zext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
store i8 0, i8* %62
br label %82
63: ; preds = %48, %45
%64 = load i32, i32* %4
%65 = icmp ugt i32 %64, 4
br i1 %65, label %66, label %81
66: ; preds = %63
%67 = load i8*, i8** %3
%68 = load i32, i32* %4
%69 = zext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %67, i64 %69
%71 = getelementptr inbounds i8, i8* %70, i64 -4
%72 = call i64 @FILENAME_CMP(i8* %71, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%73 = icmp eq i64 %72, 0
br i1 %73, label %74, label %81
74: ; preds = %66
%75 = load i32, i32* %4
%76 = sub i32 %75, 4
store i32 %76, i32* %4
%77 = load i8*, i8** %3
%78 = load i32, i32* %4
%79 = zext i32 %78 to i64
%80 = getelementptr inbounds i8, i8* %77, i64 %79
store i8 0, i8* %80
br label %81
81: ; preds = %74, %66, %63
br label %82
82: ; preds = %81, %56
%83 = load i8*, i8** %3
ret i8* %83
}

LLVM IR (-O2):
@.str = [4 x i8] c".gz\00"
@.str.1 = [5 x i8] c".bz2\00"
@.str.2 = [6 x i8] c".info\00"
@.str.3 = [5 x i8] c".inf\00"
define i8* @strip_info_suffix(i8* %0) {
%2 = tail call i8* @xstrdup(i8* %0)
%3 = tail call i32 @strlen(i8* %2)
%4 = icmp ugt i32 %3, 3
br i1 %4, label %5, label %44
5: ; preds = %1
%6 = zext i32 %3 to i64
%7 = getelementptr inbounds i8, i8* %2, i64 %6
%8 = getelementptr inbounds i8, i8* %7, i64 -3
%9 = tail call i64 @FILENAME_CMP(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %5
%12 = icmp ugt i32 %3, 4
br i1 %12, label %13, label %44
13: ; preds = %11
%14 = getelementptr inbounds i8, i8* %7, i64 -4
%15 = tail call i64 @FILENAME_CMP(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %13, %5
%18 = phi i32 [ -3, %5 ], [ -4, %13 ]
%19 = add i32 %3, %18
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %2, i64 %20
store i8 0, i8* %21
br label %22
22: ; preds = %17, %13
%23 = phi i32 [ %3, %13 ], [ %19, %17 ]
%24 = icmp ugt i32 %23, 5
br i1 %24, label %25, label %31
25: ; preds = %22
%26 = zext i32 %23 to i64
%27 = getelementptr inbounds i8, i8* %2, i64 %26
%28 = getelementptr inbounds i8, i8* %27, i64 -5
%29 = tail call i64 @FILENAME_CMP(i8* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %39, label %33
31: ; preds = %22
%32 = icmp eq i32 %23, 5
br i1 %32, label %33, label %44
33: ; preds = %31, %25
%34 = zext i32 %23 to i64
%35 = getelementptr inbounds i8, i8* %2, i64 %34
%36 = getelementptr inbounds i8, i8* %35, i64 -4
%37 = tail call i64 @FILENAME_CMP(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %33, %25
%40 = phi i32 [ -5, %25 ], [ -4, %33 ]
%41 = add i32 %23, %40
%42 = zext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %2, i64 %42
store i8 0, i8* %43
br label %44
44: ; preds = %39, %11, %1, %31, %33
ret i8* %2
}