#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 */
char toupper(char);
scalar_t__ valid_d_char(char);
char map_fileid_char(char c, int relaxed) {
  char upper;
  if (c == '/')
    return '_';
  if ((relaxed & 3) == 2)
    return c;
  if (valid_d_char(c))
    return c;
  if ((relaxed & 4) && (c & 0x7f) == c && (c < 'a' || c > 'z'))
    return c;
  upper = toupper(c);
  if (valid_d_char(upper)) {
    if (relaxed & 3) {
      return c;
    }
    return upper;
  }
  return '_';
}


x86 assembly (clang, -O0):
<map_fileid_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x2(%rbp)
mov    %esi,-0x8(%rbp)
movsbl -0x2(%rbp),%eax
cmp    $0x2f,%eax
jne    1147 <map_fileid_char+0x27>
movb   $0x5f,-0x1(%rbp)
jmp    120e <map_fileid_char+0xee>
mov    -0x8(%rbp),%eax
and    $0x3,%eax
cmp    $0x2,%eax
jne    1161 <map_fileid_char+0x41>
mov    -0x2(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    120e <map_fileid_char+0xee>
movsbl -0x2(%rbp),%edi
call   1040 <valid_d_char@plt>
cmp    $0x0,%rax
je     117f <map_fileid_char+0x5f>
mov    -0x2(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    120e <map_fileid_char+0xee>
mov    -0x8(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     11c6 <map_fileid_char+0xa6>
movsbl -0x2(%rbp),%eax
and    $0x7f,%eax
movsbl -0x2(%rbp),%ecx
cmp    %ecx,%eax
jne    11c6 <map_fileid_char+0xa6>
movsbl -0x2(%rbp),%eax
cmp    $0x61,%eax
jl     11bb <map_fileid_char+0x9b>
movsbl -0x2(%rbp),%eax
cmp    $0x7a,%eax
jle    11c6 <map_fileid_char+0xa6>
mov    -0x2(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    120e <map_fileid_char+0xee>
movsbl -0x2(%rbp),%edi
call   1030 <toupper@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%edi
call   1040 <valid_d_char@plt>
cmp    $0x0,%rax
je     120a <map_fileid_char+0xea>
mov    -0x8(%rbp),%eax
and    $0x3,%eax
cmp    $0x0,%eax
je     11ff <map_fileid_char+0xdf>
mov    -0x2(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    120e <map_fileid_char+0xee>
mov    -0x9(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    120e <map_fileid_char+0xee>
movb   $0x5f,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<map_fileid_char>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%ebx
mov    $0x5f,%r12b
cmp    $0x2f,%bl
je     1164 <map_fileid_char+0x44>
mov    %esi,%r14d
mov    %esi,%ebp
and    $0x3,%ebp
cmp    $0x2,%ebp
je     1161 <map_fileid_char+0x41>
movsbl %bl,%r15d
mov    %r15d,%edi
call   1040 <valid_d_char@plt>
test   %rax,%rax
jne    1161 <map_fileid_char+0x41>
lea    -0x7b(%rbx),%eax
cmp    $0xe5,%al
ja     1170 <map_fileid_char+0x50>
test   %bl,%bl
js     1170 <map_fileid_char+0x50>
and    $0x4,%r14d
je     1170 <map_fileid_char+0x50>
mov    %ebx,%r12d
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15d,%edi
call   1030 <toupper@plt>
mov    %eax,%r14d
movsbl %al,%edi
call   1040 <valid_d_char@plt>
test   %rax,%rax
je     1164 <map_fileid_char+0x44>
test   %ebp,%ebp
movzbl %r14b,%eax
movzbl %bl,%r12d
cmove  %eax,%r12d
jmp    1164 <map_fileid_char+0x44>

LLVM IR (-O0):
define signext i8 @map_fileid_char(i8 signext %0, i32 %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
%6 = alloca i8
store i8 %0, i8* %4
store i32 %1, i32* %5
%7 = load i8, i8* %4
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 47
br i1 %9, label %10, label %11
10: ; preds = %2
store i8 95, i8* %3
br label %59
11: ; preds = %2
%12 = load i32, i32* %5
%13 = and i32 %12, 3
%14 = icmp eq i32 %13, 2
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = load i8, i8* %4
store i8 %16, i8* %3
br label %59
17: ; preds = %11
%18 = load i8, i8* %4
%19 = call i64 @valid_d_char(i8 signext %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load i8, i8* %4
store i8 %22, i8* %3
br label %59
23: ; preds = %17
%24 = load i32, i32* %5
%25 = and i32 %24, 4
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %44
27: ; preds = %23
%28 = load i8, i8* %4
%29 = sext i8 %28 to i32
%30 = and i32 %29, 127
%31 = load i8, i8* %4
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %30, %32
br i1 %33, label %34, label %44
34: ; preds = %27
%35 = load i8, i8* %4
%36 = sext i8 %35 to i32
%37 = icmp slt i32 %36, 97
br i1 %37, label %42, label %38
38: ; preds = %34
%39 = load i8, i8* %4
%40 = sext i8 %39 to i32
%41 = icmp sgt i32 %40, 122
br i1 %41, label %42, label %44
42: ; preds = %38, %34
%43 = load i8, i8* %4
store i8 %43, i8* %3
br label %59
44: ; preds = %38, %27, %23
%45 = load i8, i8* %4
%46 = call signext i8 @toupper(i8 signext %45)
store i8 %46, i8* %6
%47 = load i8, i8* %6
%48 = call i64 @valid_d_char(i8 signext %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %58
50: ; preds = %44
%51 = load i32, i32* %5
%52 = and i32 %51, 3
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %50
%55 = load i8, i8* %4
store i8 %55, i8* %3
br label %59
56: ; preds = %50
%57 = load i8, i8* %6
store i8 %57, i8* %3
br label %59
58: ; preds = %44
store i8 95, i8* %3
br label %59
59: ; preds = %58, %56, %54, %42, %21, %15, %10
%60 = load i8, i8* %3
ret i8 %60
}

LLVM IR (-O2):
define signext i8 @map_fileid_char(i8 signext %0, i32 %1) {
%3 = icmp eq i8 %0, 47
br i1 %3, label %25, label %4
4: ; preds = %2
%5 = and i32 %1, 3
%6 = icmp eq i32 %5, 2
br i1 %6, label %25, label %7
7: ; preds = %4
%8 = tail call i64 @valid_d_char(i8 signext %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %25
10: ; preds = %7
%11 = and i32 %1, 4
%12 = icmp ne i32 %11, 0
%13 = icmp sgt i8 %0, -1
%14 = and i1 %13, %12
%15 = add i8 %0, -123
%16 = icmp ult i8 %15, -26
%17 = and i1 %16, %14
br i1 %17, label %25, label %18
18: ; preds = %10
%19 = tail call signext i8 @toupper(i8 signext %0)
%20 = tail call i64 @valid_d_char(i8 signext %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %18
%23 = icmp eq i32 %5, 0
%24 = select i1 %23, i8 %19, i8 %0
br label %25
25: ; preds = %18, %22, %10, %7, %4, %2
%26 = phi i8 [ 95, %2 ], [ %0, %4 ], [ %0, %7 ], [ %0, %10 ], [ %24, %22 ], [ 95, %18 ]
ret i8 %26
}