unsigned char asc_to_val(char c) {
  if (isdigit(c))
    return 0 + (unsigned char)(c - '0');
  if (islower(c))
    return 0xa + (unsigned char)(c - 'a');
  if (isupper(c))
    return 0xA + (unsigned char)(c - 'A');
  (!"Invalid character!")
      ? (void)0
      : _assert("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/thasenpusch/simplix/refs/"
                "heads/master/src/lib/util.c",
                247, __func__, "!\"Invalid character!\"");
}


x86 assembly (clang, -O0):
<asc_to_val>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     1175 <asc_to_val+0x35>
movsbl -0x2(%rbp),%eax
sub    $0x30,%eax
movzbl %al,%eax
add    $0x0,%eax
mov    %al,-0x1(%rbp)
jmp    11e4 <asc_to_val+0xa4>
movsbl -0x2(%rbp),%edi
call   1040 <islower@plt>
cmp    $0x0,%eax
je     119c <asc_to_val+0x5c>
movsbl -0x2(%rbp),%eax
sub    $0x61,%eax
movzbl %al,%eax
add    $0xa,%eax
mov    %al,-0x1(%rbp)
jmp    11e4 <asc_to_val+0xa4>
movsbl -0x2(%rbp),%edi
call   1050 <isupper@plt>
cmp    $0x0,%eax
je     11c3 <asc_to_val+0x83>
movsbl -0x2(%rbp),%eax
sub    $0x41,%eax
movzbl %al,%eax
add    $0xa,%eax
mov    %al,-0x1(%rbp)
jmp    11e4 <asc_to_val+0xa4>
lea    0xe36(%rip),%rdi
mov    $0xf7,%esi
lea    0xeb9(%rip),%rdx
lea    0xebd(%rip),%rcx
mov    $0x0,%al
call   1060 <_assert@plt>
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asc_to_val>:
push   %rbx
mov    %edi,%ebx
lea    -0x30(%rbx),%eax
cmp    $0x9,%eax
ja     1140 <asc_to_val+0x10>
lea    -0x30(%rbx),%eax
pop    %rbx
ret
mov    %ebx,%edi
call   1030 <islower@plt>
test   %eax,%eax
je     1150 <asc_to_val+0x20>
lea    -0x57(%rbx),%eax
pop    %rbx
ret
mov    %ebx,%edi
call   1040 <isupper@plt>
test   %eax,%eax
je     1160 <asc_to_val+0x30>
lea    -0x37(%rbx),%eax
pop    %rbx
ret
lea    0xe99(%rip),%rdi
lea    0xf21(%rip),%rdx
lea    0xf25(%rip),%rcx
mov    $0xf7,%esi
xor    %eax,%eax
call   1050 <_assert@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [143 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/thasenpusch/simplix/refs/heads/master/src/lib/util.c\00"
@__func__.asc_to_val = [11 x i8] c"asc_to_val\00"
@.str.1 = [22 x i8] c"!\22Invalid character!\22\00"
define zeroext i8 @asc_to_val(i8 signext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
%6 = call i32 @isdigit(i32 %5)
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %16
8: ; preds = %1
%9 = load i8, i8* %3
%10 = sext i8 %9 to i32
%11 = sub nsw i32 %10, 48
%12 = trunc i32 %11 to i8
%13 = zext i8 %12 to i32
%14 = add nsw i32 0, %13
%15 = trunc i32 %14 to i8
store i8 %15, i8* %2
br label %44
16: ; preds = %1
%17 = load i8, i8* %3
%18 = sext i8 %17 to i32
%19 = call i32 @islower(i32 %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %29
21: ; preds = %16
%22 = load i8, i8* %3
%23 = sext i8 %22 to i32
%24 = sub nsw i32 %23, 97
%25 = trunc i32 %24 to i8
%26 = zext i8 %25 to i32
%27 = add nsw i32 10, %26
%28 = trunc i32 %27 to i8
store i8 %28, i8* %2
br label %44
29: ; preds = %16
%30 = load i8, i8* %3
%31 = sext i8 %30 to i32
%32 = call i32 @isupper(i32 %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %42
34: ; preds = %29
%35 = load i8, i8* %3
%36 = sext i8 %35 to i32
%37 = sub nsw i32 %36, 65
%38 = trunc i32 %37 to i8
%39 = zext i8 %38 to i32
%40 = add nsw i32 10, %39
%41 = trunc i32 %40 to i8
store i8 %41, i8* %2
br label %44
42: ; preds = %29
%43 = call i32 (i8*, i32, i8*, i8*, ...) bitcast (i32 (...)* @_assert to i32 (i8*, i32, i8*, i8*, ...)*)(i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str, i64 0, i64 0), i32 247, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__func__.asc_to_val, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %44
44: ; preds = %42, %34, %21, %8
%45 = load i8, i8* %2
ret i8 %45
}

LLVM IR (-O2):
@.str = [143 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/thasenpusch/simplix/refs/heads/master/src/lib/util.c\00"
@__func__.asc_to_val = [11 x i8] c"asc_to_val\00"
@.str.1 = [22 x i8] c"!\22Invalid character!\22\00"
define zeroext i8 @asc_to_val(i8 signext %0) {
%2 = sext i8 %0 to i32
%3 = add nsw i32 %2, -48
%4 = icmp ult i32 %3, 10
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = add i8 %0, -48
br label %19
7: ; preds = %1
%8 = tail call i32 @islower(i32 %2)
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = add i8 %0, -87
br label %19
12: ; preds = %7
%13 = tail call i32 @isupper(i32 %2)
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = add i8 %0, -55
br label %19
17: ; preds = %12
%18 = tail call i32 (i8*, i32, i8*, i8*, ...) bitcast (i32 (...)* @_assert to i32 (i8*, i32, i8*, i8*, ...)*)(i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str, i64 0, i64 0), i32 247, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__func__.asc_to_val, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %15, %10, %5
%20 = phi i8 [ %6, %5 ], [ %11, %10 ], [ %16, %15 ], [ undef, %17 ]
ret i8 %20
}