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


x86 assembly (clang, -O0):
<find_nmea_start>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1120 <find_nmea_start+0x20>
movq   $0x0,-0x8(%rbp)
jmp    11b8 <find_nmea_start+0xb8>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x19(%rbp)
je     1172 <find_nmea_start+0x72>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     1172 <find_nmea_start+0x72>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x21,%ecx
mov    %al,-0x19(%rbp)
je     1172 <find_nmea_start+0x72>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x24,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1182 <find_nmea_start+0x82>
jmp    1193 <find_nmea_start+0x93>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1128 <find_nmea_start+0x28>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b0 <find_nmea_start+0xb0>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11b8 <find_nmea_start+0xb8>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_nmea_start>:
test   %rdi,%rdi
je     113c <find_nmea_start+0x3c>
mov    %rdi,%rax
movabs $0x1200000001,%rcx
jmp    1124 <find_nmea_start+0x24>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rax
movzbl (%rax),%edx
cmp    $0x24,%rdx
ja     1120 <find_nmea_start+0x20>
bt     %rdx,%rcx
jae    1120 <find_nmea_start+0x20>
xor    %ecx,%ecx
test   %dl,%dl
cmove  %rcx,%rax
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i8* @find_nmea_start(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %11, 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 33, label %8
i8 36, label %8
]
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %4, i64 1
br label %3
8: ; preds = %3, %3, %3
%9 = icmp eq i8 %5, 0
%10 = select i1 %9, i8* null, i8* %4
br label %11
11: ; preds = %8, %1
%12 = phi i8* [ null, %1 ], [ %10, %8 ]
ret i8* %12
}