#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 */
struct Cyc_Sexp_Parser {
  int dummy;
};

/* Variables and functions */
unsigned int Cyc_Sexp_hex2value(struct Cyc_Sexp_Parser *, int);
int Cyc_Sexp_pgetc(struct Cyc_Sexp_Parser *);
unsigned char Cyc_Sexp_parse_char(struct Cyc_Sexp_Parser *p) {
  unsigned _T0;
  unsigned _T1;
  unsigned _T2;
  unsigned char _T3;
  unsigned res = 0U;
  {
    unsigned i = 0U;
  _TL6F:
    if (i < 2U)
      goto _TL6D;
    else {
      goto _TL6E;
    }
  _TL6D : {
    int ch = Cyc_Sexp_pgetc(p);
    unsigned v = Cyc_Sexp_hex2value(p, ch);
    _T0 = res << 4;
    _T1 = v;
    res = _T0 | _T1;
  }
    i = i + 1;
    goto _TL6F;
  _TL6E:;
  }
  _T2 = res;
  _T3 = (unsigned char)_T2;
  return _T3;
}


x86 assembly (clang, -O0):
<Cyc_Sexp_parse_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x20(%rbp)
jae    1149 <Cyc_Sexp_parse_char+0x29>
jmp    114e <Cyc_Sexp_parse_char+0x2e>
jmp    118f <Cyc_Sexp_parse_char+0x6f>
mov    -0x8(%rbp),%rdi
call   1040 <Cyc_Sexp_pgetc@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1030 <Cyc_Sexp_hex2value@plt>
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0xc(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113a <Cyc_Sexp_parse_char+0x1a>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %al,-0x15(%rbp)
movzbl -0x15(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Cyc_Sexp_parse_char>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <Cyc_Sexp_pgetc@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <Cyc_Sexp_hex2value@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <Cyc_Sexp_pgetc@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <Cyc_Sexp_hex2value@plt>
shl    $0x4,%ebp
or     %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.Cyc_Sexp_Parser = type { i32 }
define zeroext i8 @Cyc_Sexp_parse_char(%struct.Cyc_Sexp_Parser* %0) {
%2 = alloca %struct.Cyc_Sexp_Parser*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store %struct.Cyc_Sexp_Parser* %0, %struct.Cyc_Sexp_Parser** %2
store i32 0, i32* %7
store i32 0, i32* %8
br label %11
11: ; preds = %16, %1
%12 = load i32, i32* %8
%13 = icmp ult i32 %12, 2
br i1 %13, label %14, label %15
14: ; preds = %11
br label %16
15: ; preds = %11
br label %30
16: ; preds = %14
%17 = load %struct.Cyc_Sexp_Parser*, %struct.Cyc_Sexp_Parser** %2
%18 = call i32 @Cyc_Sexp_pgetc(%struct.Cyc_Sexp_Parser* %17)
store i32 %18, i32* %9
%19 = load %struct.Cyc_Sexp_Parser*, %struct.Cyc_Sexp_Parser** %2
%20 = load i32, i32* %9
%21 = call i32 @Cyc_Sexp_hex2value(%struct.Cyc_Sexp_Parser* %19, i32 %20)
store i32 %21, i32* %10
%22 = load i32, i32* %7
%23 = shl i32 %22, 4
store i32 %23, i32* %3
%24 = load i32, i32* %10
store i32 %24, i32* %4
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = or i32 %25, %26
store i32 %27, i32* %7
%28 = load i32, i32* %8
%29 = add i32 %28, 1
store i32 %29, i32* %8
br label %11
30: ; preds = %15
%31 = load i32, i32* %7
store i32 %31, i32* %5
%32 = load i32, i32* %5
%33 = trunc i32 %32 to i8
store i8 %33, i8* %6
%34 = load i8, i8* %6
ret i8 %34
}

LLVM IR (-O2):
%struct.Cyc_Sexp_Parser = type { i32 }
define zeroext i8 @Cyc_Sexp_parse_char(%struct.Cyc_Sexp_Parser* %0) {
%2 = tail call i32 @Cyc_Sexp_pgetc(%struct.Cyc_Sexp_Parser* %0)
%3 = tail call i32 @Cyc_Sexp_hex2value(%struct.Cyc_Sexp_Parser* %0, i32 %2)
%4 = tail call i32 @Cyc_Sexp_pgetc(%struct.Cyc_Sexp_Parser* %0)
%5 = tail call i32 @Cyc_Sexp_hex2value(%struct.Cyc_Sexp_Parser* %0, i32 %4)
%6 = shl i32 %3, 4
%7 = or i32 %5, %6
%8 = trunc i32 %7 to i8
ret i8 %8
}