#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*/ getNumber(char const *, int, int, unsigned long *);
scalar_t__ strncmp(char const *, char *, int);
int shortNameMatches44BSD(const char *name) {
  const char *p;
  unsigned long ul;
  if (strncmp(name, "#1/", 3) != 0)
    return -1;
  if (!(((name[3]) >= '0') && ((name[3]) <= '9')))
    return -1;
  for (p = name + 4; *p; p++) {
    if (!(((*p) >= '0') && ((*p) <= '9')))
      break;
  }
  while (*p) {
    if (*p++ != ' ')
      return -1;
  }
  if (!getNumber(name + 3, 10, -1, &ul))
    return -1;
  if (ul == 0)
    return -1;
  return ul;
}


x86 assembly (clang, -O0):
<shortNameMatches44BSD>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec9(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1157 <shortNameMatches44BSD+0x37>
movl   $0xffffffff,-0x4(%rbp)
jmp    1265 <shortNameMatches44BSD+0x145>
mov    -0x10(%rbp),%rax
movsbl 0x3(%rax),%eax
cmp    $0x30,%eax
jl     1179 <shortNameMatches44BSD+0x59>
mov    -0x10(%rbp),%rax
movsbl 0x3(%rax),%eax
cmp    $0x39,%eax
jle    1185 <shortNameMatches44BSD+0x65>
movl   $0xffffffff,-0x4(%rbp)
jmp    1265 <shortNameMatches44BSD+0x145>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11d9 <shortNameMatches44BSD+0xb9>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     11be <shortNameMatches44BSD+0x9e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jle    11c3 <shortNameMatches44BSD+0xa3>
jmp    11d9 <shortNameMatches44BSD+0xb9>
jmp    11c8 <shortNameMatches44BSD+0xa8>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1191 <shortNameMatches44BSD+0x71>
jmp    11de <shortNameMatches44BSD+0xbe>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1217 <shortNameMatches44BSD+0xf7>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%eax
cmp    $0x20,%eax
je     1212 <shortNameMatches44BSD+0xf2>
movl   $0xffffffff,-0x4(%rbp)
jmp    1265 <shortNameMatches44BSD+0x145>
jmp    11de <shortNameMatches44BSD+0xbe>
mov    -0x10(%rbp),%rdi
add    $0x3,%rdi
mov    $0xa,%esi
mov    $0xffffffff,%edx
lea    -0x20(%rbp),%rcx
call   1040 <getNumber@plt>
cmp    $0x0,%eax
jne    1247 <shortNameMatches44BSD+0x127>
movl   $0xffffffff,-0x4(%rbp)
jmp    1265 <shortNameMatches44BSD+0x145>
cmpq   $0x0,-0x20(%rbp)
jne    125e <shortNameMatches44BSD+0x13e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1265 <shortNameMatches44BSD+0x145>
mov    -0x20(%rbp),%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shortNameMatches44BSD>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xed3(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
jne    11b6 <shortNameMatches44BSD+0x96>
mov    0x3(%rbx),%al
add    $0xd0,%al
cmp    $0x9,%al
ja     11b6 <shortNameMatches44BSD+0x96>
lea    0x3(%rbx),%rdi
add    $0x4,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rbx),%eax
lea    -0x30(%rax),%ecx
add    $0x1,%rbx
cmp    $0xa,%cl
jb     1160 <shortNameMatches44BSD+0x40>
jmp    118b <shortNameMatches44BSD+0x6b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0x20,%al
jne    11b6 <shortNameMatches44BSD+0x96>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1180 <shortNameMatches44BSD+0x60>
mov    $0xffffffff,%ebp
mov    %rsp,%rcx
mov    $0xa,%esi
mov    $0xffffffff,%edx
call   1040 <getNumber@plt>
test   %eax,%eax
je     11b6 <shortNameMatches44BSD+0x96>
mov    (%rsp),%rax
cmp    $0x1,%rax
sbb    %ebp,%ebp
or     %eax,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"/\00"
define i32 @shortNameMatches44BSD(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 -1, i32* %2
br label %71
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 3
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp sge i32 %14, 48
br i1 %15, label %16, label %22
16: ; preds = %10
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 3
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp sle i32 %20, 57
br i1 %21, label %23, label %22
22: ; preds = %16, %10
store i32 -1, i32* %2
br label %71
23: ; preds = %16
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i64 4
store i8* %25, i8** %4
br label %26
26: ; preds = %42, %23
%27 = load i8*, i8** %4
%28 = load i8, i8* %27
%29 = icmp ne i8 %28, 0
br i1 %29, label %30, label %45
30: ; preds = %26
%31 = load i8*, i8** %4
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp sge i32 %33, 48
br i1 %34, label %35, label %40
35: ; preds = %30
%36 = load i8*, i8** %4
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp sle i32 %38, 57
br i1 %39, label %41, label %40
40: ; preds = %35, %30
br label %45
41: ; preds = %35
br label %42
42: ; preds = %41
%43 = load i8*, i8** %4
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %4
br label %26
45: ; preds = %40, %26
br label %46
46: ; preds = %57, %45
%47 = load i8*, i8** %4
%48 = load i8, i8* %47
%49 = icmp ne i8 %48, 0
br i1 %49, label %50, label %58
50: ; preds = %46
%51 = load i8*, i8** %4
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %4
%53 = load i8, i8* %51
%54 = sext i8 %53 to i32
%55 = icmp ne i32 %54, 32
br i1 %55, label %56, label %57
56: ; preds = %50
store i32 -1, i32* %2
br label %71
57: ; preds = %50
br label %46
58: ; preds = %46
%59 = load i8*, i8** %3
%60 = getelementptr inbounds i8, i8* %59, i64 3
%61 = call i32 @getNumber(i8* %60, i32 10, i32 -1, i64* %5)
%62 = icmp ne i32 %61, 0
br i1 %62, label %64, label %63
63: ; preds = %58
store i32 -1, i32* %2
br label %71
64: ; preds = %58
%65 = load i64, i64* %5
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %68
67: ; preds = %64
store i32 -1, i32* %2
br label %71
68: ; preds = %64
%69 = load i64, i64* %5
%70 = trunc i64 %69 to i32
store i32 %70, i32* %2
br label %71
71: ; preds = %68, %67, %63, %56, %22, %9
%72 = load i32, i32* %2
ret i32 %72
}

LLVM IR (-O2):
@.str = [4 x i8] c"/\00"
define i32 @shortNameMatches44BSD(i8* %0) {
%2 = alloca i64
%3 = bitcast i64* %2 to i8*
%4 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %37
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %0, i64 3
%8 = load i8, i8* %7
%9 = add i8 %8, -48
%10 = icmp ult i8 %9, 10
br i1 %10, label %11, label %37
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %0, i64 4
br label %13
13: ; preds = %13, %11
%14 = phi i8* [ %12, %11 ], [ %18, %13 ]
%15 = load i8, i8* %14
%16 = add i8 %15, -48
%17 = icmp ult i8 %16, 10
%18 = getelementptr inbounds i8, i8* %14, i64 1
br i1 %17, label %13, label %19
19: ; preds = %13
%20 = icmp eq i8 %15, 0
br i1 %20, label %29, label %24
21: ; preds = %24
%22 = load i8, i8* %27
%23 = icmp eq i8 %22, 0
br i1 %23, label %29, label %24
24: ; preds = %19, %21
%25 = phi i8* [ %27, %21 ], [ %14, %19 ]
%26 = phi i8 [ %22, %21 ], [ %15, %19 ]
%27 = getelementptr inbounds i8, i8* %25, i64 1
%28 = icmp eq i8 %26, 32
br i1 %28, label %21, label %37
29: ; preds = %21, %19
%30 = call i32 @getNumber(i8* %7, i32 10, i32 -1, i64* %2)
%31 = icmp eq i32 %30, 0
br i1 %31, label %37, label %32
32: ; preds = %29
%33 = load i64, i64* %2
%34 = icmp eq i64 %33, 0
%35 = trunc i64 %33 to i32
%36 = select i1 %34, i32 -1, i32 %35
br label %37
37: ; preds = %24, %32, %29, %6, %1
%38 = phi i32 [ -1, %1 ], [ -1, %6 ], [ -1, %29 ], [ %36, %32 ], [ -1, %24 ]
ret i32 %38
}