#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__ isalpha(char);
scalar_t__ isdigit(char);
int char_order(char c) {
  if (isdigit(c))
    return 0;
  else if (isalpha(c))
    return c;
  else if (c == '\0')
    return -1;
  else if (c == '~')
    return -2;
  else
    return c + 256;
}


x86 assembly (clang, -O0):
<char_order>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     114d <char_order+0x2d>
movl   $0x0,-0x4(%rbp)
jmp    11aa <char_order+0x8a>
movsbl -0x5(%rbp),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%rax
je     116c <char_order+0x4c>
movsbl -0x5(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11aa <char_order+0x8a>
movsbl -0x5(%rbp),%eax
cmp    $0x0,%eax
jne    1185 <char_order+0x65>
movl   $0xffffffff,-0x4(%rbp)
jmp    11aa <char_order+0x8a>
movsbl -0x5(%rbp),%eax
cmp    $0x7e,%eax
jne    119e <char_order+0x7e>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11aa <char_order+0x8a>
movsbl -0x5(%rbp),%eax
add    $0x100,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<char_order>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
call   1030 <isdigit@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    1140 <char_order+0x20>
movsbl %bl,%ebp
mov    %ebp,%edi
call   1040 <isalpha@plt>
test   %rax,%rax
je     1149 <char_order+0x29>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
test   %bl,%bl
je     1159 <char_order+0x39>
cmp    $0x7e,%bl
jne    1160 <char_order+0x40>
mov    $0xfffffffe,%ebp
jmp    1140 <char_order+0x20>
mov    $0xffffffff,%ebp
jmp    1140 <char_order+0x20>
movsbl %bl,%ebp
add    $0x100,%ebp
jmp    1140 <char_order+0x20>

LLVM IR (-O0):
define i32 @char_order(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = call i64 @isdigit(i8 signext %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 0, i32* %2
br label %29
8: ; preds = %1
%9 = load i8, i8* %3
%10 = call i64 @isalpha(i8 signext %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i8, i8* %3
%14 = sext i8 %13 to i32
store i32 %14, i32* %2
br label %29
15: ; preds = %8
%16 = load i8, i8* %3
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
store i32 -1, i32* %2
br label %29
20: ; preds = %15
%21 = load i8, i8* %3
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 126
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 -2, i32* %2
br label %29
25: ; preds = %20
%26 = load i8, i8* %3
%27 = sext i8 %26 to i32
%28 = add nsw i32 %27, 256
store i32 %28, i32* %2
br label %29
29: ; preds = %25, %24, %19, %12, %7
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
define i32 @char_order(i8 signext %0) {
%2 = tail call i64 @isdigit(i8 signext %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %14
4: ; preds = %1
%5 = tail call i64 @isalpha(i8 signext %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = sext i8 %0 to i32
br label %14
9: ; preds = %4
switch i8 %0, label %11 [
i8 0, label %14
i8 126, label %10
]
10: ; preds = %9
br label %14
11: ; preds = %9
%12 = sext i8 %0 to i32
%13 = add nsw i32 %12, 256
br label %14
14: ; preds = %9, %1, %11, %10, %7
%15 = phi i32 [ %8, %7 ], [ -2, %10 ], [ %13, %11 ], [ 0, %1 ], [ -1, %9 ]
ret i32 %15
}