#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*/ FREE(char *);
char *appendExt(char const *, char *);
scalar_t__ fileExists(char *);
int /*<<< orphan*/ remove_file(char *);
void removeImgAndMeta(const char *base) {
  char *meta_file = appendExt(base, ".meta");
  char *img_file = appendExt(base, ".img");
  char *hdr_file = appendExt(base, ".hdr");
  if (fileExists(meta_file))
    remove_file(meta_file);
  if (fileExists(img_file))
    remove_file(img_file);
  if (fileExists(hdr_file))
    remove_file(hdr_file);
  FREE(meta_file);
  FREE(img_file);
  FREE(hdr_file);
}


x86 assembly (clang, -O0):
<removeImgAndMeta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1050 <appendExt@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1050 <appendExt@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe8c(%rip),%rsi
call   1050 <appendExt@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fileExists@plt>
cmp    $0x0,%rax
je     11a4 <removeImgAndMeta+0x64>
mov    -0x10(%rbp),%rdi
call   1040 <remove_file@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fileExists@plt>
cmp    $0x0,%rax
je     11c0 <removeImgAndMeta+0x80>
mov    -0x18(%rbp),%rdi
call   1040 <remove_file@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fileExists@plt>
cmp    $0x0,%rax
je     11dc <removeImgAndMeta+0x9c>
mov    -0x20(%rbp),%rdi
call   1040 <remove_file@plt>
mov    -0x10(%rbp),%rdi
call   1060 <FREE@plt>
mov    -0x18(%rbp),%rdi
call   1060 <FREE@plt>
mov    -0x20(%rbp),%rdi
call   1060 <FREE@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<removeImgAndMeta>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xeb1(%rip),%rsi
call   1050 <appendExt@plt>
mov    %rax,%r14
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
call   1050 <appendExt@plt>
mov    %rax,%r15
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
call   1050 <appendExt@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <fileExists@plt>
test   %rax,%rax
je     1190 <removeImgAndMeta+0x50>
mov    %r14,%rdi
call   1040 <remove_file@plt>
mov    %r15,%rdi
call   1030 <fileExists@plt>
test   %rax,%rax
je     11a5 <removeImgAndMeta+0x65>
mov    %r15,%rdi
call   1040 <remove_file@plt>
mov    %rbx,%rdi
call   1030 <fileExists@plt>
test   %rax,%rax
je     11ba <removeImgAndMeta+0x7a>
mov    %rbx,%rdi
call   1040 <remove_file@plt>
mov    %r14,%rdi
call   1060 <FREE@plt>
mov    %r15,%rdi
call   1060 <FREE@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <FREE@plt>

LLVM IR (-O0):
@.str = [6 x i8] c".meta\00"
@.str.1 = [5 x i8] c".img\00"
@.str.2 = [5 x i8] c".hdr\00"
define void @removeImgAndMeta(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i8* @appendExt(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %3
%8 = load i8*, i8** %2
%9 = call i8* @appendExt(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %9, i8** %4
%10 = load i8*, i8** %2
%11 = call i8* @appendExt(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i8* %11, i8** %5
%12 = load i8*, i8** %3
%13 = call i64 @fileExists(i8* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %1
%16 = load i8*, i8** %3
%17 = call i32 @remove_file(i8* %16)
br label %18
18: ; preds = %15, %1
%19 = load i8*, i8** %4
%20 = call i64 @fileExists(i8* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i8*, i8** %4
%24 = call i32 @remove_file(i8* %23)
br label %25
25: ; preds = %22, %18
%26 = load i8*, i8** %5
%27 = call i64 @fileExists(i8* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i8*, i8** %5
%31 = call i32 @remove_file(i8* %30)
br label %32
32: ; preds = %29, %25
%33 = load i8*, i8** %3
%34 = call i32 @FREE(i8* %33)
%35 = load i8*, i8** %4
%36 = call i32 @FREE(i8* %35)
%37 = load i8*, i8** %5
%38 = call i32 @FREE(i8* %37)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c".meta\00"
@.str.1 = [5 x i8] c".img\00"
@.str.2 = [5 x i8] c".hdr\00"
define void @removeImgAndMeta(i8* %0) {
%2 = tail call i8* @appendExt(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%3 = tail call i8* @appendExt(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i8* @appendExt(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i64 @fileExists(i8* %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = tail call i32 @remove_file(i8* %2)
br label %9
9: ; preds = %7, %1
%10 = tail call i64 @fileExists(i8* %3)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 @remove_file(i8* %3)
br label %14
14: ; preds = %12, %9
%15 = tail call i64 @fileExists(i8* %4)
%16 = icmp eq i64 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = tail call i32 @remove_file(i8* %4)
br label %19
19: ; preds = %17, %14
%20 = tail call i32 @FREE(i8* %2)
%21 = tail call i32 @FREE(i8* %3)
%22 = tail call i32 @FREE(i8* %4)
ret void
}