#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 scanc();
int /*<<< orphan*/ unscanc(int);
int /*<<< orphan*/ yyerror(char *);
int scan_oct_byte(void) {
  int c1, c2, c3;
  int b;
  b = 0;
  c1 = scanc();
  if (!((c1 >= '0') && (c1 <= '7'))) {
    yyerror("malformed octal digit");
    return (0);
  }
  b = c1 - '0';
  c2 = scanc();
  if (!((c2 >= '0') && (c2 <= '7'))) {
    yyerror("malformed octal digit");
    return (0);
  }
  b *= 8;
  b += (c2 - '0');
  c3 = scanc();
  if (!((c3 >= '0') && (c3 <= '7'))) {
    unscanc(c3);
  } else {
    b *= 8;
    b += (c3 - '0');
  }
  return (b);
}


x86 assembly (clang, -O0):
<scan_oct_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1050 <scanc@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x30,-0x8(%rbp)
jl     115d <scan_oct_byte+0x2d>
cmpl   $0x37,-0x8(%rbp)
jle    1175 <scan_oct_byte+0x45>
lea    0xe9c(%rip),%rdi
call   1030 <yyerror@plt>
movl   $0x0,-0x4(%rbp)
jmp    120f <scan_oct_byte+0xdf>
mov    -0x8(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1050 <scanc@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x30,-0xc(%rbp)
jl     119c <scan_oct_byte+0x6c>
cmpl   $0x37,-0xc(%rbp)
jle    11b4 <scan_oct_byte+0x84>
lea    0xe5d(%rip),%rdi
call   1030 <yyerror@plt>
movl   $0x0,-0x4(%rbp)
jmp    120f <scan_oct_byte+0xdf>
mov    -0x14(%rbp),%eax
shl    $0x3,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x30,%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1050 <scanc@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x30,-0x10(%rbp)
jl     11e7 <scan_oct_byte+0xb7>
cmpl   $0x37,-0x10(%rbp)
jle    11f4 <scan_oct_byte+0xc4>
mov    -0x10(%rbp),%edi
call   1040 <unscanc@plt>
jmp    1209 <scan_oct_byte+0xd9>
mov    -0x14(%rbp),%eax
shl    $0x3,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x30,%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan_oct_byte>:
push   %r14
push   %rbx
push   %rax
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <scanc@plt>
mov    %eax,%ebx
and    $0xfffffff8,%eax
cmp    $0x30,%eax
jne    1182 <scan_oct_byte+0x52>
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <scanc@plt>
mov    %eax,%ecx
and    $0xfffffff8,%ecx
cmp    $0x30,%ecx
jne    1182 <scan_oct_byte+0x52>
lea    (%rax,%rbx,8),%r14d
add    $0xfffffe50,%r14d
xor    %eax,%eax
call   1050 <scanc@plt>
mov    %eax,%ecx
and    $0xfffffff8,%ecx
cmp    $0x30,%ecx
jne    1199 <scan_oct_byte+0x69>
lea    (%rax,%r14,8),%r14d
add    $0xffffffd0,%r14d
jmp    118e <scan_oct_byte+0x5e>
lea    0xe77(%rip),%rdi
call   1030 <yyerror@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %eax,%edi
call   1040 <unscanc@plt>
jmp    118e <scan_oct_byte+0x5e>

LLVM IR (-O0):
@.str = [22 x i8] c"malformed octal digit\00"
define i32 @scan_oct_byte() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %5
%6 = call i32 (...) @scanc()
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp sge i32 %7, 48
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp sle i32 %10, 55
br i1 %11, label %14, label %12
12: ; preds = %9, %0
%13 = call i32 @yyerror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %50
14: ; preds = %9
%15 = load i32, i32* %2
%16 = sub nsw i32 %15, 48
store i32 %16, i32* %5
%17 = call i32 (...) @scanc()
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = icmp sge i32 %18, 48
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load i32, i32* %3
%22 = icmp sle i32 %21, 55
br i1 %22, label %25, label %23
23: ; preds = %20, %14
%24 = call i32 @yyerror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %50
25: ; preds = %20
%26 = load i32, i32* %5
%27 = mul nsw i32 %26, 8
store i32 %27, i32* %5
%28 = load i32, i32* %3
%29 = sub nsw i32 %28, 48
%30 = load i32, i32* %5
%31 = add nsw i32 %30, %29
store i32 %31, i32* %5
%32 = call i32 (...) @scanc()
store i32 %32, i32* %4
%33 = load i32, i32* %4
%34 = icmp sge i32 %33, 48
br i1 %34, label %35, label %38
35: ; preds = %25
%36 = load i32, i32* %4
%37 = icmp sle i32 %36, 55
br i1 %37, label %41, label %38
38: ; preds = %35, %25
%39 = load i32, i32* %4
%40 = call i32 @unscanc(i32 %39)
br label %48
41: ; preds = %35
%42 = load i32, i32* %5
%43 = mul nsw i32 %42, 8
store i32 %43, i32* %5
%44 = load i32, i32* %4
%45 = sub nsw i32 %44, 48
%46 = load i32, i32* %5
%47 = add nsw i32 %46, %45
store i32 %47, i32* %5
br label %48
48: ; preds = %41, %38
%49 = load i32, i32* %5
store i32 %49, i32* %1
br label %50
50: ; preds = %48, %23, %12
%51 = load i32, i32* %1
ret i32 %51
}

LLVM IR (-O2):
@.str = [22 x i8] c"malformed octal digit\00"
define i32 @scan_oct_byte() {
%1 = tail call i32 (...) @scanc()
%2 = and i32 %1, -8
%3 = icmp eq i32 %2, 48
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = tail call i32 @yyerror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %25
6: ; preds = %0
%7 = tail call i32 (...) @scanc()
%8 = and i32 %7, -8
%9 = icmp eq i32 %8, 48
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = tail call i32 @yyerror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %25
12: ; preds = %6
%13 = shl nuw nsw i32 %1, 3
%14 = add nsw i32 %13, -432
%15 = add nsw i32 %14, %7
%16 = tail call i32 (...) @scanc()
%17 = and i32 %16, -8
%18 = icmp eq i32 %17, 48
br i1 %18, label %21, label %19
19: ; preds = %12
%20 = tail call i32 @unscanc(i32 %16)
br label %25
21: ; preds = %12
%22 = shl nuw nsw i32 %15, 3
%23 = add nsw i32 %22, -48
%24 = add nsw i32 %23, %16
br label %25
25: ; preds = %19, %21, %10, %4
%26 = phi i32 [ 0, %10 ], [ 0, %4 ], [ %24, %21 ], [ %15, %19 ]
ret i32 %26
}