unsigned int nextChar(unsigned char *current) {
  unsigned char result = 0;
  if (*current == 0x39)
    return 1;
  if (*current == 0x7a)
    result = 0x41;
  if (*current == 0x5a)
    result = 0x30;
  if (*current == 0)
    result = 0x61;
  if (result == 0)
    *current = *current + 1;
  else {
    *current = result;
  }
  return 0;
}


x86 assembly (clang, -O0):
<nextChar>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x39,%eax
jne    1128 <nextChar+0x28>
movl   $0x1,-0x4(%rbp)
jmp    1198 <nextChar+0x98>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x7a,%eax
jne    113c <nextChar+0x3c>
movb   $0x41,-0x11(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x5a,%eax
jne    1150 <nextChar+0x50>
movb   $0x30,-0x11(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
jne    1164 <nextChar+0x64>
movb   $0x61,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x0,%eax
jne    1188 <nextChar+0x88>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
add    $0x1,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
jmp    1191 <nextChar+0x91>
mov    -0x11(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<nextChar>:
mov    (%rdi),%al
cmp    $0x39,%al
je     110e <nextChar+0xe>
cmp    $0x7a,%al
jne    1114 <nextChar+0x14>
mov    $0x41,%cl
jmp    1116 <nextChar+0x16>
mov    $0x1,%eax
ret
xor    %ecx,%ecx
cmp    $0x5a,%al
movzbl %cl,%ecx
mov    $0x30,%edx
cmovne %ecx,%edx
test   %al,%al
mov    $0x61,%ecx
cmovne %edx,%ecx
add    $0x1,%al
test   %cl,%cl
movzbl %al,%eax
cmovne %ecx,%eax
mov    %al,(%rdi)
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @nextChar(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %3
store i8 0, i8* %4
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = icmp eq i32 %7, 57
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 1, i32* %2
br label %43
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = icmp eq i32 %13, 122
br i1 %14, label %15, label %16
15: ; preds = %10
store i8 65, i8* %4
br label %16
16: ; preds = %15, %10
%17 = load i8*, i8** %3
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = icmp eq i32 %19, 90
br i1 %20, label %21, label %22
21: ; preds = %16
store i8 48, i8* %4
br label %22
22: ; preds = %21, %16
%23 = load i8*, i8** %3
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %22
store i8 97, i8* %4
br label %28
28: ; preds = %27, %22
%29 = load i8, i8* %4
%30 = zext i8 %29 to i32
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %39
32: ; preds = %28
%33 = load i8*, i8** %3
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = add nsw i32 %35, 1
%37 = trunc i32 %36 to i8
%38 = load i8*, i8** %3
store i8 %37, i8* %38
br label %42
39: ; preds = %28
%40 = load i8, i8* %4
%41 = load i8*, i8** %3
store i8 %40, i8* %41
br label %42
42: ; preds = %39, %32
store i32 0, i32* %2
br label %43
43: ; preds = %42, %9
%44 = load i32, i32* %2
ret i32 %44
}

LLVM IR (-O2):
define i32 @nextChar(i8* nocapture %0) {
%2 = load i8, i8* %0
switch i8 %2, label %4 [
i8 57, label %13
i8 122, label %3
]
3: ; preds = %1
br label %4
4: ; preds = %1, %3
%5 = phi i8 [ 65, %3 ], [ 0, %1 ]
%6 = icmp eq i8 %2, 90
%7 = select i1 %6, i8 48, i8 %5
%8 = icmp eq i8 %2, 0
%9 = select i1 %8, i8 97, i8 %7
%10 = icmp eq i8 %9, 0
%11 = add i8 %2, 1
%12 = select i1 %10, i8 %11, i8 %9
store i8 %12, i8* %0
br label %13
13: ; preds = %1, %4
%14 = phi i32 [ 0, %4 ], [ 1, %1 ]
ret i32 %14
}