#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 */
int vmemAllocString(char *, int);
int /*<<< orphan*/ vmemPush(int);
void sysCtoh(int c) {
  unsigned char res[2];
  int v = (c >> 4) & 15;
  res[0] = (v < 10) ? '0' + v : 'a' + v - 10;
  v = c & 15;
  res[1] = (v < 10) ? '0' + v : 'a' + v - 10;
  vmemPush((1 + ((vmemAllocString((char *)res, 2)) << 1)));
}


x86 assembly (clang, -O0):
<sysCtoh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x4,%eax
and    $0xf,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    114f <sysCtoh+0x2f>
mov    -0xc(%rbp),%eax
add    $0x30,%eax
mov    %eax,-0x10(%rbp)
jmp    115b <sysCtoh+0x3b>
mov    -0xc(%rbp),%eax
add    $0x61,%eax
sub    $0xa,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %al,-0x6(%rbp)
mov    -0x4(%rbp),%eax
and    $0xf,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    1182 <sysCtoh+0x62>
mov    -0xc(%rbp),%eax
add    $0x30,%eax
mov    %eax,-0x14(%rbp)
jmp    118e <sysCtoh+0x6e>
mov    -0xc(%rbp),%eax
add    $0x61,%eax
sub    $0xa,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %al,-0x5(%rbp)
lea    -0x6(%rbp),%rdi
mov    $0x2,%esi
call   1030 <vmemAllocString@plt>
mov    %eax,%edi
shl    $0x1,%edi
add    $0x1,%edi
call   1040 <vmemPush@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sysCtoh>:
push   %rax
mov    %edi,%eax
shr    $0x4,%eax
and    $0xf,%eax
lea    0x57(%rax),%ecx
lea    0x30(%rax),%edx
cmp    $0xa,%eax
movzbl %dl,%eax
movzbl %cl,%ecx
cmovb  %eax,%ecx
mov    %cl,0x6(%rsp)
and    $0xf,%edi
lea    0x57(%rdi),%eax
lea    0x30(%rdi),%ecx
cmp    $0xa,%edi
movzbl %cl,%ecx
movzbl %al,%eax
cmovb  %ecx,%eax
mov    %al,0x7(%rsp)
lea    0x6(%rsp),%rdi
mov    $0x2,%esi
call   1030 <vmemAllocString@plt>
lea    (%rax,%rax,1),%edi
add    $0x1,%edi
call   1040 <vmemPush@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @sysCtoh(i32 %0) {
%2 = alloca i32
%3 = alloca [2 x i8]
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = ashr i32 %5, 4
%7 = and i32 %6, 15
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i32, i32* %4
%12 = add nsw i32 48, %11
br label %17
13: ; preds = %1
%14 = load i32, i32* %4
%15 = add nsw i32 97, %14
%16 = sub nsw i32 %15, 10
br label %17
17: ; preds = %13, %10
%18 = phi i32 [ %12, %10 ], [ %16, %13 ]
%19 = trunc i32 %18 to i8
%20 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
store i8 %19, i8* %20
%21 = load i32, i32* %2
%22 = and i32 %21, 15
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 10
br i1 %24, label %25, label %28
25: ; preds = %17
%26 = load i32, i32* %4
%27 = add nsw i32 48, %26
br label %32
28: ; preds = %17
%29 = load i32, i32* %4
%30 = add nsw i32 97, %29
%31 = sub nsw i32 %30, 10
br label %32
32: ; preds = %28, %25
%33 = phi i32 [ %27, %25 ], [ %31, %28 ]
%34 = trunc i32 %33 to i8
%35 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 1
store i8 %34, i8* %35
%36 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%37 = call i32 @vmemAllocString(i8* %36, i32 2)
%38 = shl i32 %37, 1
%39 = add nsw i32 1, %38
%40 = call i32 @vmemPush(i32 %39)
ret void
}

LLVM IR (-O2):
define void @sysCtoh(i32 %0) {
%2 = alloca [2 x i8]
%3 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%4 = lshr i32 %0, 4
%5 = and i32 %4, 15
%6 = icmp ult i32 %5, 10
%7 = or i32 %5, 48
%8 = add nuw nsw i32 %5, 87
%9 = select i1 %6, i32 %7, i32 %8
%10 = trunc i32 %9 to i8
store i8 %10, i8* %3
%11 = and i32 %0, 15
%12 = icmp ult i32 %11, 10
%13 = or i32 %11, 48
%14 = add nuw nsw i32 %11, 87
%15 = select i1 %12, i32 %13, i32 %14
%16 = trunc i32 %15 to i8
%17 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
store i8 %16, i8* %17
%18 = call i32 @vmemAllocString(i8* %3, i32 2)
%19 = shl i32 %18, 1
%20 = or i32 %19, 1
%21 = call i32 @vmemPush(i32 %20)
ret void
}