#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*/ DebugPrintf(int, char *, char const *);
int /*<<< orphan*/ PhilipsOutputErrorMessage(unsigned char);
scalar_t__ atoi(char const *);
unsigned char GetAndReportErrorNumber(const char *Answer) {
  unsigned char Result = 0xFF;
  unsigned int i = 0;
  while (1) {
    if (Answer[i] == 0x00) {
      break;
    }
    if (Answer[i] == 0x0a) {
      i++;
      if (Answer[i] < '0' || Answer[i] > '9') {
        DebugPrintf(1, "ErrorString: %s", &Answer[i]);
        break;
      }
      Result = (unsigned char)(atoi(&Answer[i]));
      break;
    }
    i++;
  }
  PhilipsOutputErrorMessage(Result);
  return Result;
}


x86 assembly (clang, -O0):
<GetAndReportErrorNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0xff,-0x9(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    1160 <GetAndReportErrorNumber+0x30>
jmp    11ea <GetAndReportErrorNumber+0xba>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    11dc <GetAndReportErrorNumber+0xac>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jl     11a5 <GetAndReportErrorNumber+0x75>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
jle    11c5 <GetAndReportErrorNumber+0x95>
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%eax
add    %rax,%rdx
mov    $0x1,%edi
lea    0xe45(%rip),%rsi
call   1030 <DebugPrintf@plt>
jmp    11ea <GetAndReportErrorNumber+0xba>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%eax
add    %rax,%rdi
call   1040 <atoi@plt>
mov    %al,-0x9(%rbp)
jmp    11ea <GetAndReportErrorNumber+0xba>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1147 <GetAndReportErrorNumber+0x17>
movzbl -0x9(%rbp),%edi
call   1050 <PhilipsOutputErrorMessage@plt>
movzbl -0x9(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetAndReportErrorNumber>:
push   %rbx
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
lea    -0x1(%rax),%ecx
movzbl (%rdi,%rcx,1),%ecx
test   %cl,%cl
je     1175 <GetAndReportErrorNumber+0x45>
cmp    $0xa,%cl
je     1155 <GetAndReportErrorNumber+0x25>
add    $0x1,%eax
jmp    1140 <GetAndReportErrorNumber+0x10>
mov    %eax,%eax
lea    (%rdi,%rax,1),%rdx
mov    (%rdi,%rax,1),%al
add    $0xc6,%al
cmp    $0xf5,%al
ja     1179 <GetAndReportErrorNumber+0x49>
lea    0xe95(%rip),%rsi
mov    $0x1,%edi
call   1030 <DebugPrintf@plt>
mov    $0xff,%al
jmp    1181 <GetAndReportErrorNumber+0x51>
mov    %rdx,%rdi
call   1040 <atoi@plt>
movzbl %al,%ebx
mov    %ebx,%edi
call   1050 <PhilipsOutputErrorMessage@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"ErrorString: %s\00"
define zeroext i8 @GetAndReportErrorNumber(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i32
store i8* %0, i8** %2
store i8 -1, i8* %3
store i32 0, i32* %4
br label %5
5: ; preds = %1, %53
%6 = load i8*, i8** %2
%7 = load i32, i32* %4
%8 = zext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %5
br label %56
14: ; preds = %5
%15 = load i8*, i8** %2
%16 = load i32, i32* %4
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 10
br i1 %21, label %22, label %53
22: ; preds = %14
%23 = load i32, i32* %4
%24 = add i32 %23, 1
store i32 %24, i32* %4
%25 = load i8*, i8** %2
%26 = load i32, i32* %4
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp slt i32 %30, 48
br i1 %31, label %40, label %32
32: ; preds = %22
%33 = load i8*, i8** %2
%34 = load i32, i32* %4
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp sgt i32 %38, 57
br i1 %39, label %40, label %46
40: ; preds = %32, %22
%41 = load i8*, i8** %2
%42 = load i32, i32* %4
%43 = zext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = call i32 @DebugPrintf(i32 1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %44)
br label %56
46: ; preds = %32
%47 = load i8*, i8** %2
%48 = load i32, i32* %4
%49 = zext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
%51 = call i64 @atoi(i8* %50)
%52 = trunc i64 %51 to i8
store i8 %52, i8* %3
br label %56
53: ; preds = %14
%54 = load i32, i32* %4
%55 = add i32 %54, 1
store i32 %55, i32* %4
br label %5
56: ; preds = %46, %40, %13
%57 = load i8, i8* %3
%58 = call i32 @PhilipsOutputErrorMessage(i8 zeroext %57)
%59 = load i8, i8* %3
ret i8 %59
}

LLVM IR (-O2):
@.str = [16 x i8] c"ErrorString: %s\00"
define zeroext i8 @GetAndReportErrorNumber(i8* %0) {
br label %2
2: ; preds = %19, %1
%3 = phi i32 [ 0, %1 ], [ %20, %19 ]
%4 = zext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
switch i8 %6, label %19 [
i8 0, label %21
i8 10, label %7
]
7: ; preds = %2
%8 = add i32 %3, 1
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = add i8 %11, -58
%13 = icmp ult i8 %12, -10
br i1 %13, label %14, label %16
14: ; preds = %7
%15 = tail call i32 @DebugPrintf(i32 1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %21
16: ; preds = %7
%17 = tail call i64 @atoi(i8* %10)
%18 = trunc i64 %17 to i8
br label %21
19: ; preds = %2
%20 = add i32 %3, 1
br label %2
21: ; preds = %2, %16, %14
%22 = phi i8 [ -1, %14 ], [ %18, %16 ], [ -1, %2 ]
%23 = tail call i32 @PhilipsOutputErrorMessage(i8 zeroext %22)
ret i8 %22
}