#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 */
char *RemoveLeadingZeroes(char *);
int /*<<< orphan*/ assert(int /*<<< orphan*/);
long atol(char *);
int /*<<< orphan*/ exit_wrapper(int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, unsigned long);
long int ParseLongIntXML(char *buffer, unsigned long linenum) {
  char numberbuffer[11] = {0};
  unsigned long index = 0;
  unsigned long index2 = 0;
  char *tempstr = NULL;
  long num;
  (assert(buffer != NULL));
  while (buffer[index] != '\0') {
    if (buffer[index] == '<')
      break;
    if (index2 >= 10)
      break;
    numberbuffer[index2++] = buffer[index++];
  }
  numberbuffer[index2] = '\0';
  tempstr = RemoveLeadingZeroes(numberbuffer);
  if (tempstr[0] == '0') {
    num = 0;
  } else {
    num = atol(tempstr);
    if (!num) {
      printf("Error converting numerical string to numerical value.\nError "
             "occurs in line %lu of input file\nAborting\n",
             linenum);
      exit_wrapper(2);
    }
  }
  free(tempstr);
  return num;
}


x86 assembly (clang, -O0):
<ParseLongIntXML>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x1b(%rbp),%rdi
xor    %esi,%esi
mov    $0xb,%edx
call   1050 <memset@plt>
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1227 <ParseLongIntXML+0xb7>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3c,%eax
jne    11e9 <ParseLongIntXML+0x79>
jmp    1227 <ParseLongIntXML+0xb7>
cmpq   $0xa,-0x30(%rbp)
jb     11f9 <ParseLongIntXML+0x89>
jmp    1227 <ParseLongIntXML+0xb7>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x28(%rbp)
mov    (%rax,%rcx,1),%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,-0x1b(%rbp,%rax,1)
jmp    11ba <ParseLongIntXML+0x4a>
mov    -0x30(%rbp),%rax
movb   $0x0,-0x1b(%rbp,%rax,1)
lea    -0x1b(%rbp),%rdi
call   1090 <RemoveLeadingZeroes@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    125a <ParseLongIntXML+0xea>
movq   $0x0,-0x40(%rbp)
jmp    1291 <ParseLongIntXML+0x121>
mov    -0x38(%rbp),%rdi
call   1080 <atol@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    128c <ParseLongIntXML+0x11c>
mov    -0x10(%rbp),%rsi
lea    0xd83(%rip),%rdi
call   1040 <printf@plt>
mov    $0x2,%edi
call   1060 <exit_wrapper@plt>
jmp    1291 <ParseLongIntXML+0x121>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ParseLongIntXML>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x0,0x7(%rsp)
movq   $0x0,(%rsp)
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1060 <assert@plt>
mov    (%rbx),%al
test   %al,%al
je     11bf <ParseLongIntXML+0x5f>
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0x3c,%al
je     11c3 <ParseLongIntXML+0x63>
cmp    $0x9,%rcx
ja     11c3 <ParseLongIntXML+0x63>
lea    0x1(%rcx),%rdx
mov    %al,(%rsp,%rcx,1)
movzbl 0x1(%rbx,%rcx,1),%eax
mov    %rdx,%rcx
test   %al,%al
jne    11a0 <ParseLongIntXML+0x40>
jmp    11c6 <ParseLongIntXML+0x66>
xor    %edx,%edx
jmp    11c6 <ParseLongIntXML+0x66>
mov    %rcx,%rdx
movb   $0x0,(%rsp,%rdx,1)
mov    %rsp,%rdi
call   1080 <RemoveLeadingZeroes@plt>
mov    %rax,%r15
cmpb   $0x30,(%rax)
je     1203 <ParseLongIntXML+0xa3>
mov    %r15,%rdi
call   1070 <atol@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1205 <ParseLongIntXML+0xa5>
lea    0xe0f(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    $0x2,%edi
call   1050 <exit_wrapper@plt>
xor    %ebx,%ebx
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [103 x i8] c"Error converting numerical string to numerical value.\0AError occurs in line %lu of input file\0AAborting\0A\00"
define i64 @ParseLongIntXML(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca [11 x i8]
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%10 = bitcast [11 x i8]* %5 to i8*
store i64 0, i64* %6
store i64 0, i64* %7
store i8* null, i8** %8
%11 = load i8*, i8** %3
%12 = icmp ne i8* %11, null
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
br label %15
15: ; preds = %34, %2
%16 = load i8*, i8** %3
%17 = load i64, i64* %6
%18 = getelementptr inbounds i8, i8* %16, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %43
22: ; preds = %15
%23 = load i8*, i8** %3
%24 = load i64, i64* %6
%25 = getelementptr inbounds i8, i8* %23, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 60
br i1 %28, label %29, label %30
29: ; preds = %22
br label %43
30: ; preds = %22
%31 = load i64, i64* %7
%32 = icmp uge i64 %31, 10
br i1 %32, label %33, label %34
33: ; preds = %30
br label %43
34: ; preds = %30
%35 = load i8*, i8** %3
%36 = load i64, i64* %6
%37 = add i64 %36, 1
store i64 %37, i64* %6
%38 = getelementptr inbounds i8, i8* %35, i64 %36
%39 = load i8, i8* %38
%40 = load i64, i64* %7
%41 = add i64 %40, 1
store i64 %41, i64* %7
%42 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 %40
store i8 %39, i8* %42
br label %15
43: ; preds = %33, %29, %15
%44 = load i64, i64* %7
%45 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 %44
store i8 0, i8* %45
%46 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%47 = call i8* @RemoveLeadingZeroes(i8* %46)
store i8* %47, i8** %8
%48 = load i8*, i8** %8
%49 = getelementptr inbounds i8, i8* %48, i64 0
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 48
br i1 %52, label %53, label %54
53: ; preds = %43
store i64 0, i64* %9
br label %64
54: ; preds = %43
%55 = load i8*, i8** %8
%56 = call i64 @atol(i8* %55)
store i64 %56, i64* %9
%57 = load i64, i64* %9
%58 = icmp ne i64 %57, 0
br i1 %58, label %63, label %59
59: ; preds = %54
%60 = load i64, i64* %4
%61 = call i32 @printf(i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str, i64 0, i64 0), i64 %60)
%62 = call i32 @exit_wrapper(i32 2)
br label %63
63: ; preds = %59, %54
br label %64
64: ; preds = %63, %53
%65 = load i8*, i8** %8
%66 = call i32 @free(i8* %65)
%67 = load i64, i64* %9
ret i64 %67
}

LLVM IR (-O2):
@.str = [103 x i8] c"Error converting numerical string to numerical value.\0AError occurs in line %lu of input file\0AAborting\0A\00"
define i64 @ParseLongIntXML(i8* %0, i64 %1) {
%3 = alloca [11 x i8]
%4 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%5 = icmp ne i8* %0, null
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 0
br i1 %9, label %22, label %10
10: ; preds = %2, %16
%11 = phi i8 [ %20, %16 ], [ %8, %2 ]
%12 = phi i64 [ %17, %16 ], [ 0, %2 ]
%13 = icmp eq i8 %11, 60
%14 = icmp ugt i64 %12, 9
%15 = select i1 %13, i1 true, i1 %14
br i1 %15, label %22, label %16
16: ; preds = %10
%17 = add nuw nsw i64 %12, 1
%18 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 %12
store i8 %11, i8* %18
%19 = getelementptr inbounds i8, i8* %0, i64 %17
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %22, label %10
22: ; preds = %16, %10, %2
%23 = phi i64 [ 0, %2 ], [ %12, %10 ], [ %17, %16 ]
%24 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 %23
store i8 0, i8* %24
%25 = call i8* @RemoveLeadingZeroes(i8* %4)
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 48
br i1 %27, label %34, label %28
28: ; preds = %22
%29 = call i64 @atol(i8* %25)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = call i32 @printf(i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str, i64 0, i64 0), i64 %1)
%33 = call i32 @exit_wrapper(i32 2)
br label %34
34: ; preds = %22, %28, %31
%35 = phi i64 [ %29, %28 ], [ 0, %31 ], [ 0, %22 ]
%36 = call i32 @free(i8* %25)
ret i64 %35
}