#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 */
typedef int int32_t;

/* Variables and functions */
int funge_stack_push(int /*<<< orphan*/, int *);
int /*<<< orphan*/ funge_thread_stack();
int32_t funge_stack_push_digit(int32_t funge_char) {
  int32_t val;
  int32_t rc;
  if (funge_char >= 0x30 && funge_char <= 0x39) {
    val = funge_char - 0x30;
  } else if (funge_char >= 0x61 && funge_char <= 0x66) {
    val = funge_char - 0x61 + 0xa;
  } else {
    return 1;
  }
  rc = funge_stack_push(funge_thread_stack(), &val);
  return rc;
}


x86 assembly (clang, -O0):
<funge_stack_push_digit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x30,-0x8(%rbp)
jl     114d <funge_stack_push_digit+0x2d>
cmpl   $0x39,-0x8(%rbp)
jg     114d <funge_stack_push_digit+0x2d>
mov    -0x8(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0xc(%rbp)
jmp    1183 <funge_stack_push_digit+0x63>
cmpl   $0x61,-0x8(%rbp)
jl     1172 <funge_stack_push_digit+0x52>
cmpl   $0x66,-0x8(%rbp)
jg     1172 <funge_stack_push_digit+0x52>
mov    -0x8(%rbp),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %eax,-0xc(%rbp)
jmp    117e <funge_stack_push_digit+0x5e>
movl   $0x1,-0x4(%rbp)
jmp    119e <funge_stack_push_digit+0x7e>
jmp    1183 <funge_stack_push_digit+0x63>
mov    $0x0,%al
call   1040 <funge_thread_stack@plt>
mov    %eax,%edi
lea    -0xc(%rbp),%rsi
call   1030 <funge_stack_push@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<funge_stack_push_digit>:
lea    -0x30(%rdi),%eax
cmp    $0xa,%eax
jb     113a <funge_stack_push_digit+0x1a>
lea    -0x61(%rdi),%ecx
mov    $0x1,%eax
cmp    $0x5,%ecx
ja     1156 <funge_stack_push_digit+0x36>
add    $0xffffffa9,%edi
mov    %edi,%eax
push   %rax
mov    %eax,0x4(%rsp)
xor    %eax,%eax
call   1040 <funge_thread_stack@plt>
lea    0x4(%rsp),%rsi
mov    %eax,%edi
call   1030 <funge_stack_push@plt>
add    $0x8,%rsp
ret

LLVM IR (-O0):
define i32 @funge_stack_push_digit(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = icmp sge i32 %6, 48
br i1 %7, label %8, label %14
8: ; preds = %1
%9 = load i32, i32* %3
%10 = icmp sle i32 %9, 57
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i32, i32* %3
%13 = sub nsw i32 %12, 48
store i32 %13, i32* %4
br label %26
14: ; preds = %8, %1
%15 = load i32, i32* %3
%16 = icmp sge i32 %15, 97
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load i32, i32* %3
%19 = icmp sle i32 %18, 102
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i32, i32* %3
%22 = sub nsw i32 %21, 97
%23 = add nsw i32 %22, 10
store i32 %23, i32* %4
br label %25
24: ; preds = %17, %14
store i32 1, i32* %2
br label %30
25: ; preds = %20
br label %26
26: ; preds = %25, %11
%27 = call i32 (...) @funge_thread_stack()
%28 = call i32 @funge_stack_push(i32 %27, i32* %4)
store i32 %28, i32* %5
%29 = load i32, i32* %5
store i32 %29, i32* %2
br label %30
30: ; preds = %26, %24
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
define i32 @funge_stack_push_digit(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = add i32 %0, -48
%5 = icmp ult i32 %4, 10
br i1 %5, label %11, label %6
6: ; preds = %1
%7 = add i32 %0, -97
%8 = icmp ult i32 %7, 6
br i1 %8, label %9, label %15
9: ; preds = %6
%10 = add nsw i32 %0, -87
br label %11
11: ; preds = %1, %9
%12 = phi i32 [ %10, %9 ], [ %4, %1 ]
store i32 %12, i32* %2
%13 = tail call i32 (...) @funge_thread_stack()
%14 = call i32 @funge_stack_push(i32 %13, i32* %2)
br label %15
15: ; preds = %6, %11
%16 = phi i32 [ %14, %11 ], [ 1, %6 ]
ret i32 %16
}