#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__ ERANGE;
long LONG_MAX;
long LONG_MIN;
scalar_t__ errno;
char *strstr(char const *, char *);
long strtol(char *, char **, int);
int /*<<< orphan*/ ui_error(char *);
short _extract_cell_id(const char *command, long int *cell) {
  char *cell_str, *endptr;
  cell_str = strstr(command, " ");
  *cell = strtol(cell_str, &endptr, 10);
  if ((errno == ERANGE && (*cell == LONG_MAX || *cell == LONG_MIN)) ||
      (errno != 0 && *cell == 0) || (*endptr != '\0' && endptr != cell_str)) {
    ui_error("Invalid cell ID value");
    return 0;
  } else if (endptr == cell_str) {
    ui_error("No cell ID found");
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<_extract_cell_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    0x2e51(%rip),%rax
mov    (%rax),%rax
mov    0x2e5f(%rip),%rcx
cmp    (%rcx),%rax
jne    11b8 <_extract_cell_id+0x88>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2e38(%rip),%rcx
cmp    (%rcx),%rax
je     11f5 <_extract_cell_id+0xc5>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2e39(%rip),%rcx
cmp    (%rcx),%rax
je     11f5 <_extract_cell_id+0xc5>
mov    0x2e09(%rip),%rax
cmpq   $0x0,(%rax)
je     11d7 <_extract_cell_id+0xa7>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     11f5 <_extract_cell_id+0xc5>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     120c <_extract_cell_id+0xdc>
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     120c <_extract_cell_id+0xdc>
lea    0xe06(%rip),%rdi
call   1040 <ui_error@plt>
movw   $0x0,-0x2(%rbp)
jmp    123c <_extract_cell_id+0x10c>
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jne    1231 <_extract_cell_id+0x101>
lea    0xdf7(%rip),%rdi
call   1040 <ui_error@plt>
movw   $0x0,-0x2(%rbp)
jmp    123c <_extract_cell_id+0x10c>
jmp    1236 <_extract_cell_id+0x106>
movw   $0x1,-0x2(%rbp)
movswl -0x2(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_extract_cell_id>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    $0x20,%esi
call   1030 <strchr@plt>
mov    %rax,%r14
mov    %rsp,%rsi
mov    %rax,%rdi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,(%rbx)
mov    0x2e6a(%rip),%rcx
mov    (%rcx),%rcx
mov    0x2e78(%rip),%rdx
cmp    (%rdx),%rcx
jne    118c <_extract_cell_id+0x5c>
mov    0x2e5c(%rip),%rdx
lea    0xe85(%rip),%rdi
cmp    (%rdx),%rax
je     119d <_extract_cell_id+0x6d>
mov    0x2e61(%rip),%rdx
cmp    (%rdx),%rax
je     119d <_extract_cell_id+0x6d>
test   %rcx,%rcx
je     11ac <_extract_cell_id+0x7c>
test   %rax,%rax
jne    11ac <_extract_cell_id+0x7c>
lea    0xe63(%rip),%rdi
call   1050 <ui_error@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    (%rsp),%rax
mov    (%rax),%cl
test   %cl,%cl
lea    0xe5b(%rip),%rdx
lea    0xe3e(%rip),%rdi
cmove  %rdx,%rdi
cmp    %r14,%rax
cmove  %rdx,%rdi
je     119d <_extract_cell_id+0x6d>
mov    $0x1,%ax
test   %cl,%cl
je     11a4 <_extract_cell_id+0x74>
jmp    119d <_extract_cell_id+0x6d>

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@errno = global i64 0
@ERANGE = global i64 0
@LONG_MAX = global i64 0
@LONG_MIN = global i64 0
@.str.1 = [22 x i8] c"Invalid cell ID value\00"
@.str.2 = [17 x i8] c"No cell ID found\00"
define signext i16 @_extract_cell_id(i8* %0, i64* %1) {
%3 = alloca i16
%4 = alloca i8*
%5 = alloca i64*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i64* %1, i64** %5
%8 = load i8*, i8** %4
%9 = call i8* @strstr(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = call i64 @strtol(i8* %10, i8** %7, i32 10)
%12 = load i64*, i64** %5
store i64 %11, i64* %12
%13 = load i64, i64* @errno
%14 = load i64, i64* @ERANGE
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %26
16: ; preds = %2
%17 = load i64*, i64** %5
%18 = load i64, i64* %17
%19 = load i64, i64* @LONG_MAX
%20 = icmp eq i64 %18, %19
br i1 %20, label %42, label %21
21: ; preds = %16
%22 = load i64*, i64** %5
%23 = load i64, i64* %22
%24 = load i64, i64* @LONG_MIN
%25 = icmp eq i64 %23, %24
br i1 %25, label %42, label %26
26: ; preds = %21, %2
%27 = load i64, i64* @errno
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i64*, i64** %5
%31 = load i64, i64* %30
%32 = icmp eq i64 %31, 0
br i1 %32, label %42, label %33
33: ; preds = %29, %26
%34 = load i8*, i8** %7
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %33
%39 = load i8*, i8** %7
%40 = load i8*, i8** %6
%41 = icmp ne i8* %39, %40
br i1 %41, label %42, label %44
42: ; preds = %38, %29, %21, %16
%43 = call i32 @ui_error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
store i16 0, i16* %3
br label %52
44: ; preds = %38, %33
%45 = load i8*, i8** %7
%46 = load i8*, i8** %6
%47 = icmp eq i8* %45, %46
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = call i32 @ui_error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i16 0, i16* %3
br label %52
50: ; preds = %44
br label %51
51: ; preds = %50
store i16 1, i16* %3
br label %52
52: ; preds = %51, %48, %42
%53 = load i16, i16* %3
ret i16 %53
}

LLVM IR (-O2):
@errno = global i64 0
@ERANGE = global i64 0
@LONG_MAX = global i64 0
@LONG_MIN = global i64 0
@.str.1 = [22 x i8] c"Invalid cell ID value\00"
@.str.2 = [17 x i8] c"No cell ID found\00"
define signext i16 @_extract_cell_id(i8* %0, i64* nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = tail call i8* @strchr(i8* dereferenceable(1) %0, i32 32)
%6 = call i64 @strtol(i8* %5, i8** %3, i32 10)
store i64 %6, i64* %1
%7 = load i64, i64* @errno
%8 = load i64, i64* @ERANGE
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i64, i64* @LONG_MAX
%12 = icmp eq i64 %6, %11
%13 = load i64, i64* @LONG_MIN
%14 = icmp eq i64 %6, %13
%15 = select i1 %12, i1 true, i1 %14
br i1 %15, label %29, label %16
16: ; preds = %10, %2
%17 = icmp ne i64 %7, 0
%18 = icmp eq i64 %6, 0
%19 = select i1 %17, i1 %18, i1 false
br i1 %19, label %29, label %20
20: ; preds = %16
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
%24 = icmp eq i8* %21, %5
%25 = or i1 %24, %23
%26 = xor i1 %23, true
%27 = or i1 %24, %26
%28 = select i1 %25, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0)
br i1 %27, label %29, label %32
29: ; preds = %20, %10, %16
%30 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), %16 ], [ %28, %20 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), %10 ]
%31 = tail call i32 @ui_error(i8* %30)
br label %32
32: ; preds = %20, %29
%33 = phi i16 [ 0, %29 ], [ 1, %20 ]
ret i16 %33
}