#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 */
scalar_t__ memcmp(char const *, char *, int);
int strlen(char const *);
long strtol(char const *, char **, int /*<<< orphan*/);
void extract_type_2_socket_inode(const char lname[], long *inode_p) {
  if (strlen(lname) < (strlen("[0000]:")) + 1)
    *inode_p = -1;
  else if (memcmp(lname, "[0000]:", (strlen("[0000]:"))))
    *inode_p = -1;
  else {
    char *serr;
    *inode_p = strtol(lname + (strlen("[0000]:")), &serr, 0);
    if (!serr || *serr || *inode_p < 0 || *inode_p > 65535)
      *inode_p = -1;
  }
}


x86 assembly (clang, -O0):
<extract_type_2_socket_inode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
lea    0xead(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1178 <extract_type_2_socket_inode+0x48>
mov    -0x10(%rbp),%rax
movq   $0xffffffffffffffff,(%rax)
jmp    1239 <extract_type_2_socket_inode+0x109>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xe79(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
lea    0xe67(%rip),%rsi
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     11b8 <extract_type_2_socket_inode+0x88>
mov    -0x10(%rbp),%rax
movq   $0xffffffffffffffff,(%rax)
jmp    1234 <extract_type_2_socket_inode+0x104>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    0xe39(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
cltq
add    %rax,%rdi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     1224 <extract_type_2_socket_inode+0xf4>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1224 <extract_type_2_socket_inode+0xf4>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jl     1224 <extract_type_2_socket_inode+0xf4>
mov    -0x10(%rbp),%rax
cmpq   $0xffff,(%rax)
jle    122f <extract_type_2_socket_inode+0xff>
mov    -0x10(%rbp),%rax
movq   $0xffffffffffffffff,(%rax)
jmp    1234 <extract_type_2_socket_inode+0x104>
jmp    1239 <extract_type_2_socket_inode+0x109>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_type_2_socket_inode>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ebp
lea    0xeb4(%rip),%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
jle    1176 <extract_type_2_socket_inode+0x46>
lea    0xea4(%rip),%rbp
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
je     1186 <extract_type_2_socket_inode+0x56>
movq   $0xffffffffffffffff,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe73(%rip),%rdi
call   1030 <strlen@plt>
cltq
add    %rax,%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %rax,(%r14)
mov    0x8(%rsp),%rcx
test   %rcx,%rcx
je     1176 <extract_type_2_socket_inode+0x46>
cmpb   $0x0,(%rcx)
jne    1176 <extract_type_2_socket_inode+0x46>
test   %rax,%rax
js     1176 <extract_type_2_socket_inode+0x46>
cmp    $0x10000,%rax
jl     117d <extract_type_2_socket_inode+0x4d>
jmp    1176 <extract_type_2_socket_inode+0x46>

LLVM IR (-O0):
@.str = [8 x i8] c"[0000]:\00"
define void @extract_type_2_socket_inode(i8* %0, i64* %1) {
%3 = alloca i8*
%4 = alloca i64*
%5 = alloca i8*
store i8* %0, i8** %3
store i64* %1, i64** %4
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
%8 = call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%9 = add nsw i32 %8, 1
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = load i64*, i64** %4
store i64 -1, i64* %12
br label %46
13: ; preds = %2
%14 = load i8*, i8** %3
%15 = call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%16 = call i64 @memcmp(i8* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = load i64*, i64** %4
store i64 -1, i64* %19
br label %45
20: ; preds = %13
%21 = load i8*, i8** %3
%22 = call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = call i64 @strtol(i8* %24, i8** %5, i32 0)
%26 = load i64*, i64** %4
store i64 %25, i64* %26
%27 = load i8*, i8** %5
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %42
29: ; preds = %20
%30 = load i8*, i8** %5
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 0
br i1 %33, label %42, label %34
34: ; preds = %29
%35 = load i64*, i64** %4
%36 = load i64, i64* %35
%37 = icmp slt i64 %36, 0
br i1 %37, label %42, label %38
38: ; preds = %34
%39 = load i64*, i64** %4
%40 = load i64, i64* %39
%41 = icmp sgt i64 %40, 65535
br i1 %41, label %42, label %44
42: ; preds = %38, %34, %29, %20
%43 = load i64*, i64** %4
store i64 -1, i64* %43
br label %44
44: ; preds = %42, %38
br label %45
45: ; preds = %44, %18
br label %46
46: ; preds = %45, %11
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"[0000]:\00"
define void @extract_type_2_socket_inode(i8* %0, i64* nocapture writeonly %1) {
%3 = alloca i8*
%4 = tail call i32 @strlen(i8* %0)
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%6 = icmp sgt i32 %4, %5
br i1 %6, label %8, label %7
7: ; preds = %2
store i64 -1, i64* %1
br label %30
8: ; preds = %2
%9 = tail call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%10 = tail call i64 @memcmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %8
store i64 -1, i64* %1
br label %30
13: ; preds = %8
%14 = bitcast i8** %3 to i8*
%15 = tail call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = call i64 @strtol(i8* %17, i8** %3, i32 0)
store i64 %18, i64* %1
%19 = load i8*, i8** %3
%20 = icmp eq i8* %19, null
br i1 %20, label %28, label %21
21: ; preds = %13
%22 = load i8, i8* %19
%23 = icmp ne i8 %22, 0
%24 = icmp slt i64 %18, 0
%25 = select i1 %23, i1 true, i1 %24
%26 = icmp sgt i64 %18, 65535
%27 = select i1 %25, i1 true, i1 %26
br i1 %27, label %28, label %29
28: ; preds = %21, %13
store i64 -1, i64* %1
br label %29
29: ; preds = %21, %28
br label %30
30: ; preds = %12, %29, %7
ret void
}