#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 atoi(char const *);
scalar_t__ isdigit(char const);
int strlen(char const *);
int /*<<< orphan*/ strncmp(char const *, char *, int);
int parse_function_n(const char *p) {
  int v = -9999;
  if (strlen(p) > 2 && !strncmp(p, "FN", 2)) {
    p += 2;
    if (isdigit(*p)) {
      v = atoi(p);
      if (v < 1 || v > 8)
        v = -9999;
    }
  }
  return v;
}


x86 assembly (clang, -O0):
<parse_function_n>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xffffd8f1,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x2,%eax
jle    11d6 <parse_function_n+0x96>
mov    -0x8(%rbp),%rdi
lea    0xe90(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11d6 <parse_function_n+0x96>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
je     11d1 <parse_function_n+0x91>
mov    -0x8(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jl     11c5 <parse_function_n+0x85>
cmpl   $0x8,-0xc(%rbp)
jle    11cc <parse_function_n+0x8c>
movl   $0xffffd8f1,-0xc(%rbp)
jmp    11d1 <parse_function_n+0x91>
jmp    11d6 <parse_function_n+0x96>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_function_n>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <strlen@plt>
mov    $0xffffd8f1,%ebp
cmp    $0x3,%eax
jl     1195 <parse_function_n+0x55>
lea    0xea4(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    1195 <parse_function_n+0x55>
movsbl 0x2(%rbx),%edi
call   1040 <isdigit@plt>
test   %rax,%rax
je     1195 <parse_function_n+0x55>
add    $0x2,%rbx
mov    %rbx,%rdi
call   1060 <atoi@plt>
lea    -0x9(%rax),%ecx
cmp    $0xfffffff8,%ecx
mov    $0xffffd8f1,%ebp
cmovae %eax,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"FN\00"
define i32 @parse_function_n(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 -9999, i32* %3
%4 = load i8*, i8** %2
%5 = call i32 @strlen(i8* %4)
%6 = icmp sgt i32 %5, 2
br i1 %6, label %7, label %29
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = call i32 @strncmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%10 = icmp ne i32 %9, 0
br i1 %10, label %29, label %11
11: ; preds = %7
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i64 2
store i8* %13, i8** %2
%14 = load i8*, i8** %2
%15 = load i8, i8* %14
%16 = call i64 @isdigit(i8 signext %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %11
%19 = load i8*, i8** %2
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = icmp slt i32 %21, 1
br i1 %22, label %26, label %23
23: ; preds = %18
%24 = load i32, i32* %3
%25 = icmp sgt i32 %24, 8
br i1 %25, label %26, label %27
26: ; preds = %23, %18
store i32 -9999, i32* %3
br label %27
27: ; preds = %26, %23
br label %28
28: ; preds = %27, %11
br label %29
29: ; preds = %28, %7, %1
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@.str = [3 x i8] c"FN\00"
define i32 @parse_function_n(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 2
br i1 %3, label %4, label %17
4: ; preds = %1
%5 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %17
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %0, i64 2
%9 = load i8, i8* %8
%10 = tail call i64 @isdigit(i8 signext %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %7
%13 = tail call i32 @atoi(i8* %8)
%14 = add i32 %13, -9
%15 = icmp ult i32 %14, -8
%16 = select i1 %15, i32 -9999, i32 %13
br label %17
17: ; preds = %12, %7, %4, %1
%18 = phi i32 [ -9999, %4 ], [ %16, %12 ], [ -9999, %7 ], [ -9999, %1 ]
ret i32 %18
}