#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 Cyc_Sexp_parse_int(struct Cyc_Sexp_Parser *p) {
  unsigned _T0;
  unsigned _T1;
  unsigned _T2;
  unsigned res = 0U;
  {
    unsigned i = 0U;
  _TL67:
    if (i < 8U)
      goto _TL65;
    else {
      goto _TL66;
    }
  _TL65 : {
    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 _TL67;
  _TL66:;
  }
  _T2 = res;
  return _T2;
}


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

x86 assembly (clang, -O2):
<Cyc_Sexp_parse_int>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%rbx
call   1040 <Cyc_Sexp_pgetc@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <Cyc_Sexp_hex2value@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
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>
mov    %eax,%r14d
shl    $0x8,%r15d
shl    $0x4,%ebp
or     %r15d,%ebp
or     %ebp,%r14d
mov    %rbx,%rdi
call   1040 <Cyc_Sexp_pgetc@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <Cyc_Sexp_hex2value@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1040 <Cyc_Sexp_pgetc@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <Cyc_Sexp_hex2value@plt>
mov    %eax,%r12d
shl    $0x8,%r14d
shl    $0x4,%r15d
or     %r15d,%r12d
or     %r14d,%r12d
mov    %rbx,%rdi
call   1040 <Cyc_Sexp_pgetc@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <Cyc_Sexp_hex2value@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1040 <Cyc_Sexp_pgetc@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <Cyc_Sexp_hex2value@plt>
mov    %eax,%ebp
shl    $0x8,%r12d
shl    $0x4,%r14d
or     %r14d,%ebp
or     %r12d,%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
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.Cyc_Sexp_Parser = type { i32 }
define i32 @Cyc_Sexp_parse_int(%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 = tail call i32 @Cyc_Sexp_pgetc(%struct.Cyc_Sexp_Parser* %0)
%7 = tail call i32 @Cyc_Sexp_hex2value(%struct.Cyc_Sexp_Parser* %0, i32 %6)
%8 = shl i32 %3, 8
%9 = shl i32 %5, 4
%10 = or i32 %8, %9
%11 = or i32 %7, %10
%12 = tail call i32 @Cyc_Sexp_pgetc(%struct.Cyc_Sexp_Parser* %0)
%13 = tail call i32 @Cyc_Sexp_hex2value(%struct.Cyc_Sexp_Parser* %0, i32 %12)
%14 = tail call i32 @Cyc_Sexp_pgetc(%struct.Cyc_Sexp_Parser* %0)
%15 = tail call i32 @Cyc_Sexp_hex2value(%struct.Cyc_Sexp_Parser* %0, i32 %14)
%16 = shl i32 %11, 8
%17 = shl i32 %13, 4
%18 = or i32 %16, %17
%19 = or i32 %15, %18
%20 = tail call i32 @Cyc_Sexp_pgetc(%struct.Cyc_Sexp_Parser* %0)
%21 = tail call i32 @Cyc_Sexp_hex2value(%struct.Cyc_Sexp_Parser* %0, i32 %20)
%22 = tail call i32 @Cyc_Sexp_pgetc(%struct.Cyc_Sexp_Parser* %0)
%23 = tail call i32 @Cyc_Sexp_hex2value(%struct.Cyc_Sexp_Parser* %0, i32 %22)
%24 = shl i32 %19, 8
%25 = shl i32 %21, 4
%26 = or i32 %24, %25
%27 = or i32 %23, %26
%28 = tail call i32 @Cyc_Sexp_pgetc(%struct.Cyc_Sexp_Parser* %0)
%29 = tail call i32 @Cyc_Sexp_hex2value(%struct.Cyc_Sexp_Parser* %0, i32 %28)
%30 = shl i32 %27, 4
%31 = or i32 %29, %30
ret i32 %31
}