#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*/ eout(char *, char *);
int /*<<< orphan*/ isdigit(char);
int strlen(char *);
int validate_job_id(char *JobID) {
  int rc = 0;
  char *p = JobID;
  if (*p++ != 'F')
    rc = -1;
  while (*p != '\0' && rc == 0) {
    if (!isdigit(*p))
      rc = -1;
    p++;
  }
  if (strlen(JobID) > 20)
    rc = -1;
  if (rc < 0)
    eout("invalid JobID: '%s'\n", JobID);
  return rc;
}


x86 assembly (clang, -O0):
<validate_job_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%eax
cmp    $0x46,%eax
je     116d <validate_job_id+0x3d>
movl   $0xffffffff,-0xc(%rbp)
jmp    1172 <validate_job_id+0x42>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     1191 <validate_job_id+0x61>
cmpl   $0x0,-0xc(%rbp)
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11a1 <validate_job_id+0x71>
jmp    11ce <validate_job_id+0x9e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11bd <validate_job_id+0x8d>
movl   $0xffffffff,-0xc(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1172 <validate_job_id+0x42>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x14,%eax
jle    11e7 <validate_job_id+0xb7>
movl   $0xffffffff,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1201 <validate_job_id+0xd1>
mov    -0x8(%rbp),%rsi
lea    0xe04(%rip),%rdi
call   1050 <eout@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validate_job_id>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
cmpb   $0x46,(%rdi)
setne  %bpl
jne    116b <validate_job_id+0x3b>
mov    0x1(%r14),%al
test   %al,%al
je     116b <validate_job_id+0x3b>
lea    0x2(%r14),%rbx
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
sete   %bpl
je     116b <validate_job_id+0x3b>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1150 <validate_job_id+0x20>
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    $0x15,%eax
setge  %bl
or     %bpl,%bl
cmp    $0x1,%bl
jne    1190 <validate_job_id+0x60>
lea    0xe78(%rip),%rdi
mov    %r14,%rsi
call   1050 <eout@plt>
movzbl %bl,%eax
neg    %eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"invalid JobID: '%s'\0A\00"
define i32 @validate_job_id(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %3
%5 = load i8*, i8** %2
store i8* %5, i8** %4
%6 = load i8*, i8** %4
%7 = getelementptr inbounds i8, i8* %6, i32 1
store i8* %7, i8** %4
%8 = load i8, i8* %6
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 70
br i1 %10, label %11, label %12
11: ; preds = %1
store i32 -1, i32* %3
br label %12
12: ; preds = %11, %1
br label %13
13: ; preds = %29, %12
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i32, i32* %3
%20 = icmp eq i32 %19, 0
br label %21
21: ; preds = %18, %13
%22 = phi i1 [ false, %13 ], [ %20, %18 ]
br i1 %22, label %23, label %32
23: ; preds = %21
%24 = load i8*, i8** %4
%25 = load i8, i8* %24
%26 = call i32 @isdigit(i8 signext %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %29, label %28
28: ; preds = %23
store i32 -1, i32* %3
br label %29
29: ; preds = %28, %23
%30 = load i8*, i8** %4
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %4
br label %13
32: ; preds = %21
%33 = load i8*, i8** %2
%34 = call i32 @strlen(i8* %33)
%35 = icmp sgt i32 %34, 20
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 -1, i32* %3
br label %37
37: ; preds = %36, %32
%38 = load i32, i32* %3
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %37
%41 = load i8*, i8** %2
%42 = call i32 @eout(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %40, %37
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@.str = [21 x i8] c"invalid JobID: '%s'\0A\00"
define i32 @validate_job_id(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp ne i8 %2, 70
%4 = getelementptr inbounds i8, i8* %0, i64 1
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 0
%7 = or i1 %3, %6
br i1 %7, label %17, label %8
8: ; preds = %1, %8
%9 = phi i8 [ %14, %8 ], [ %5, %1 ]
%10 = phi i8* [ %13, %8 ], [ %4, %1 ]
%11 = tail call i32 @isdigit(i8 signext %9)
%12 = icmp eq i32 %11, 0
%13 = getelementptr inbounds i8, i8* %10, i64 1
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
%16 = or i1 %12, %15
br i1 %16, label %17, label %8
17: ; preds = %8, %1
%18 = phi i1 [ %3, %1 ], [ %12, %8 ]
%19 = tail call i32 @strlen(i8* %0)
%20 = icmp sgt i32 %19, 20
%21 = select i1 %20, i1 true, i1 %18
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = tail call i32 @eout(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %24
24: ; preds = %22, %17
%25 = sext i1 %21 to i32
ret i32 %25
}