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

/* Variables and functions */
scalar_t__ delfiles(char *, char *);
char *getfname(char *);
scalar_t__ isalpha(char);
int /*<<< orphan*/ sprintf(char *, char *, char, ...);
scalar_t__ strchr(char const *, char);
int /*<<< orphan*/ strncat(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char const *, int);
int /*<<< orphan*/ tolower(char);
int toupper(char);
int removecase(const char *path) {
  char inpath[260 + 1];
  char fname[260 * 4 + 1];
  char tmp[5];
  char *p;
  int i;
  if (strchr(path, '?') || strchr(path, '*'))
    return (-1);
  (strncpy(inpath, path, sizeof(inpath)), inpath[sizeof(inpath) - 1] = 0);
  p = getfname(inpath);
  fname[0] = 0;
  for (i = 0; p[i]; i++) {
    if (isalpha(p[i]))
      sprintf(tmp, "[%c%c]", toupper(p[i]), tolower(p[i]));
    else
      sprintf(tmp, "%c", p[i]);
    strncat(fname, tmp, 260 * 4);
  }
  *p = 0;
  return (delfiles(inpath, fname) ? -1 : 0);
}


x86 assembly (clang, -O0):
<removecase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x560,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3f,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
jne    11cf <removecase+0x3f>
mov    -0x10(%rbp),%rdi
mov    $0x2a,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     11db <removecase+0x4b>
movl   $0xffffffff,-0x4(%rbp)
jmp    133c <removecase+0x1ac>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x105,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x1c(%rbp)
lea    -0x120(%rbp),%rdi
call   1060 <getfname@plt>
mov    %rax,-0x550(%rbp)
movb   $0x0,-0x540(%rbp)
movl   $0x0,-0x554(%rbp)
mov    -0x550(%rbp),%rax
movslq -0x554(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     130b <removecase+0x17b>
mov    -0x550(%rbp),%rax
movslq -0x554(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   10a0 <isalpha@plt>
cmp    $0x0,%rax
je     12b8 <removecase+0x128>
lea    -0x545(%rbp),%rax
mov    %rax,-0x560(%rbp)
mov    -0x550(%rbp),%rax
movslq -0x554(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <toupper@plt>
mov    %al,-0x555(%rbp)
mov    -0x550(%rbp),%rax
movslq -0x554(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1080 <tolower@plt>
mov    -0x560(%rbp),%rdi
mov    %eax,%ecx
mov    -0x555(%rbp),%al
lea    0xd57(%rip),%rsi
movsbl %al,%edx
mov    $0x0,%al
call   10b0 <sprintf@plt>
jmp    12df <removecase+0x14f>
lea    -0x545(%rbp),%rdi
mov    -0x550(%rbp),%rax
movslq -0x554(%rbp),%rcx
lea    0xd33(%rip),%rsi
movsbl (%rax,%rcx,1),%edx
mov    $0x0,%al
call   10b0 <sprintf@plt>
lea    -0x540(%rbp),%rdi
lea    -0x545(%rbp),%rsi
mov    $0x410,%edx
call   1070 <strncat@plt>
mov    -0x554(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x554(%rbp)
jmp    1218 <removecase+0x88>
mov    -0x550(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x120(%rbp),%rdi
lea    -0x540(%rbp),%rsi
call   1090 <delfiles@plt>
mov    %rax,%rdx
xor    %eax,%eax
mov    $0xffffffff,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x560,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<removecase>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x538,%rsp
mov    %rdi,%rbx
mov    $0x3f,%esi
call   1050 <strchr@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
jne    12a7 <removecase+0x117>
mov    %rbx,%rdi
mov    $0x2a,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    12a7 <removecase+0x117>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x105,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x114(%rsp)
mov    %rbp,%rdi
call   1060 <getfname@plt>
mov    %rax,%r14
movb   $0x0,0x120(%rsp)
mov    (%rax),%al
test   %al,%al
je     128c <removecase+0xfc>
lea    0x120(%rsp),%r15
lea    0xb(%rsp),%r13
lea    0xde0(%rip),%r12
mov    %r14,%rbx
jmp    1255 <removecase+0xc5>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %cl,0xb(%rsp)
movb   $0x0,0xc(%rsp)
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x410,%edx
call   1070 <strncat@plt>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     128c <removecase+0xfc>
movsbl %al,%edi
call   10a0 <isalpha@plt>
movzbl (%rbx),%ecx
test   %rax,%rax
je     1230 <removecase+0xa0>
movsbl %cl,%edi
call   1040 <toupper@plt>
mov    %eax,%ebp
movsbl (%rbx),%edi
call   1080 <tolower@plt>
movsbl %bpl,%edx
mov    %r13,%rdi
mov    %r12,%rsi
mov    %eax,%ecx
xor    %eax,%eax
call   10b0 <sprintf@plt>
jmp    1239 <removecase+0xa9>
movb   $0x0,(%r14)
lea    0x10(%rsp),%rdi
lea    0x120(%rsp),%rsi
call   1090 <delfiles@plt>
neg    %rax
sbb    %ebp,%ebp
mov    %ebp,%eax
add    $0x538,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"[%c%c]\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @removecase(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [261 x i8]
%5 = alloca [1041 x i8]
%6 = alloca [5 x i8]
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %3
%9 = load i8*, i8** %3
%10 = call i64 @strchr(i8* %9, i8 signext 63)
%11 = icmp ne i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i64 @strchr(i8* %13, i8 signext 42)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12, %1
store i32 -1, i32* %2
br label %79
17: ; preds = %12
%18 = getelementptr inbounds [261 x i8], [261 x i8]* %4, i64 0, i64 0
%19 = load i8*, i8** %3
%20 = call i32 @strncpy(i8* %18, i8* %19, i32 261)
%21 = getelementptr inbounds [261 x i8], [261 x i8]* %4, i64 0, i64 260
store i8 0, i8* %21
%22 = getelementptr inbounds [261 x i8], [261 x i8]* %4, i64 0, i64 0
%23 = call i8* @getfname(i8* %22)
store i8* %23, i8** %7
%24 = getelementptr inbounds [1041 x i8], [1041 x i8]* %5, i64 0, i64 0
store i8 0, i8* %24
store i32 0, i32* %8
br label %25
25: ; preds = %68, %17
%26 = load i8*, i8** %7
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = icmp ne i8 %30, 0
br i1 %31, label %32, label %71
32: ; preds = %25
%33 = load i8*, i8** %7
%34 = load i32, i32* %8
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = call i64 @isalpha(i8 signext %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %56
40: ; preds = %32
%41 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%42 = load i8*, i8** %7
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = load i8, i8* %45
%47 = call i32 @toupper(i8 signext %46)
%48 = trunc i32 %47 to i8
%49 = load i8*, i8** %7
%50 = load i32, i32* %8
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
%53 = load i8, i8* %52
%54 = call i32 @tolower(i8 signext %53)
%55 = call i32 (i8*, i8*, i8, ...) @sprintf(i8* %41, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %48, i32 %54)
br label %64
56: ; preds = %32
%57 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%58 = load i8*, i8** %7
%59 = load i32, i32* %8
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %58, i64 %60
%62 = load i8, i8* %61
%63 = call i32 (i8*, i8*, i8, ...) @sprintf(i8* %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %62)
br label %64
64: ; preds = %56, %40
%65 = getelementptr inbounds [1041 x i8], [1041 x i8]* %5, i64 0, i64 0
%66 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%67 = call i32 @strncat(i8* %65, i8* %66, i32 1040)
br label %68
68: ; preds = %64
%69 = load i32, i32* %8
%70 = add nsw i32 %69, 1
store i32 %70, i32* %8
br label %25
71: ; preds = %25
%72 = load i8*, i8** %7
store i8 0, i8* %72
%73 = getelementptr inbounds [261 x i8], [261 x i8]* %4, i64 0, i64 0
%74 = getelementptr inbounds [1041 x i8], [1041 x i8]* %5, i64 0, i64 0
%75 = call i64 @delfiles(i8* %73, i8* %74)
%76 = icmp ne i64 %75, 0
%77 = zext i1 %76 to i64
%78 = select i1 %76, i32 -1, i32 0
store i32 %78, i32* %2
br label %79
79: ; preds = %71, %16
%80 = load i32, i32* %2
ret i32 %80
}

LLVM IR (-O2):
@.str = [7 x i8] c"[%c%c]\00"
define i32 @removecase(i8* %0) {
%2 = alloca [261 x i8]
%3 = alloca [1041 x i8]
%4 = alloca [5 x i8]
%5 = getelementptr inbounds [261 x i8], [261 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [1041 x i8], [1041 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%8 = tail call i64 @strchr(i8* %0, i8 signext 63)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %45
10: ; preds = %1
%11 = tail call i64 @strchr(i8* %0, i8 signext 42)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %45
13: ; preds = %10
%14 = call i32 @strncpy(i8* %5, i8* %0, i32 261)
%15 = getelementptr inbounds [261 x i8], [261 x i8]* %2, i64 0, i64 260
store i8 0, i8* %15
%16 = call i8* @getfname(i8* %5)
store i8 0, i8* %6
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %41, label %19
19: ; preds = %13
%20 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 1
br label %21
21: ; preds = %19, %35
%22 = phi i64 [ 0, %19 ], [ %37, %35 ]
%23 = phi i8 [ %17, %19 ], [ %39, %35 ]
%24 = phi i8* [ %16, %19 ], [ %38, %35 ]
%25 = call i64 @isalpha(i8 signext %23)
%26 = icmp eq i64 %25, 0
%27 = load i8, i8* %24
br i1 %26, label %34, label %28
28: ; preds = %21
%29 = call i32 @toupper(i8 signext %27)
%30 = trunc i32 %29 to i8
%31 = load i8, i8* %24
%32 = call i32 @tolower(i8 signext %31)
%33 = call i32 (i8*, i8*, i8, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %30, i32 %32)
br label %35
34: ; preds = %21
store i8 %27, i8* %7
store i8 0, i8* %20
br label %35
35: ; preds = %34, %28
%36 = call i32 @strncat(i8* %6, i8* %7, i32 1040)
%37 = add nuw i64 %22, 1
%38 = getelementptr inbounds i8, i8* %16, i64 %37
%39 = load i8, i8* %38
%40 = icmp eq i8 %39, 0
br i1 %40, label %41, label %21
41: ; preds = %35, %13
store i8 0, i8* %16
%42 = call i64 @delfiles(i8* %5, i8* %6)
%43 = icmp ne i64 %42, 0
%44 = sext i1 %43 to i32
br label %45
45: ; preds = %1, %10, %41
%46 = phi i32 [ %44, %41 ], [ -1, %10 ], [ -1, %1 ]
ret i32 %46
}