#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 */
unsigned char strtol(char *, int /*<<< orphan*/ *, int);
unsigned char get_value(char *s) {
  if (s[0] == '$') {
    return strtol(&s[1], NULL, 16);
  } else if (s[0] == '%') {
    return strtol(&s[1], NULL, 2);
  }
  return strtol(s, NULL, 0);
}


x86 assembly (clang, -O0):
<get_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x24,%eax
jne    114a <get_value+0x3a>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %al,-0x1(%rbp)
jmp    118f <get_value+0x7f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
jne    1178 <get_value+0x68>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x2,%edx
call   1030 <strtol@plt>
mov    %al,-0x1(%rbp)
jmp    118f <get_value+0x7f>
jmp    117d <get_value+0x6d>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_value>:
mov    (%rdi),%al
cmp    $0x25,%al
je     112a <get_value+0x1a>
cmp    $0x24,%al
jne    113a <get_value+0x2a>
add    $0x1,%rdi
xor    %esi,%esi
mov    $0x10,%edx
jmp    1030 <strtol@plt>
add    $0x1,%rdi
xor    %esi,%esi
mov    $0x2,%edx
jmp    1030 <strtol@plt>
xor    %esi,%esi
xor    %edx,%edx
jmp    1030 <strtol@plt>

LLVM IR (-O0):
define zeroext i8 @get_value(i8* %0) {
%2 = alloca i8
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8, i8* %4, i64 0
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 36
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = call zeroext i8 @strtol(i8* %11, i32* null, i32 16)
store i8 %12, i8* %2
br label %27
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 37
br i1 %18, label %19, label %23
19: ; preds = %13
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = call zeroext i8 @strtol(i8* %21, i32* null, i32 2)
store i8 %22, i8* %2
br label %27
23: ; preds = %13
br label %24
24: ; preds = %23
%25 = load i8*, i8** %3
%26 = call zeroext i8 @strtol(i8* %25, i32* null, i32 0)
store i8 %26, i8* %2
br label %27
27: ; preds = %24, %19, %9
%28 = load i8, i8* %2
ret i8 %28
}

LLVM IR (-O2):
define zeroext i8 @get_value(i8* nocapture %0) {
%2 = load i8, i8* %0
switch i8 %2, label %9 [
i8 36, label %3
i8 37, label %6
]
3: ; preds = %1
%4 = getelementptr inbounds i8, i8* %0, i64 1
%5 = tail call zeroext i8 @strtol(i8* nocapture %4, i32* null, i32 16)
br label %11
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = tail call zeroext i8 @strtol(i8* nocapture %7, i32* null, i32 2)
br label %11
9: ; preds = %1
%10 = tail call zeroext i8 @strtol(i8* nocapture %0, i32* null, i32 0)
br label %11
11: ; preds = %9, %6, %3
%12 = phi i8 [ %5, %3 ], [ %8, %6 ], [ %10, %9 ]
ret i8 %12
}