#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*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strip_whitespace(char *);
int /*<<< orphan*/ valid_numeral_char(char);
int /*<<< orphan*/ valid_numeral_first_char(char);
char *tokenizer_next_udp_message(char *input_p) {
  char *word, *input;
  assert(input_p != NULL);
  word = input = input_p;
  if (*input == 0)
    return NULL;
  if (!valid_numeral_first_char(*input)) {
    fprintf(stderr, "Number expected\n");
    return NULL;
  }
  while (*++input != 0) {
    if (*input == ';') {
      *input = 0;
      strip_whitespace(input + 1);
      break;
    }
    if (!valid_numeral_char(*input)) {
      fprintf(stderr, "Invalid character\n");
      return NULL;
    }
  }
  input_p = input;
  return word;
}


x86 assembly (clang, -O0):
<tokenizer_next_udp_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1197 <tokenizer_next_udp_message+0x47>
movq   $0x0,-0x8(%rbp)
jmp    1264 <tokenizer_next_udp_message+0x114>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1070 <valid_numeral_first_char@plt>
cmp    $0x0,%eax
jne    11ce <tokenizer_next_udp_message+0x7e>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
lea    0xe44(%rip),%rsi
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1264 <tokenizer_next_udp_message+0x114>
jmp    11d3 <tokenizer_next_udp_message+0x83>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     1254 <tokenizer_next_udp_message+0x104>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3b,%eax
jne    1218 <tokenizer_next_udp_message+0xc8>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
call   1040 <strip_whitespace@plt>
jmp    1254 <tokenizer_next_udp_message+0x104>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <valid_numeral_char@plt>
cmp    $0x0,%eax
jne    124f <tokenizer_next_udp_message+0xff>
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
lea    0xdd4(%rip),%rsi
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1264 <tokenizer_next_udp_message+0x114>
jmp    11d3 <tokenizer_next_udp_message+0x83>
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tokenizer_next_udp_message>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1050 <assert@plt>
mov    (%r14),%al
test   %al,%al
je     11ae <tokenizer_next_udp_message+0x5e>
movsbl %al,%edi
call   1070 <valid_numeral_first_char@plt>
test   %eax,%eax
je     11b3 <tokenizer_next_udp_message+0x63>
lea    0x2(%r14),%rbx
nopl   0x0(%rax)
movzbl -0x1(%rbx),%eax
test   %al,%al
je     11d9 <tokenizer_next_udp_message+0x89>
cmp    $0x3b,%al
je     11cd <tokenizer_next_udp_message+0x7d>
movsbl %al,%edi
call   1030 <valid_numeral_char@plt>
add    $0x1,%rbx
test   %eax,%eax
jne    1180 <tokenizer_next_udp_message+0x30>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
lea    0xe65(%rip),%rsi
jmp    11c3 <tokenizer_next_udp_message+0x73>
xor    %r14d,%r14d
jmp    11d9 <tokenizer_next_udp_message+0x89>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
lea    0xe3d(%rip),%rsi
call   1060 <fprintf@plt>
xor    %r14d,%r14d
jmp    11d9 <tokenizer_next_udp_message+0x89>
movb   $0x0,-0x1(%rbx)
mov    %rbx,%rdi
call   1040 <strip_whitespace@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [17 x i8] c"Number expected\0A\00"
@.str.1 = [19 x i8] c"Invalid character\0A\00"
define i8* @tokenizer_next_udp_message(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = load i8*, i8** %3
store i8* %10, i8** %5
store i8* %10, i8** %4
%11 = load i8*, i8** %5
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %1
store i8* null, i8** %2
br label %53
16: ; preds = %1
%17 = load i8*, i8** %5
%18 = load i8, i8* %17
%19 = call i32 @valid_numeral_first_char(i8 signext %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %16
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i8* null, i8** %2
br label %53
24: ; preds = %16
br label %25
25: ; preds = %49, %24
%26 = load i8*, i8** %5
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %5
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %50
31: ; preds = %25
%32 = load i8*, i8** %5
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 59
br i1 %35, label %36, label %41
36: ; preds = %31
%37 = load i8*, i8** %5
store i8 0, i8* %37
%38 = load i8*, i8** %5
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = call i32 @strip_whitespace(i8* %39)
br label %50
41: ; preds = %31
%42 = load i8*, i8** %5
%43 = load i8, i8* %42
%44 = call i32 @valid_numeral_char(i8 signext %43)
%45 = icmp ne i32 %44, 0
br i1 %45, label %49, label %46
46: ; preds = %41
%47 = load i32, i32* @stderr
%48 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
store i8* null, i8** %2
br label %53
49: ; preds = %41
br label %25
50: ; preds = %36, %25
%51 = load i8*, i8** %5
store i8* %51, i8** %3
%52 = load i8*, i8** %4
store i8* %52, i8** %2
br label %53
53: ; preds = %50, %46, %21, %15
%54 = load i8*, i8** %2
ret i8* %54
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [17 x i8] c"Number expected\0A\00"
@.str.1 = [19 x i8] c"Invalid character\0A\00"
define i8* @tokenizer_next_udp_message(i8* %0) {
%2 = icmp ne i8* %0, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %26, label %7
7: ; preds = %1
%8 = tail call i32 @valid_numeral_first_char(i8 signext %5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %26
13: ; preds = %7, %20
%14 = phi i8* [ %15, %20 ], [ %0, %7 ]
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = load i8, i8* %15
switch i8 %16, label %20 [
i8 0, label %26
i8 59, label %17
]
17: ; preds = %13
store i8 0, i8* %15
%18 = getelementptr inbounds i8, i8* %14, i64 2
%19 = tail call i32 @strip_whitespace(i8* %18)
br label %26
20: ; preds = %13
%21 = tail call i32 @valid_numeral_char(i8 signext %16)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %13
23: ; preds = %20
%24 = load i32, i32* @stderr
%25 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %13, %17, %1, %23, %10
%27 = phi i8* [ null, %23 ], [ null, %10 ], [ null, %1 ], [ %0, %17 ], [ %0, %13 ]
ret i8* %27
}