#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__ isspace(char const);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int stateMessage(char const *, int const, char *, int);
int parseDrawbarRegistration(const char *drw, unsigned int bar[],
                             const int lineNumber, const char *fileName) {
  char msg[256];
  int bus = 0;
  const char *t = drw;
  while (bus < 9) {
    if (*t == '\0') {
      sprintf(msg, "Drawbar registration incomplete '%s'", drw);
      return stateMessage(fileName, lineNumber, msg, -1);
    }
    if ((isspace(*t)) || (*t == '-') || (*t == '_')) {
      t++;
      continue;
    }
    if (('0' <= *t) && (*t <= '8')) {
      bar[bus] = *t - '0';
      t++;
      bus++;
      continue;
    } else {
      sprintf(msg, "Illegal char in drawbar registration '%c'", *t);
      return stateMessage(fileName, lineNumber, msg, -1);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<parseDrawbarRegistration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x134(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x140(%rbp)
cmpl   $0x9,-0x134(%rbp)
jge    12b8 <parseDrawbarRegistration+0x188>
mov    -0x140(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11b8 <parseDrawbarRegistration+0x88>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    -0x130(%rbp),%rdx
mov    $0xffffffff,%ecx
call   1040 <stateMessage@plt>
mov    %eax,-0x4(%rbp)
jmp    12bf <parseDrawbarRegistration+0x18f>
mov    -0x140(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
jne    11f7 <parseDrawbarRegistration+0xc7>
mov    -0x140(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     11f7 <parseDrawbarRegistration+0xc7>
mov    -0x140(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
jne    120e <parseDrawbarRegistration+0xde>
mov    -0x140(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x140(%rbp)
jmp    115f <parseDrawbarRegistration+0x2f>
mov    -0x140(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x30,%eax
cmp    %ecx,%eax
jg     1279 <parseDrawbarRegistration+0x149>
mov    -0x140(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x38,%eax
jg     1279 <parseDrawbarRegistration+0x149>
mov    -0x140(%rbp),%rax
movsbl (%rax),%edx
sub    $0x30,%edx
mov    -0x18(%rbp),%rax
movslq -0x134(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x140(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x140(%rbp)
mov    -0x134(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134(%rbp)
jmp    115f <parseDrawbarRegistration+0x2f>
lea    -0x130(%rbp),%rdi
mov    -0x140(%rbp),%rax
movsbl (%rax),%edx
lea    0xd94(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    -0x130(%rbp),%rdx
mov    $0xffffffff,%ecx
call   1040 <stateMessage@plt>
mov    %eax,-0x4(%rbp)
jmp    12bf <parseDrawbarRegistration+0x18f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseDrawbarRegistration>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rcx,%r14
mov    %edx,%r12d
mov    %rsi,0x8(%rsp)
mov    %rdi,%rbp
mov    $0x1,%r15b
xor    %r13d,%r13d
mov    %rdi,%rbx
add    $0x1,%rbx
jmp    116a <parseDrawbarRegistration+0x3a>
xchg   %ax,%ax
add    $0x1,%rbx
test   $0x1,%r15b
je     11b5 <parseDrawbarRegistration+0x85>
movzbl -0x1(%rbx),%eax
test   %al,%al
je     11b9 <parseDrawbarRegistration+0x89>
movsbl %al,%edi
call   1030 <isspace@plt>
test   %rax,%rax
jne    1160 <parseDrawbarRegistration+0x30>
movsbl -0x1(%rbx),%edx
cmp    $0x5f,%edx
je     1160 <parseDrawbarRegistration+0x30>
cmp    $0x2d,%dl
je     1160 <parseDrawbarRegistration+0x30>
lea    -0x30(%rdx),%eax
cmp    $0x8,%al
ja     11f6 <parseDrawbarRegistration+0xc6>
add    $0xffffffd0,%edx
mov    0x8(%rsp),%rax
mov    %edx,(%rax,%r13,4)
cmp    $0x8,%r13
lea    0x1(%r13),%rax
setb   %r15b
mov    %rax,%r13
cmp    $0x9,%rax
jne    1158 <parseDrawbarRegistration+0x28>
xor    %eax,%eax
jmp    11e4 <parseDrawbarRegistration+0xb4>
lea    0xe40(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <sprintf@plt>
lea    0x10(%rsp),%rdx
mov    %r14,%rdi
mov    %r12d,%esi
mov    $0xffffffff,%ecx
call   1040 <stateMessage@plt>
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe28(%rip),%rsi
lea    0x10(%rsp),%rdi
xor    %eax,%eax
call   1050 <sprintf@plt>
jmp    11cf <parseDrawbarRegistration+0x9f>

LLVM IR (-O0):
@.str = [37 x i8] c"Drawbar registration incomplete '%s'\00"
@.str.1 = [42 x i8] c"Illegal char in drawbar registration '%c'\00"
define i32 @parseDrawbarRegistration(i8* %0, i32* %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca [256 x i8]
%11 = alloca i32
%12 = alloca i8*
store i8* %0, i8** %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32 0, i32* %11
%13 = load i8*, i8** %6
store i8* %13, i8** %12
br label %14
14: ; preds = %58, %45, %4
%15 = load i32, i32* %11
%16 = icmp slt i32 %15, 9
br i1 %16, label %17, label %81
17: ; preds = %14
%18 = load i8*, i8** %12
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %30
22: ; preds = %17
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%24 = load i8*, i8** %6
%25 = call i32 (i8*, i8*, ...) @sprintf(i8* %23, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = load i8*, i8** %9
%27 = load i32, i32* %8
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%29 = call i32 @stateMessage(i8* %26, i32 %27, i8* %28, i32 -1)
store i32 %29, i32* %5
br label %82
30: ; preds = %17
%31 = load i8*, i8** %12
%32 = load i8, i8* %31
%33 = call i64 @isspace(i8 signext %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %45, label %35
35: ; preds = %30
%36 = load i8*, i8** %12
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 45
br i1 %39, label %45, label %40
40: ; preds = %35
%41 = load i8*, i8** %12
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 95
br i1 %44, label %45, label %48
45: ; preds = %40, %35, %30
%46 = load i8*, i8** %12
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %12
br label %14
48: ; preds = %40
%49 = load i8*, i8** %12
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp sle i32 48, %51
br i1 %52, label %53, label %71
53: ; preds = %48
%54 = load i8*, i8** %12
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp sle i32 %56, 56
br i1 %57, label %58, label %71
58: ; preds = %53
%59 = load i8*, i8** %12
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = sub nsw i32 %61, 48
%63 = load i32*, i32** %7
%64 = load i32, i32* %11
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i32, i32* %63, i64 %65
store i32 %62, i32* %66
%67 = load i8*, i8** %12
%68 = getelementptr inbounds i8, i8* %67, i32 1
store i8* %68, i8** %12
%69 = load i32, i32* %11
%70 = add nsw i32 %69, 1
store i32 %70, i32* %11
br label %14
71: ; preds = %53, %48
%72 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%73 = load i8*, i8** %12
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
%76 = call i32 (i8*, i8*, ...) @sprintf(i8* %72, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %75)
%77 = load i8*, i8** %9
%78 = load i32, i32* %8
%79 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%80 = call i32 @stateMessage(i8* %77, i32 %78, i8* %79, i32 -1)
store i32 %80, i32* %5
br label %82
81: ; preds = %14
store i32 0, i32* %5
br label %82
82: ; preds = %81, %71, %22
%83 = load i32, i32* %5
ret i32 %83
}

LLVM IR (-O2):
@.str = [37 x i8] c"Drawbar registration incomplete '%s'\00"
@.str.1 = [42 x i8] c"Illegal char in drawbar registration '%c'\00"
define i32 @parseDrawbarRegistration(i8* %0, i32* nocapture writeonly %1, i32 %2, i8* %3) {
%5 = alloca [256 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
br label %7
7: ; preds = %4, %28
%8 = phi i64 [ 0, %4 ], [ %32, %28 ]
%9 = phi i1 [ true, %4 ], [ %33, %28 ]
%10 = phi i8* [ %0, %4 ], [ %31, %28 ]
br label %11
11: ; preds = %7, %22
%12 = phi i8* [ %10, %7 ], [ %23, %22 ]
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %37
17: ; preds = %11
%18 = tail call i64 @isspace(i8 signext %13)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = load i8, i8* %12
switch i8 %21, label %24 [
i8 45, label %22
i8 95, label %22
]
22: ; preds = %20, %20, %17
%23 = getelementptr inbounds i8, i8* %12, i64 1
br i1 %9, label %11, label %39
24: ; preds = %20
%25 = sext i8 %21 to i32
%26 = add i8 %21, -48
%27 = icmp ult i8 %26, 9
br i1 %27, label %28, label %35
28: ; preds = %24
%29 = add nsw i32 %25, -48
%30 = getelementptr inbounds i32, i32* %1, i64 %8
store i32 %29, i32* %30
%31 = getelementptr inbounds i8, i8* %12, i64 1
%32 = add nuw nsw i64 %8, 1
%33 = icmp ult i64 %8, 8
%34 = icmp eq i64 %32, 9
br i1 %34, label %39, label %7
35: ; preds = %24
%36 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %25)
br label %37
37: ; preds = %15, %35
%38 = call i32 @stateMessage(i8* %3, i32 %2, i8* %6, i32 -1)
br label %39
39: ; preds = %28, %22, %37
%40 = phi i32 [ %38, %37 ], [ 0, %22 ], [ 0, %28 ]
ret i32 %40
}