#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*/ fprintf(int /*<<< orphan*/, char *);
char *nmea_next_field(char *);
int nmea_uint(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int test_nmea_uint(void) {
  char buf[255];
  char *p;
  strcpy(buf, "42,1122,0531,0703,0707,65535,0");
  p = buf;
  if (nmea_uint(p) != 42) {
    fprintf(stderr, "nmea_uint() 1: Failed\n");
    return 0;
  }
  p = nmea_next_field(p);
  if (nmea_uint(p) != 1122) {
    fprintf(stderr, "nmea_uint() 2: Failed\n");
    return 0;
  }
  p = nmea_next_field(p);
  if (nmea_uint(p) != 531) {
    fprintf(stderr, "nmea_uint() 3: Failed\n");
    return 0;
  }
  p = nmea_next_field(p);
  if (nmea_uint(p) != 703) {
    fprintf(stderr, "nmea_uint() 4: Failed\n");
    return 0;
  }
  p = nmea_next_field(p);
  if (nmea_uint(p) != 707) {
    fprintf(stderr, "nmea_uint() 5: Failed\n");
    return 0;
  }
  p = nmea_next_field(p);
  if (nmea_uint(p) != 65535) {
    fprintf(stderr, "nmea_uint() 6: Failed\n");
    return 0;
  }
  p = nmea_next_field(p);
  if (nmea_uint(p) != 0) {
    fprintf(stderr, "nmea_uint() 7: Failed\n");
    return 0;
  }
  fprintf(stderr, "nmea_uint(): Passed\n");
  return 1;
}


x86 assembly (clang, -O0):
<test_nmea_uint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
lea    -0x110(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x110(%rbp),%rax
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rdi
call   1030 <nmea_uint@plt>
cmp    $0x2a,%eax
je     11a2 <test_nmea_uint+0x62>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
lea    0xe8e(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    137e <test_nmea_uint+0x23e>
mov    -0x118(%rbp),%rdi
call   1060 <nmea_next_field@plt>
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rdi
call   1030 <nmea_uint@plt>
cmp    $0x462,%eax
je     11ed <test_nmea_uint+0xad>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
lea    0xe5a(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    137e <test_nmea_uint+0x23e>
mov    -0x118(%rbp),%rdi
call   1060 <nmea_next_field@plt>
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rdi
call   1030 <nmea_uint@plt>
cmp    $0x213,%eax
je     1238 <test_nmea_uint+0xf8>
mov    0x2dc2(%rip),%rax
mov    (%rax),%edi
lea    0xe26(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    137e <test_nmea_uint+0x23e>
mov    -0x118(%rbp),%rdi
call   1060 <nmea_next_field@plt>
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rdi
call   1030 <nmea_uint@plt>
cmp    $0x2bf,%eax
je     1283 <test_nmea_uint+0x143>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
lea    0xdf2(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    137e <test_nmea_uint+0x23e>
mov    -0x118(%rbp),%rdi
call   1060 <nmea_next_field@plt>
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rdi
call   1030 <nmea_uint@plt>
cmp    $0x2c3,%eax
je     12ce <test_nmea_uint+0x18e>
mov    0x2d2c(%rip),%rax
mov    (%rax),%edi
lea    0xdbe(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    137e <test_nmea_uint+0x23e>
mov    -0x118(%rbp),%rdi
call   1060 <nmea_next_field@plt>
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rdi
call   1030 <nmea_uint@plt>
cmp    $0xffff,%eax
je     1319 <test_nmea_uint+0x1d9>
mov    0x2ce1(%rip),%rax
mov    (%rax),%edi
lea    0xd8a(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    137e <test_nmea_uint+0x23e>
mov    -0x118(%rbp),%rdi
call   1060 <nmea_next_field@plt>
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rdi
call   1030 <nmea_uint@plt>
cmp    $0x0,%eax
je     1362 <test_nmea_uint+0x222>
mov    0x2c98(%rip),%rax
mov    (%rax),%edi
lea    0xd58(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    137e <test_nmea_uint+0x23e>
mov    0x2c77(%rip),%rax
mov    (%rax),%edi
lea    0xd4e(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_nmea_uint>:
push   %rbx
sub    $0x100,%rsp
lea    0xeb1(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1030 <nmea_uint@plt>
cmp    $0x2a,%eax
jne    122b <test_nmea_uint+0xeb>
mov    %rsp,%rdi
call   1060 <nmea_next_field@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <nmea_uint@plt>
cmp    $0x462,%eax
jne    123d <test_nmea_uint+0xfd>
mov    %rbx,%rdi
call   1060 <nmea_next_field@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <nmea_uint@plt>
cmp    $0x213,%eax
jne    124f <test_nmea_uint+0x10f>
mov    %rbx,%rdi
call   1060 <nmea_next_field@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <nmea_uint@plt>
cmp    $0x2bf,%eax
jne    1261 <test_nmea_uint+0x121>
mov    %rbx,%rdi
call   1060 <nmea_next_field@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <nmea_uint@plt>
cmp    $0x2c3,%eax
jne    1273 <test_nmea_uint+0x133>
mov    %rbx,%rdi
call   1060 <nmea_next_field@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <nmea_uint@plt>
cmp    $0xffff,%eax
jne    1285 <test_nmea_uint+0x145>
mov    %rbx,%rdi
call   1060 <nmea_next_field@plt>
mov    %rax,%rdi
call   1030 <nmea_uint@plt>
mov    0x2dc8(%rip),%rcx
mov    (%rcx),%edi
test   %eax,%eax
je     12a5 <test_nmea_uint+0x165>
lea    0xe80(%rip),%rsi
jmp    1295 <test_nmea_uint+0x155>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
lea    0xde4(%rip),%rsi
jmp    1295 <test_nmea_uint+0x155>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
lea    0xde9(%rip),%rsi
jmp    1295 <test_nmea_uint+0x155>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
lea    0xdee(%rip),%rsi
jmp    1295 <test_nmea_uint+0x155>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
lea    0xdf3(%rip),%rsi
jmp    1295 <test_nmea_uint+0x155>
mov    0x2d66(%rip),%rax
mov    (%rax),%edi
lea    0xdf8(%rip),%rsi
jmp    1295 <test_nmea_uint+0x155>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
lea    0xdfd(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
ret
lea    0xe14(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%eax
jmp    129c <test_nmea_uint+0x15c>

LLVM IR (-O0):
@.str = [31 x i8] c"42,1122,0531,0703,0707,65535,0\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"nmea_uint() 1: Failed\0A\00"
@.str.2 = [23 x i8] c"nmea_uint() 2: Failed\0A\00"
@.str.3 = [23 x i8] c"nmea_uint() 3: Failed\0A\00"
@.str.4 = [23 x i8] c"nmea_uint() 4: Failed\0A\00"
@.str.5 = [23 x i8] c"nmea_uint() 5: Failed\0A\00"
@.str.6 = [23 x i8] c"nmea_uint() 6: Failed\0A\00"
@.str.7 = [23 x i8] c"nmea_uint() 7: Failed\0A\00"
@.str.8 = [21 x i8] c"nmea_uint(): Passed\0A\00"
define i32 @test_nmea_uint() {
%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 ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @nmea_uint(i8* %7)
%9 = icmp ne i32 %8, 42
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %70
13: ; preds = %0
%14 = load i8*, i8** %3
%15 = call i8* @nmea_next_field(i8* %14)
store i8* %15, i8** %3
%16 = load i8*, i8** %3
%17 = call i32 @nmea_uint(i8* %16)
%18 = icmp ne i32 %17, 1122
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %70
22: ; preds = %13
%23 = load i8*, i8** %3
%24 = call i8* @nmea_next_field(i8* %23)
store i8* %24, i8** %3
%25 = load i8*, i8** %3
%26 = call i32 @nmea_uint(i8* %25)
%27 = icmp ne i32 %26, 531
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %70
31: ; preds = %22
%32 = load i8*, i8** %3
%33 = call i8* @nmea_next_field(i8* %32)
store i8* %33, i8** %3
%34 = load i8*, i8** %3
%35 = call i32 @nmea_uint(i8* %34)
%36 = icmp ne i32 %35, 703
br i1 %36, label %37, label %40
37: ; preds = %31
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %70
40: ; preds = %31
%41 = load i8*, i8** %3
%42 = call i8* @nmea_next_field(i8* %41)
store i8* %42, i8** %3
%43 = load i8*, i8** %3
%44 = call i32 @nmea_uint(i8* %43)
%45 = icmp ne i32 %44, 707
br i1 %45, label %46, label %49
46: ; preds = %40
%47 = load i32, i32* @stderr
%48 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %1
br label %70
49: ; preds = %40
%50 = load i8*, i8** %3
%51 = call i8* @nmea_next_field(i8* %50)
store i8* %51, i8** %3
%52 = load i8*, i8** %3
%53 = call i32 @nmea_uint(i8* %52)
%54 = icmp ne i32 %53, 65535
br i1 %54, label %55, label %58
55: ; preds = %49
%56 = load i32, i32* @stderr
%57 = call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %1
br label %70
58: ; preds = %49
%59 = load i8*, i8** %3
%60 = call i8* @nmea_next_field(i8* %59)
store i8* %60, i8** %3
%61 = load i8*, i8** %3
%62 = call i32 @nmea_uint(i8* %61)
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %58
%65 = load i32, i32* @stderr
%66 = call i32 @fprintf(i32 %65, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %1
br label %70
67: ; preds = %58
%68 = load i32, i32* @stderr
%69 = call i32 @fprintf(i32 %68, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %1
br label %70
70: ; preds = %67, %64, %55, %46, %37, %28, %19, %10
%71 = load i32, i32* %1
ret i32 %71
}

LLVM IR (-O2):
@.str = [31 x i8] c"42,1122,0531,0703,0707,65535,0\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"nmea_uint() 1: Failed\0A\00"
@.str.2 = [23 x i8] c"nmea_uint() 2: Failed\0A\00"
@.str.3 = [23 x i8] c"nmea_uint() 3: Failed\0A\00"
@.str.4 = [23 x i8] c"nmea_uint() 4: Failed\0A\00"
@.str.5 = [23 x i8] c"nmea_uint() 5: Failed\0A\00"
@.str.6 = [23 x i8] c"nmea_uint() 6: Failed\0A\00"
@.str.7 = [23 x i8] c"nmea_uint() 7: Failed\0A\00"
@.str.8 = [21 x i8] c"nmea_uint(): Passed\0A\00"
define i32 @test_nmea_uint() {
%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 ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @nmea_uint(i8* %2)
%5 = icmp eq i32 %4, 42
br i1 %5, label %9, label %6
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %53
9: ; preds = %0
%10 = call i8* @nmea_next_field(i8* %2)
%11 = call i32 @nmea_uint(i8* %10)
%12 = icmp eq i32 %11, 1122
br i1 %12, label %16, label %13
13: ; preds = %9
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %53
16: ; preds = %9
%17 = call i8* @nmea_next_field(i8* %10)
%18 = call i32 @nmea_uint(i8* %17)
%19 = icmp eq i32 %18, 531
br i1 %19, label %23, label %20
20: ; preds = %16
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %53
23: ; preds = %16
%24 = call i8* @nmea_next_field(i8* %17)
%25 = call i32 @nmea_uint(i8* %24)
%26 = icmp eq i32 %25, 703
br i1 %26, label %30, label %27
27: ; preds = %23
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %53
30: ; preds = %23
%31 = call i8* @nmea_next_field(i8* %24)
%32 = call i32 @nmea_uint(i8* %31)
%33 = icmp eq i32 %32, 707
br i1 %33, label %37, label %34
34: ; preds = %30
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
br label %53
37: ; preds = %30
%38 = call i8* @nmea_next_field(i8* %31)
%39 = call i32 @nmea_uint(i8* %38)
%40 = icmp eq i32 %39, 65535
br i1 %40, label %44, label %41
41: ; preds = %37
%42 = load i32, i32* @stderr
%43 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %53
44: ; preds = %37
%45 = call i8* @nmea_next_field(i8* %38)
%46 = call i32 @nmea_uint(i8* %45)
%47 = icmp eq i32 %46, 0
%48 = load i32, i32* @stderr
br i1 %47, label %51, label %49
49: ; preds = %44
%50 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
br label %53
51: ; preds = %44
%52 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
br label %53
53: ; preds = %51, %49, %41, %34, %27, %20, %13, %6
%54 = phi i32 [ 0, %6 ], [ 0, %13 ], [ 0, %20 ], [ 0, %27 ], [ 0, %34 ], [ 0, %41 ], [ 0, %49 ], [ 1, %51 ]
ret i32 %54
}