#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
scalar_t__ strcmp(char const *, char *);
int strlen(char const *);
void closeFile(FILE *F, const char *path) {
  if ((path) && ((strcmp(path + strlen(path) - 4, ".bz2") == 0) ||
                 (strcmp(path + strlen(path) - 3, ".gz") == 0))) {
    pclose(F);
  } else {
    fclose(F);
  }
}


x86 assembly (clang, -O0):
<closeFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11d1 <closeFile+0x91>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x18(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe80(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     11c3 <closeFile+0x83>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xe51(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11d1 <closeFile+0x91>
mov    -0x8(%rbp),%rdi
call   1050 <pclose@plt>
jmp    11da <closeFile+0x9a>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<closeFile>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rsi,%rsi
je     1195 <closeFile+0x55>
mov    %rsi,%rbx
mov    %rsi,%rdi
call   1040 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe98(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11a4 <closeFile+0x64>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xe7a(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11a4 <closeFile+0x64>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fclose@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <pclose@plt>

LLVM IR (-O0):
@.str = [5 x i8] c".bz2\00"
@.str.1 = [4 x i8] c".gz\00"
define void @closeFile(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %28
7: ; preds = %2
%8 = load i8*, i8** %4
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %8, i64 %11
%13 = getelementptr inbounds i8, i8* %12, i64 -4
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %25, label %16
16: ; preds = %7
%17 = load i8*, i8** %4
%18 = load i8*, i8** %4
%19 = call i32 @strlen(i8* %18)
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %17, i64 %20
%22 = getelementptr inbounds i8, i8* %21, i64 -3
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %16, %7
%26 = load i32*, i32** %3
%27 = call i32 @pclose(i32* %26)
br label %31
28: ; preds = %16, %2
%29 = load i32*, i32** %3
%30 = call i32 @fclose(i32* %29)
br label %31
31: ; preds = %28, %25
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c".bz2\00"
@.str.1 = [4 x i8] c".gz\00"
define void @closeFile(i32* nocapture %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %20, label %4
4: ; preds = %2
%5 = tail call i32 @strlen(i8* %1)
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %1, i64 %6
%8 = getelementptr inbounds i8, i8* %7, i64 -4
%9 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %18, label %11
11: ; preds = %4
%12 = tail call i32 @strlen(i8* %1)
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %1, i64 %13
%15 = getelementptr inbounds i8, i8* %14, i64 -3
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %11, %4
%19 = tail call i32 @pclose(i32* %0)
br label %22
20: ; preds = %11, %2
%21 = tail call i32 @fclose(i32* %0)
br label %22
22: ; preds = %20, %18
ret void
}