#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 *nmea_next_field(char *p) {
  while (p && (*p != 0) && (*p != ',') && (*p != '*')) {
    p++;
  }
  if (p != 0)
    return p + 1;
  return NULL;
}


x86 assembly (clang, -O0):
<nmea_next_field>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x11(%rbp)
je     1152 <nmea_next_field+0x52>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     1152 <nmea_next_field+0x52>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2c,%ecx
mov    %al,-0x11(%rbp)
je     1152 <nmea_next_field+0x52>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1162 <nmea_next_field+0x62>
jmp    1173 <nmea_next_field+0x73>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1108 <nmea_next_field+0x8>
cmpq   $0x0,-0x10(%rbp)
je     118f <nmea_next_field+0x8f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1197 <nmea_next_field+0x97>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<nmea_next_field>:
test   %rdi,%rdi
je     1135 <nmea_next_field+0x35>
mov    %rdi,%rax
add    $0x1,%rax
movabs $0x140000000001,%rcx
jmp    1124 <nmea_next_field+0x24>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rax
movzbl -0x1(%rax),%edx
cmp    $0x2c,%rdx
ja     1120 <nmea_next_field+0x20>
bt     %rdx,%rcx
jae    1120 <nmea_next_field+0x20>
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i8* @nmea_next_field(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %3
br label %4
4: ; preds = %24, %1
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %22
7: ; preds = %4
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 44
br i1 %16, label %17, label %22
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 42
br label %22
22: ; preds = %17, %12, %7, %4
%23 = phi i1 [ false, %12 ], [ false, %7 ], [ false, %4 ], [ %21, %17 ]
br i1 %23, label %24, label %27
24: ; preds = %22
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %3
br label %4
27: ; preds = %22
%28 = load i8*, i8** %3
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i64 1
store i8* %32, i8** %2
br label %34
33: ; preds = %27
store i8* null, i8** %2
br label %34
34: ; preds = %33, %30
%35 = load i8*, i8** %2
ret i8* %35
}

LLVM IR (-O2):
define i8* @nmea_next_field(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %10, label %3
3: ; preds = %1, %6
%4 = phi i8* [ %7, %6 ], [ %0, %1 ]
%5 = load i8, i8* %4
switch i8 %5, label %6 [
i8 0, label %8
i8 44, label %8
i8 42, label %8
]
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %4, i64 1
br label %3
8: ; preds = %3, %3, %3
%9 = getelementptr inbounds i8, i8* %4, i64 1
br label %10
10: ; preds = %1, %8
%11 = phi i8* [ %9, %8 ], [ null, %1 ]
ret i8* %11
}