#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char);
int /*<<< orphan*/ isdigit(char);
int /*<<< orphan*/ stderr;
char *next(char *end, char *ptr) {
  int state;
  char *cur = ptr;
  char now;
  state = 0;
  while (cur != end) {
    now = *cur;
    switch (state) {
    case 0:
      if (isdigit(now))
        cur++;
      else if (now == ' ' || now == '\t' || now == ',')
        state = 1;
      else if (now == '\n')
        state = 2;
      else
        state = -1;
      break;
    case 1:
      *cur = 0;
      return ++cur;
    case 2:
      return cur;
    default:
      fprintf(stderr,
              "Error while processing input file. Unrecognised char (%c)\n",
              *cur);
      exit(EXIT_FAILURE);
    }
  }
  return cur;
}


x86 assembly (clang, -O0):
<next>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     1278 <next+0x148>
mov    -0x28(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x29(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x30(%rbp)
test   %eax,%eax
je     119b <next+0x6b>
jmp    1179 <next+0x49>
mov    -0x30(%rbp),%eax
sub    $0x1,%eax
je     1220 <next+0xf0>
jmp    118a <next+0x5a>
mov    -0x30(%rbp),%eax
sub    $0x2,%eax
je     123c <next+0x10c>
jmp    1249 <next+0x119>
movsbl -0x29(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     11be <next+0x8e>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    121b <next+0xeb>
movsbl -0x29(%rbp),%eax
cmp    $0x20,%eax
je     11e5 <next+0xb5>
movsbl -0x29(%rbp),%eax
cmp    $0x9,%eax
je     11e5 <next+0xb5>
movsbl -0x29(%rbp),%eax
cmp    $0x2c,%eax
jne    11f1 <next+0xc1>
movl   $0x1,-0x1c(%rbp)
jmp    1216 <next+0xe6>
movsbl -0x29(%rbp),%eax
cmp    $0xa,%eax
jne    120a <next+0xda>
movl   $0x2,-0x1c(%rbp)
jmp    1211 <next+0xe1>
movl   $0xffffffff,-0x1c(%rbp)
jmp    1216 <next+0xe6>
jmp    121b <next+0xeb>
jmp    1273 <next+0x143>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    %rax,-0x8(%rbp)
jmp    1280 <next+0x150>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1280 <next+0x150>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rax
lea    0xda3(%rip),%rsi
movsbl (%rax),%edx
call   1040 <fprintf@plt>
mov    0x2d6c(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
jmp    114f <next+0x1f>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
cmp    %rdi,%rsi
je     11e5 <next+0xb5>
mov    %rdi,%r14
xor    %eax,%eax
lea    0xeb0(%rip),%r15
jmp    116b <next+0x3b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r12
xor    %eax,%eax
cmp    %r14,%r12
je     11e2 <next+0xb2>
movzbl (%r12),%ebx
test   %eax,%eax
jne    11a7 <next+0x77>
movsbl %bl,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    1160 <next+0x30>
add    $0xf7,%bl
cmp    $0x23,%bl
ja     11a0 <next+0x70>
mov    $0x1,%eax
movzbl %bl,%ecx
movslq (%r15,%rcx,4),%rcx
add    %r15,%rcx
jmp    *%rcx
mov    $0x2,%eax
jmp    1166 <next+0x36>
mov    $0xffffffff,%eax
jmp    1166 <next+0x36>
cmp    $0x1,%eax
je     11d7 <next+0xa7>
cmp    $0x2,%eax
je     11e5 <next+0xb5>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
movsbl %bl,%edx
lea    0xecc(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
movb   $0x0,(%r12)
add    $0x1,%r12
jmp    11e5 <next+0xb5>
mov    %r14,%r12
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [59 x i8] c"Error while processing input file. Unrecognised char (%c)\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @next(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %5
store i8* %9, i8** %7
store i32 0, i32* %6
br label %10
10: ; preds = %60, %2
%11 = load i8*, i8** %7
%12 = load i8*, i8** %4
%13 = icmp ne i8* %11, %12
br i1 %13, label %14, label %61
14: ; preds = %10
%15 = load i8*, i8** %7
%16 = load i8, i8* %15
store i8 %16, i8* %8
%17 = load i32, i32* %6
switch i32 %17, label %53 [
i32 0, label %18
i32 1, label %47
i32 2, label %51
]
18: ; preds = %14
%19 = load i8, i8* %8
%20 = call i32 @isdigit(i8 signext %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i8*, i8** %7
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %7
br label %46
25: ; preds = %18
%26 = load i8, i8* %8
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 32
br i1 %28, label %37, label %29
29: ; preds = %25
%30 = load i8, i8* %8
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 9
br i1 %32, label %37, label %33
33: ; preds = %29
%34 = load i8, i8* %8
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 44
br i1 %36, label %37, label %38
37: ; preds = %33, %29, %25
store i32 1, i32* %6
br label %45
38: ; preds = %33
%39 = load i8, i8* %8
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 10
br i1 %41, label %42, label %43
42: ; preds = %38
store i32 2, i32* %6
br label %44
43: ; preds = %38
store i32 -1, i32* %6
br label %44
44: ; preds = %43, %42
br label %45
45: ; preds = %44, %37
br label %46
46: ; preds = %45, %22
br label %60
47: ; preds = %14
%48 = load i8*, i8** %7
store i8 0, i8* %48
%49 = load i8*, i8** %7
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %7
store i8* %50, i8** %3
br label %63
51: ; preds = %14
%52 = load i8*, i8** %7
store i8* %52, i8** %3
br label %63
53: ; preds = %14
%54 = load i32, i32* @stderr
%55 = load i8*, i8** %7
%56 = load i8, i8* %55
%57 = call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8 signext %56)
%58 = load i32, i32* @EXIT_FAILURE
%59 = call i32 @exit(i32 %58)
unreachable
60: ; preds = %46
br label %10
61: ; preds = %10
%62 = load i8*, i8** %7
store i8* %62, i8** %3
br label %63
63: ; preds = %61, %51, %47
%64 = load i8*, i8** %3
ret i8* %64
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [59 x i8] c"Error while processing input file. Unrecognised char (%c)\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @next(i8* readnone %0, i8* %1) {
%3 = icmp eq i8* %1, %0
br i1 %3, label %27, label %4
4: ; preds = %2, %23
%5 = phi i8* [ %25, %23 ], [ %1, %2 ]
%6 = phi i32 [ %24, %23 ], [ 0, %2 ]
%7 = load i8, i8* %5
switch i32 %6, label %18 [
i32 0, label %8
i32 1, label %16
i32 2, label %27
]
8: ; preds = %4
%9 = tail call i32 @isdigit(i8 signext %7)
%10 = icmp eq i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = getelementptr inbounds i8, i8* %5, i64 1
br label %23
13: ; preds = %8
switch i8 %7, label %15 [
i8 44, label %23
i8 32, label %23
i8 9, label %23
i8 10, label %14
]
14: ; preds = %13
br label %23
15: ; preds = %13
br label %23
16: ; preds = %4
store i8 0, i8* %5
%17 = getelementptr inbounds i8, i8* %5, i64 1
br label %27
18: ; preds = %4
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8 signext %7)
%21 = load i32, i32* @EXIT_FAILURE
%22 = tail call i32 @exit(i32 %21)
unreachable
23: ; preds = %13, %13, %13, %11, %14, %15
%24 = phi i32 [ 0, %11 ], [ 2, %14 ], [ -1, %15 ], [ 1, %13 ], [ 1, %13 ], [ 1, %13 ]
%25 = phi i8* [ %12, %11 ], [ %5, %14 ], [ %5, %15 ], [ %5, %13 ], [ %5, %13 ], [ %5, %13 ]
%26 = icmp eq i8* %25, %0
br i1 %26, label %27, label %4
27: ; preds = %4, %23, %2, %16
%28 = phi i8* [ %17, %16 ], [ %1, %2 ], [ %5, %4 ], [ %0, %23 ]
ret i8* %28
}