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


x86 assembly (clang, -O0):
<GetErrorNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    1150 <GetErrorNumber+0x30>
movb   $0xff,-0x1(%rbp)
jmp    11de <GetErrorNumber+0xbe>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1169 <GetErrorNumber+0x49>
jmp    1177 <GetErrorNumber+0x57>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1133 <GetErrorNumber+0x13>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jl     11a8 <GetErrorNumber+0x88>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
jle    11cc <GetErrorNumber+0xac>
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%eax
add    %rax,%rdx
mov    $0x1,%edi
lea    0xe42(%rip),%rsi
call   1030 <DebugPrintf@plt>
movb   $0xff,-0x1(%rbp)
jmp    11de <GetErrorNumber+0xbe>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    %rax,%rdi
call   1040 <atoi@plt>
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetErrorNumber>:
push   %rax
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
lea    -0x1(%rax),%ecx
movzbl (%rdi,%rcx,1),%ecx
test   %cl,%cl
je     1165 <GetErrorNumber+0x45>
cmp    $0xa,%cl
je     1145 <GetErrorNumber+0x25>
add    $0x1,%eax
jmp    1130 <GetErrorNumber+0x10>
mov    %eax,%eax
lea    (%rdi,%rax,1),%rdx
mov    (%rdi,%rax,1),%al
add    $0xc6,%al
cmp    $0xf5,%al
ja     1169 <GetErrorNumber+0x49>
lea    0xea5(%rip),%rsi
mov    $0x1,%edi
call   1030 <DebugPrintf@plt>
mov    $0xff,%al
pop    %rcx
ret
mov    %rdx,%rdi
call   1040 <atoi@plt>
pop    %rcx
ret

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

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