#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 /*<<< orphan*/ syntax(char *, char *);
int parse_octave(char *p) {
  int oct;
  if (p) {
    oct = 1;
    if (*p == '-') {
      oct = -1;
      p++;
    }
    if (*p >= '0' && *p <= '4')
      return oct * (*p - '0');
    syntax("Bad octave value", p);
  }
  return 10;
}


x86 assembly (clang, -O0):
<parse_octave>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1199 <parse_octave+0x89>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1151 <parse_octave+0x41>
movl   $0xffffffff,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     1189 <parse_octave+0x79>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x34,%eax
jg     1189 <parse_octave+0x79>
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
movsbl (%rcx),%ecx
sub    $0x30,%ecx
imul   %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11a0 <parse_octave+0x90>
mov    -0x10(%rbp),%rsi
lea    0xe6c(%rip),%rdi
call   1030 <syntax@plt>
movl   $0xa,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_octave>:
push   %rbx
mov    $0xa,%ebx
test   %rdi,%rdi
je     1156 <parse_octave+0x46>
mov    %rdi,%rsi
mov    (%rdi),%al
xor    %edx,%edx
cmp    $0x2d,%al
sete   %dl
movzbl (%rdi,%rdx,1),%ecx
lea    -0x30(%rcx),%edi
cmp    $0x4,%dil
ja     1147 <parse_octave+0x37>
mov    $0x30,%edx
sub    %ecx,%edx
add    $0xffffffd0,%ecx
cmp    $0x2d,%al
cmove  %edx,%ecx
mov    %ecx,%ebx
jmp    1156 <parse_octave+0x46>
add    %rdx,%rsi
lea    0xeaf(%rip),%rdi
call   1030 <syntax@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Bad octave value\00"
define i32 @parse_octave(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %35
7: ; preds = %1
store i32 1, i32* %4
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 45
br i1 %11, label %12, label %15
12: ; preds = %7
store i32 -1, i32* %4
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %3
br label %15
15: ; preds = %12, %7
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp sge i32 %18, 48
br i1 %19, label %20, label %32
20: ; preds = %15
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp sle i32 %23, 52
br i1 %24, label %25, label %32
25: ; preds = %20
%26 = load i32, i32* %4
%27 = load i8*, i8** %3
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = sub nsw i32 %29, 48
%31 = mul nsw i32 %26, %30
store i32 %31, i32* %2
br label %36
32: ; preds = %20, %15
%33 = load i8*, i8** %3
%34 = call i32 @syntax(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %32, %1
store i32 10, i32* %2
br label %36
36: ; preds = %35, %25
%37 = load i32, i32* %2
ret i32 %37
}

LLVM IR (-O2):
@.str = [17 x i8] c"Bad octave value\00"
define i32 @parse_octave(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %18, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 45
%6 = zext i1 %5 to i64
%7 = getelementptr i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = add i8 %8, -48
%10 = icmp ult i8 %9, 5
br i1 %10, label %11, label %16
11: ; preds = %3
%12 = zext i8 %8 to i32
%13 = add nsw i32 %12, -48
%14 = sub nsw i32 48, %12
%15 = select i1 %5, i32 %14, i32 %13
br label %18
16: ; preds = %3
%17 = tail call i32 @syntax(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %18
18: ; preds = %1, %16, %11
%19 = phi i32 [ %15, %11 ], [ 10, %16 ], [ 10, %1 ]
ret i32 %19
}