#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__ MALLOC(int);
char *findExt(char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp_case(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *stripExt(char *);
void append_band_ext(char *inFile, char *outFile, char *bandExt) {
  char *ext, *base_name;
  ext = findExt(inFile);
  if (ext && (strcmp_case(ext, ".IMG") == 0 || strcmp_case(ext, ".TIF") == 0 ||
              strcmp_case(ext, ".TIFF") == 0 || strcmp_case(ext, ".JPG") == 0 ||
              strcmp_case(ext, ".JPEG") == 0 || strcmp_case(ext, ".PNG") == 0 ||
              strcmp_case(ext, ".PGM") == 0 || strcmp_case(ext, ".BIN") == 0 ||
              strcmp_case(ext, ".NC") == 0 || strcmp_case(ext, ".H5") == 0))
    base_name = stripExt(inFile);
  else {
    base_name = (char *)MALLOC(sizeof(char) * 255);
    strcpy(base_name, inFile);
  }
  if (bandExt)
    sprintf(outFile, "%s_%s", base_name, bandExt);
  else
    sprintf(outFile, "%s", base_name);
  if (ext)
    strcat(outFile, ext);
  free(base_name);
}


x86 assembly (clang, -O0):
<append_band_ext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   10a0 <findExt@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     12c2 <append_band_ext+0x142>
mov    -0x20(%rbp),%rdi
lea    0xe49(%rip),%rsi
call   1060 <strcmp_case@plt>
cmp    $0x0,%rax
je     12b0 <append_band_ext+0x130>
mov    -0x20(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1060 <strcmp_case@plt>
cmp    $0x0,%rax
je     12b0 <append_band_ext+0x130>
mov    -0x20(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1060 <strcmp_case@plt>
cmp    $0x0,%rax
je     12b0 <append_band_ext+0x130>
mov    -0x20(%rbp),%rdi
lea    0xe0b(%rip),%rsi
call   1060 <strcmp_case@plt>
cmp    $0x0,%rax
je     12b0 <append_band_ext+0x130>
mov    -0x20(%rbp),%rdi
lea    0xdf6(%rip),%rsi
call   1060 <strcmp_case@plt>
cmp    $0x0,%rax
je     12b0 <append_band_ext+0x130>
mov    -0x20(%rbp),%rdi
lea    0xde2(%rip),%rsi
call   1060 <strcmp_case@plt>
cmp    $0x0,%rax
je     12b0 <append_band_ext+0x130>
mov    -0x20(%rbp),%rdi
lea    0xdcd(%rip),%rsi
call   1060 <strcmp_case@plt>
cmp    $0x0,%rax
je     12b0 <append_band_ext+0x130>
mov    -0x20(%rbp),%rdi
lea    0xdb8(%rip),%rsi
call   1060 <strcmp_case@plt>
cmp    $0x0,%rax
je     12b0 <append_band_ext+0x130>
mov    -0x20(%rbp),%rdi
lea    0xda3(%rip),%rsi
call   1060 <strcmp_case@plt>
cmp    $0x0,%rax
je     12b0 <append_band_ext+0x130>
mov    -0x20(%rbp),%rdi
lea    0xd8d(%rip),%rsi
call   1060 <strcmp_case@plt>
cmp    $0x0,%rax
jne    12c2 <append_band_ext+0x142>
mov    -0x8(%rbp),%rdi
call   1050 <stripExt@plt>
mov    %rax,-0x28(%rbp)
jmp    12dd <append_band_ext+0x15d>
mov    $0xff,%edi
call   1070 <MALLOC@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
cmpq   $0x0,-0x18(%rbp)
je     1307 <append_band_ext+0x187>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xd37(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
jmp    131d <append_band_ext+0x19d>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xd1f(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
cmpq   $0x0,-0x20(%rbp)
je     1335 <append_band_ext+0x1b5>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<append_band_ext>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
call   10a0 <findExt@plt>
mov    %rax,%r13
test   %rax,%rax
je     127f <append_band_ext+0xff>
lea    0xe56(%rip),%rsi
mov    %r13,%rdi
call   1060 <strcmp_case@plt>
test   %rax,%rax
je     12ae <append_band_ext+0x12e>
lea    0xe43(%rip),%rsi
mov    %r13,%rdi
call   1060 <strcmp_case@plt>
test   %rax,%rax
je     12ae <append_band_ext+0x12e>
lea    0xe30(%rip),%rsi
mov    %r13,%rdi
call   1060 <strcmp_case@plt>
test   %rax,%rax
je     12ae <append_band_ext+0x12e>
lea    0xe1e(%rip),%rsi
mov    %r13,%rdi
call   1060 <strcmp_case@plt>
test   %rax,%rax
je     12ae <append_band_ext+0x12e>
lea    0xe0b(%rip),%rsi
mov    %r13,%rdi
call   1060 <strcmp_case@plt>
test   %rax,%rax
je     12ae <append_band_ext+0x12e>
lea    0xdf9(%rip),%rsi
mov    %r13,%rdi
call   1060 <strcmp_case@plt>
test   %rax,%rax
je     12ae <append_band_ext+0x12e>
lea    0xdea(%rip),%rsi
mov    %r13,%rdi
call   1060 <strcmp_case@plt>
test   %rax,%rax
je     12ae <append_band_ext+0x12e>
lea    0xddb(%rip),%rsi
mov    %r13,%rdi
call   1060 <strcmp_case@plt>
test   %rax,%rax
je     12ae <append_band_ext+0x12e>
lea    0xdcc(%rip),%rsi
mov    %r13,%rdi
call   1060 <strcmp_case@plt>
test   %rax,%rax
je     12ae <append_band_ext+0x12e>
lea    0xdbc(%rip),%rsi
mov    %r13,%rdi
call   1060 <strcmp_case@plt>
test   %rax,%rax
je     12ae <append_band_ext+0x12e>
mov    $0xff,%edi
call   1070 <MALLOC@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
test   %r15,%r15
jne    12be <append_band_ext+0x13e>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
test   %r13,%r13
jne    12da <append_band_ext+0x15a>
jmp    12e5 <append_band_ext+0x165>
mov    %r12,%rdi
call   1050 <stripExt@plt>
mov    %rax,%rbx
test   %r15,%r15
je     129c <append_band_ext+0x11c>
lea    0xd6d(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1090 <sprintf@plt>
test   %r13,%r13
je     12e5 <append_band_ext+0x165>
mov    %r14,%rdi
mov    %r13,%rsi
call   1080 <strcat@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [5 x i8] c".IMG\00"
@.str.1 = [5 x i8] c".TIF\00"
@.str.2 = [6 x i8] c".TIFF\00"
@.str.3 = [5 x i8] c".JPG\00"
@.str.4 = [6 x i8] c".JPEG\00"
@.str.5 = [5 x i8] c".PNG\00"
@.str.6 = [5 x i8] c".PGM\00"
@.str.7 = [5 x i8] c".BIN\00"
@.str.8 = [4 x i8] c".NC\00"
@.str.9 = [4 x i8] c".H5\00"
@.str.10 = [6 x i8] c"%s_%s\00"
@.str.11 = [3 x i8] c"%s\00"
define void @append_band_ext(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = load i8*, i8** %4
%10 = call i8* @findExt(i8* %9)
store i8* %10, i8** %7
%11 = load i8*, i8** %7
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %56
13: ; preds = %3
%14 = load i8*, i8** %7
%15 = call i64 @strcmp_case(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %53, label %17
17: ; preds = %13
%18 = load i8*, i8** %7
%19 = call i64 @strcmp_case(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %53, label %21
21: ; preds = %17
%22 = load i8*, i8** %7
%23 = call i64 @strcmp_case(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %53, label %25
25: ; preds = %21
%26 = load i8*, i8** %7
%27 = call i64 @strcmp_case(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %53, label %29
29: ; preds = %25
%30 = load i8*, i8** %7
%31 = call i64 @strcmp_case(i8* %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %53, label %33
33: ; preds = %29
%34 = load i8*, i8** %7
%35 = call i64 @strcmp_case(i8* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %53, label %37
37: ; preds = %33
%38 = load i8*, i8** %7
%39 = call i64 @strcmp_case(i8* %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %53, label %41
41: ; preds = %37
%42 = load i8*, i8** %7
%43 = call i64 @strcmp_case(i8* %42, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %53, label %45
45: ; preds = %41
%46 = load i8*, i8** %7
%47 = call i64 @strcmp_case(i8* %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %53, label %49
49: ; preds = %45
%50 = load i8*, i8** %7
%51 = call i64 @strcmp_case(i8* %50, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %49, %45, %41, %37, %33, %29, %25, %21, %17, %13
%54 = load i8*, i8** %4
%55 = call i8* @stripExt(i8* %54)
store i8* %55, i8** %8
br label %62
56: ; preds = %49, %3
%57 = call i64 @MALLOC(i32 255)
%58 = inttoptr i64 %57 to i8*
store i8* %58, i8** %8
%59 = load i8*, i8** %8
%60 = load i8*, i8** %4
%61 = call i32 @strcpy(i8* %59, i8* %60)
br label %62
62: ; preds = %56, %53
%63 = load i8*, i8** %6
%64 = icmp ne i8* %63, null
br i1 %64, label %65, label %70
65: ; preds = %62
%66 = load i8*, i8** %5
%67 = load i8*, i8** %8
%68 = load i8*, i8** %6
%69 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %66, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* %67, i8* %68)
br label %74
70: ; preds = %62
%71 = load i8*, i8** %5
%72 = load i8*, i8** %8
%73 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %71, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* %72)
br label %74
74: ; preds = %70, %65
%75 = load i8*, i8** %7
%76 = icmp ne i8* %75, null
br i1 %76, label %77, label %81
77: ; preds = %74
%78 = load i8*, i8** %5
%79 = load i8*, i8** %7
%80 = call i32 @strcat(i8* %78, i8* %79)
br label %81
81: ; preds = %77, %74
%82 = load i8*, i8** %8
%83 = call i32 @free(i8* %82)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c".IMG\00"
@.str.1 = [5 x i8] c".TIF\00"
@.str.2 = [6 x i8] c".TIFF\00"
@.str.3 = [5 x i8] c".JPG\00"
@.str.4 = [6 x i8] c".JPEG\00"
@.str.5 = [5 x i8] c".PNG\00"
@.str.6 = [5 x i8] c".PGM\00"
@.str.7 = [5 x i8] c".BIN\00"
@.str.8 = [4 x i8] c".NC\00"
@.str.9 = [4 x i8] c".H5\00"
@.str.10 = [6 x i8] c"%s_%s\00"
define void @append_band_ext(i8* %0, i8* %1, i8* %2) {
%4 = tail call i8* @findExt(i8* %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %38, label %6
6: ; preds = %3
%7 = tail call i64 @strcmp_case(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %36, label %9
9: ; preds = %6
%10 = tail call i64 @strcmp_case(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %36, label %12
12: ; preds = %9
%13 = tail call i64 @strcmp_case(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %36, label %15
15: ; preds = %12
%16 = tail call i64 @strcmp_case(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %36, label %18
18: ; preds = %15
%19 = tail call i64 @strcmp_case(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %36, label %21
21: ; preds = %18
%22 = tail call i64 @strcmp_case(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %36, label %24
24: ; preds = %21
%25 = tail call i64 @strcmp_case(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %36, label %27
27: ; preds = %24
%28 = tail call i64 @strcmp_case(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %36, label %30
30: ; preds = %27
%31 = tail call i64 @strcmp_case(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = tail call i64 @strcmp_case(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %33, %30, %27, %24, %21, %18, %15, %12, %9, %6
%37 = tail call i8* @stripExt(i8* %0)
br label %42
38: ; preds = %33, %3
%39 = tail call i64 @MALLOC(i32 255)
%40 = inttoptr i64 %39 to i8*
%41 = tail call i32 @strcpy(i8* %40, i8* %0)
br label %42
42: ; preds = %38, %36
%43 = phi i8* [ %37, %36 ], [ %40, %38 ]
%44 = icmp eq i8* %2, null
br i1 %44, label %47, label %45
45: ; preds = %42
%46 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* %43, i8* %2)
br label %49
47: ; preds = %42
%48 = tail call i8* bitcast (i32 (i8*, i8*)* @strcpy to i8* (i8*, i8*)*)(i8* %1, i8* %43)
br label %49
49: ; preds = %47, %45
br i1 %5, label %52, label %50
50: ; preds = %49
%51 = tail call i32 @strcat(i8* %1, i8* %4)
br label %52
52: ; preds = %50, %49
%53 = tail call i32 @free(i8* %43)
ret void
}