#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 *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strncmp(char *, char *, int);
int test_find_nmea_start(void) {
  char buf[255];
  char *p;
  strcpy(buf, "!AIVDM,1,1,,A,19NWoq000Wrt<RJHEuuqiWlN061d,0*5F");
  if ((p = find_nmea_start(buf)) == NULL) {
    fprintf(stderr, "find_nmea_start() 1: failed\n");
    return 0;
  }
  strcpy((char *)buf, "$PSHI,123,456,789*CC");
  if ((p = find_nmea_start(buf)) == NULL) {
    fprintf(stderr, "find_nmea_start() 2: failed\n");
    return 0;
  }
  strcpy((char *)buf,
         "678,4343,123,585*FF\n$GPGGA,32,121,676,29394,29234*AA\n");
  if ((p = find_nmea_start(buf)) == NULL) {
    fprintf(stderr, "find_nmea_start() 3: failed\n");
    return 0;
  }
  if (strncmp(p, "$GPGGA,", 7) != 0) {
    fprintf(stderr, "find_nmea_start() 3.1: failed\n");
    return 0;
  }
  strcpy((char *)buf,
         "678,4343,123,585*FF\n!AIVDM,5,2,a,123,32,584,49494,DDA,*BB\n");
  if ((p = find_nmea_start(buf)) == NULL) {
    fprintf(stderr, "find_nmea_start() 4: failed\n");
    return 0;
  }
  if (strncmp(p, "!AIVDM,", 7) != 0) {
    fprintf(stderr, "find_nmea_start() 4.1: failed\n");
    return 0;
  }
  strcpy((char *)buf,
         "678,4343,123,585*FF\n#AIVDM,5,2,a,123,32,584,49494,DDA,*BB\n");
  if ((p = find_nmea_start(buf)) != NULL) {
    fprintf(stderr, "find_nmea_start() 5: failed\n");
    return 0;
  }
  fprintf(stderr, "find_nmea_start(): Passed\n");
  return 1;
}


x86 assembly (clang, -O0):
<test_find_nmea_start>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
lea    -0x110(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x110(%rbp),%rdi
call   1050 <find_nmea_start@plt>
mov    %rax,-0x118(%rbp)
cmp    $0x0,%rax
jne    119c <test_find_nmea_start+0x5c>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xea5(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1382 <test_find_nmea_start+0x242>
lea    -0x110(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x110(%rbp),%rdi
call   1050 <find_nmea_start@plt>
mov    %rax,-0x118(%rbp)
cmp    $0x0,%rax
jne    11ed <test_find_nmea_start+0xad>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
lea    0xe86(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1382 <test_find_nmea_start+0x242>
lea    -0x110(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x110(%rbp),%rdi
call   1050 <find_nmea_start@plt>
mov    %rax,-0x118(%rbp)
cmp    $0x0,%rax
jne    123e <test_find_nmea_start+0xfe>
mov    0x2dbc(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1382 <test_find_nmea_start+0x242>
mov    -0x118(%rbp),%rdi
lea    0xe86(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1281 <test_find_nmea_start+0x141>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
lea    0xe6a(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1382 <test_find_nmea_start+0x242>
lea    -0x110(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x110(%rbp),%rdi
call   1050 <find_nmea_start@plt>
mov    %rax,-0x118(%rbp)
cmp    $0x0,%rax
jne    12d2 <test_find_nmea_start+0x192>
mov    0x2d28(%rip),%rax
mov    (%rax),%edi
lea    0xe73(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1382 <test_find_nmea_start+0x242>
mov    -0x118(%rbp),%rdi
lea    0xe71(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1315 <test_find_nmea_start+0x1d5>
mov    0x2ce5(%rip),%rax
mov    (%rax),%edi
lea    0xe55(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1382 <test_find_nmea_start+0x242>
lea    -0x110(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x110(%rbp),%rdi
call   1050 <find_nmea_start@plt>
mov    %rax,-0x118(%rbp)
cmp    $0x0,%rax
je     1366 <test_find_nmea_start+0x226>
mov    0x2c94(%rip),%rax
mov    (%rax),%edi
lea    0xe5e(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1382 <test_find_nmea_start+0x242>
mov    0x2c73(%rip),%rax
mov    (%rax),%edi
lea    0xe5a(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_find_nmea_start>:
push   %rbx
sub    $0x100,%rsp
lea    0xeb1(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <find_nmea_start@plt>
test   %rax,%rax
je     11d0 <test_find_nmea_start+0x90>
lea    0xedf(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <find_nmea_start@plt>
test   %rax,%rax
je     11e2 <test_find_nmea_start+0xa2>
lea    0xef2(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <find_nmea_start@plt>
test   %rax,%rax
je     11f4 <test_find_nmea_start+0xb4>
lea    0xf26(%rip),%rsi
mov    %rax,%rdi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1214 <test_find_nmea_start+0xd4>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
lea    0xf0c(%rip),%rsi
jmp    1204 <test_find_nmea_start+0xc4>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
jmp    1204 <test_find_nmea_start+0xc4>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
jmp    1204 <test_find_nmea_start+0xc4>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
lea    0xeb1(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
ret
lea    0xede(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <find_nmea_start@plt>
test   %rax,%rax
je     125e <test_find_nmea_start+0x11e>
lea    0xf17(%rip),%rsi
mov    %rax,%rdi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1270 <test_find_nmea_start+0x130>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
lea    0xefd(%rip),%rsi
jmp    1204 <test_find_nmea_start+0xc4>
mov    0x2d7b(%rip),%rax
mov    (%rax),%edi
lea    0xec6(%rip),%rsi
jmp    1204 <test_find_nmea_start+0xc4>
lea    0xf01(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <find_nmea_start@plt>
mov    0x2d4f(%rip),%rcx
mov    (%rcx),%edi
test   %rax,%rax
je     12a4 <test_find_nmea_start+0x164>
lea    0xf14(%rip),%rsi
jmp    1204 <test_find_nmea_start+0xc4>
lea    0xf25(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%eax
jmp    120b <test_find_nmea_start+0xcb>

LLVM IR (-O0):
@.str = [48 x i8] c"!AIVDM,1,1,,A,19NWoq000Wrt<RJHEuuqiWlN061d,0*5F\00"
@stderr = global i32 0
@.str.1 = [29 x i8] c"find_nmea_start() 1: failed\0A\00"
@.str.2 = [21 x i8] c"$PSHI,123,456,789*CC\00"
@.str.3 = [29 x i8] c"find_nmea_start() 2: failed\0A\00"
@.str.4 = [54 x i8] c"678,4343,123,585*FF\0A$GPGGA,32,121,676,29394,29234*AA\0A\00"
@.str.5 = [29 x i8] c"find_nmea_start() 3: failed\0A\00"
@.str.6 = [8 x i8] c"$GPGGA,\00"
@.str.7 = [31 x i8] c"find_nmea_start() 3.1: failed\0A\00"
@.str.8 = [59 x i8] c"678,4343,123,585*FF\0A!AIVDM,5,2,a,123,32,584,49494,DDA,*BB\0A\00"
@.str.9 = [29 x i8] c"find_nmea_start() 4: failed\0A\00"
@.str.10 = [8 x i8] c"!AIVDM,\00"
@.str.11 = [31 x i8] c"find_nmea_start() 4.1: failed\0A\00"
@.str.12 = [59 x i8] c"678,4343,123,585*FF\0A#AIVDM,5,2,a,123,32,584,49494,DDA,*BB\0A\00"
@.str.13 = [29 x i8] c"find_nmea_start() 5: failed\0A\00"
@.str.14 = [27 x i8] c"find_nmea_start(): Passed\0A\00"
define i32 @test_find_nmea_start() {
%1 = alloca i32
%2 = alloca [255 x i8]
%3 = alloca i8*
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%7 = call i8* @find_nmea_start(i8* %6)
store i8* %7, i8** %3
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %65
12: ; preds = %0
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%16 = call i8* @find_nmea_start(i8* %15)
store i8* %16, i8** %3
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %65
21: ; preds = %12
%22 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%23 = call i32 @strcpy(i8* %22, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
%24 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%25 = call i8* @find_nmea_start(i8* %24)
store i8* %25, i8** %3
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %30
27: ; preds = %21
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %1
br label %65
30: ; preds = %21
%31 = load i8*, i8** %3
%32 = call i64 @strncmp(i8* %31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 7)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %1
br label %65
37: ; preds = %30
%38 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%39 = call i32 @strcpy(i8* %38, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.8, i64 0, i64 0))
%40 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%41 = call i8* @find_nmea_start(i8* %40)
store i8* %41, i8** %3
%42 = icmp eq i8* %41, null
br i1 %42, label %43, label %46
43: ; preds = %37
%44 = load i32, i32* @stderr
%45 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %1
br label %65
46: ; preds = %37
%47 = load i8*, i8** %3
%48 = call i64 @strncmp(i8* %47, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i32 7)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %46
%51 = load i32, i32* @stderr
%52 = call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %1
br label %65
53: ; preds = %46
%54 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%55 = call i32 @strcpy(i8* %54, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.12, i64 0, i64 0))
%56 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%57 = call i8* @find_nmea_start(i8* %56)
store i8* %57, i8** %3
%58 = icmp ne i8* %57, null
br i1 %58, label %59, label %62
59: ; preds = %53
%60 = load i32, i32* @stderr
%61 = call i32 @fprintf(i32 %60, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0))
store i32 0, i32* %1
br label %65
62: ; preds = %53
%63 = load i32, i32* @stderr
%64 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.14, i64 0, i64 0))
store i32 1, i32* %1
br label %65
65: ; preds = %62, %59, %50, %43, %34, %27, %18, %9
%66 = load i32, i32* %1
ret i32 %66
}

LLVM IR (-O2):
@.str = [48 x i8] c"!AIVDM,1,1,,A,19NWoq000Wrt<RJHEuuqiWlN061d,0*5F\00"
@stderr = global i32 0
@.str.1 = [29 x i8] c"find_nmea_start() 1: failed\0A\00"
@.str.2 = [21 x i8] c"$PSHI,123,456,789*CC\00"
@.str.3 = [29 x i8] c"find_nmea_start() 2: failed\0A\00"
@.str.4 = [54 x i8] c"678,4343,123,585*FF\0A$GPGGA,32,121,676,29394,29234*AA\0A\00"
@.str.5 = [29 x i8] c"find_nmea_start() 3: failed\0A\00"
@.str.6 = [8 x i8] c"$GPGGA,\00"
@.str.7 = [31 x i8] c"find_nmea_start() 3.1: failed\0A\00"
@.str.8 = [59 x i8] c"678,4343,123,585*FF\0A!AIVDM,5,2,a,123,32,584,49494,DDA,*BB\0A\00"
@.str.9 = [29 x i8] c"find_nmea_start() 4: failed\0A\00"
@.str.10 = [8 x i8] c"!AIVDM,\00"
@.str.11 = [31 x i8] c"find_nmea_start() 4.1: failed\0A\00"
@.str.12 = [59 x i8] c"678,4343,123,585*FF\0A#AIVDM,5,2,a,123,32,584,49494,DDA,*BB\0A\00"
@.str.13 = [29 x i8] c"find_nmea_start() 5: failed\0A\00"
@.str.14 = [27 x i8] c"find_nmea_start(): Passed\0A\00"
define i32 @test_find_nmea_start() {
%1 = alloca [255 x i8]
%2 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%3 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%4 = call i8* @find_nmea_start(i8* %2)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %51
9: ; preds = %0
%10 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%11 = call i8* @find_nmea_start(i8* %2)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %51
16: ; preds = %9
%17 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
%18 = call i8* @find_nmea_start(i8* %2)
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
br label %51
23: ; preds = %16
%24 = call i64 @strncmp(i8* %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 7)
%25 = icmp eq i64 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
br label %51
29: ; preds = %23
%30 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.8, i64 0, i64 0))
%31 = call i8* @find_nmea_start(i8* %2)
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
br label %51
36: ; preds = %29
%37 = call i64 @strncmp(i8* %31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i32 7)
%38 = icmp eq i64 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %36
%40 = load i32, i32* @stderr
%41 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.11, i64 0, i64 0))
br label %51
42: ; preds = %36
%43 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.12, i64 0, i64 0))
%44 = call i8* @find_nmea_start(i8* %2)
%45 = icmp eq i8* %44, null
%46 = load i32, i32* @stderr
br i1 %45, label %49, label %47
47: ; preds = %42
%48 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0))
br label %51
49: ; preds = %42
%50 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.14, i64 0, i64 0))
br label %51
51: ; preds = %49, %47, %39, %33, %26, %20, %13, %6
%52 = phi i32 [ 0, %6 ], [ 0, %13 ], [ 0, %20 ], [ 0, %26 ], [ 0, %33 ], [ 0, %39 ], [ 0, %47 ], [ 1, %49 ]
ret i32 %52
}