#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*/ Q_isBadDirChar(char);
char *Q_CleanDirName(char *dirname) {
  char *d;
  char *s;
  s = dirname;
  d = dirname;
  while (*s == '.') {
    s++;
  }
  while (*s != '\0') {
    if (!Q_isBadDirChar(*s)) {
      *d++ = *s;
    }
    s++;
  }
  *d = '\0';
  return dirname;
}


x86 assembly (clang, -O0):
<Q_CleanDirName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    114d <Q_CleanDirName+0x3d>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    112c <Q_CleanDirName+0x1c>
jmp    1152 <Q_CleanDirName+0x42>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     119f <Q_CleanDirName+0x8f>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <Q_isBadDirChar@plt>
cmp    $0x0,%eax
jne    118e <Q_CleanDirName+0x7e>
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1152 <Q_CleanDirName+0x42>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Q_CleanDirName>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    %rdi,%rbx
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
add    $0x1,%rbx
cmp    $0x2e,%al
je     1120 <Q_CleanDirName+0x10>
mov    %r14,%r15
jmp    1137 <Q_CleanDirName+0x27>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1154 <Q_CleanDirName+0x44>
movsbl %al,%edi
call   1030 <Q_isBadDirChar@plt>
test   %eax,%eax
jne    1130 <Q_CleanDirName+0x20>
movzbl -0x1(%rbx),%eax
mov    %al,(%r15)
add    $0x1,%r15
jmp    1130 <Q_CleanDirName+0x20>
movb   $0x0,(%r15)
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @Q_CleanDirName(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
store i8* %5, i8** %4
%6 = load i8*, i8** %2
store i8* %6, i8** %3
br label %7
7: ; preds = %12, %1
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 46
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %4
br label %7
15: ; preds = %7
br label %16
16: ; preds = %31, %15
%17 = load i8*, i8** %4
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %34
21: ; preds = %16
%22 = load i8*, i8** %4
%23 = load i8, i8* %22
%24 = call i32 @Q_isBadDirChar(i8 signext %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %31, label %26
26: ; preds = %21
%27 = load i8*, i8** %4
%28 = load i8, i8* %27
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %3
store i8 %28, i8* %29
br label %31
31: ; preds = %26, %21
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %4
br label %16
34: ; preds = %16
%35 = load i8*, i8** %3
store i8 0, i8* %35
%36 = load i8*, i8** %2
ret i8* %36
}

LLVM IR (-O2):
define i8* @Q_CleanDirName(i8* returned %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i8* [ %0, %1 ], [ %5, %2 ]
%4 = load i8, i8* %3
%5 = getelementptr inbounds i8, i8* %3, i64 1
switch i8 %4, label %6 [
i8 46, label %2
i8 0, label %20
]
6: ; preds = %2, %15
%7 = phi i8* [ %17, %15 ], [ %3, %2 ]
%8 = phi i8* [ %16, %15 ], [ %0, %2 ]
%9 = phi i8 [ %18, %15 ], [ %4, %2 ]
%10 = tail call i32 @Q_isBadDirChar(i8 signext %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %6
%13 = load i8, i8* %7
%14 = getelementptr inbounds i8, i8* %8, i64 1
store i8 %13, i8* %8
br label %15
15: ; preds = %12, %6
%16 = phi i8* [ %8, %6 ], [ %14, %12 ]
%17 = getelementptr inbounds i8, i8* %7, i64 1
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %6
20: ; preds = %2, %15
%21 = phi i8* [ %16, %15 ], [ %0, %2 ]
store i8 0, i8* %21
ret i8* %0
}