#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 get();
int /*<<< orphan*/ unget(int);
int read_octal_char(int c) {
  int r = c - '0';
  c = get();
  if ('0' <= c && c <= '7') {
    r = (r << 3) | (c - '0');
    c = get();
    if ('0' <= c && c <= '7')
      r = (r << 3) | (c - '0');
    else
      unget(c);
  } else {
    unget(c);
  }
  return r;
}


x86 assembly (clang, -O0):
<read_octal_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <get@plt>
mov    %eax,-0x4(%rbp)
mov    $0x30,%eax
cmp    -0x4(%rbp),%eax
jg     11ac <read_octal_char+0x8c>
cmpl   $0x37,-0x4(%rbp)
jg     11ac <read_octal_char+0x8c>
mov    -0x8(%rbp),%eax
shl    $0x3,%eax
mov    -0x4(%rbp),%ecx
sub    $0x30,%ecx
or     %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <get@plt>
mov    %eax,-0x4(%rbp)
mov    $0x30,%eax
cmp    -0x4(%rbp),%eax
jg     119f <read_octal_char+0x7f>
cmpl   $0x37,-0x4(%rbp)
jg     119f <read_octal_char+0x7f>
mov    -0x8(%rbp),%eax
shl    $0x3,%eax
mov    -0x4(%rbp),%ecx
sub    $0x30,%ecx
or     %ecx,%eax
mov    %eax,-0x8(%rbp)
jmp    11a7 <read_octal_char+0x87>
mov    -0x4(%rbp),%edi
call   1030 <unget@plt>
jmp    11b4 <read_octal_char+0x94>
mov    -0x4(%rbp),%edi
call   1030 <unget@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_octal_char>:
push   %rbx
mov    %edi,%ebx
add    $0xffffffd0,%ebx
xor    %eax,%eax
call   1040 <get@plt>
mov    %eax,%ecx
and    $0xfffffff8,%ecx
cmp    $0x30,%ecx
jne    115e <read_octal_char+0x3e>
mov    %ebx,%ecx
shl    $0x3,%ecx
add    $0xffffffd0,%eax
mov    %eax,%ebx
or     %ecx,%ebx
xor    %eax,%eax
call   1040 <get@plt>
mov    %eax,%ecx
and    $0xfffffff8,%ecx
cmp    $0x30,%ecx
jne    115e <read_octal_char+0x3e>
shl    $0x3,%ebx
add    $0xffffffd0,%eax
or     %eax,%ebx
jmp    1165 <read_octal_char+0x45>
mov    %eax,%edi
call   1030 <unget@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @read_octal_char(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = sub nsw i32 %4, 48
store i32 %5, i32* %3
%6 = call i32 (...) @get()
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp sle i32 48, %7
br i1 %8, label %9, label %34
9: ; preds = %1
%10 = load i32, i32* %2
%11 = icmp sle i32 %10, 55
br i1 %11, label %12, label %34
12: ; preds = %9
%13 = load i32, i32* %3
%14 = shl i32 %13, 3
%15 = load i32, i32* %2
%16 = sub nsw i32 %15, 48
%17 = or i32 %14, %16
store i32 %17, i32* %3
%18 = call i32 (...) @get()
store i32 %18, i32* %2
%19 = load i32, i32* %2
%20 = icmp sle i32 48, %19
br i1 %20, label %21, label %30
21: ; preds = %12
%22 = load i32, i32* %2
%23 = icmp sle i32 %22, 55
br i1 %23, label %24, label %30
24: ; preds = %21
%25 = load i32, i32* %3
%26 = shl i32 %25, 3
%27 = load i32, i32* %2
%28 = sub nsw i32 %27, 48
%29 = or i32 %26, %28
store i32 %29, i32* %3
br label %33
30: ; preds = %21, %12
%31 = load i32, i32* %2
%32 = call i32 @unget(i32 %31)
br label %33
33: ; preds = %30, %24
br label %37
34: ; preds = %9, %1
%35 = load i32, i32* %2
%36 = call i32 @unget(i32 %35)
br label %37
37: ; preds = %34, %33
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
define i32 @read_octal_char(i32 %0) {
%2 = add nsw i32 %0, -48
%3 = tail call i32 (...) @get()
%4 = and i32 %3, -8
%5 = icmp eq i32 %4, 48
br i1 %5, label %6, label %19
6: ; preds = %1
%7 = shl i32 %2, 3
%8 = add nsw i32 %3, -48
%9 = or i32 %8, %7
%10 = tail call i32 (...) @get()
%11 = and i32 %10, -8
%12 = icmp eq i32 %11, 48
br i1 %12, label %13, label %17
13: ; preds = %6
%14 = shl i32 %9, 3
%15 = add nsw i32 %10, -48
%16 = or i32 %15, %14
br label %21
17: ; preds = %6
%18 = tail call i32 @unget(i32 %10)
br label %21
19: ; preds = %1
%20 = tail call i32 @unget(i32 %3)
br label %21
21: ; preds = %13, %17, %19
%22 = phi i32 [ %16, %13 ], [ %9, %17 ], [ %2, %19 ]
ret i32 %22
}