#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*/ strcmp(char *, char *);
char *strrchr(char *, char);
void decodefmt(char *path, int *fmt) {
  char *p;
  *fmt = -1;
  if ((p = strrchr(path, '#'))) {
    if (!strcmp(p, "#rtcm2"))
      *fmt = 0;
    else if (!strcmp(p, "#rtcm3"))
      *fmt = 1;
    else if (!strcmp(p, "#nov"))
      *fmt = 2;
    else if (!strcmp(p, "#oem3"))
      *fmt = 3;
    else if (!strcmp(p, "#ubx"))
      *fmt = 4;
    else if (!strcmp(p, "#ss2"))
      *fmt = 5;
    else if (!strcmp(p, "#hemis"))
      *fmt = 6;
    else if (!strcmp(p, "#stq"))
      *fmt = 7;
    else if (!strcmp(p, "#javad"))
      *fmt = 9;
    else if (!strcmp(p, "#nvs"))
      *fmt = 10;
    else
      return;
    *p = '\0';
  }
}


x86 assembly (clang, -O0):
<decodefmt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x8(%rbp),%rdi
mov    $0x23,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     131f <decodefmt+0x1ff>
mov    -0x18(%rbp),%rdi
lea    0xe9f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    117e <decodefmt+0x5e>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
jmp    1318 <decodefmt+0x1f8>
mov    -0x18(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11a6 <decodefmt+0x86>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    1313 <decodefmt+0x1f3>
mov    -0x18(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11ce <decodefmt+0xae>
mov    -0x10(%rbp),%rax
movl   $0x2,(%rax)
jmp    130e <decodefmt+0x1ee>
mov    -0x18(%rbp),%rdi
lea    0xe3a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11f6 <decodefmt+0xd6>
mov    -0x10(%rbp),%rax
movl   $0x3,(%rax)
jmp    1309 <decodefmt+0x1e9>
mov    -0x18(%rbp),%rdi
lea    0xe18(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    121e <decodefmt+0xfe>
mov    -0x10(%rbp),%rax
movl   $0x4,(%rax)
jmp    1304 <decodefmt+0x1e4>
mov    -0x18(%rbp),%rdi
lea    0xdf5(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1246 <decodefmt+0x126>
mov    -0x10(%rbp),%rax
movl   $0x5,(%rax)
jmp    12ff <decodefmt+0x1df>
mov    -0x18(%rbp),%rdi
lea    0xdd2(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    126e <decodefmt+0x14e>
mov    -0x10(%rbp),%rax
movl   $0x6,(%rax)
jmp    12fa <decodefmt+0x1da>
mov    -0x18(%rbp),%rdi
lea    0xdb1(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1296 <decodefmt+0x176>
mov    -0x10(%rbp),%rax
movl   $0x7,(%rax)
jmp    12f5 <decodefmt+0x1d5>
mov    -0x18(%rbp),%rdi
lea    0xd8e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    12be <decodefmt+0x19e>
mov    -0x10(%rbp),%rax
movl   $0x9,(%rax)
jmp    12f0 <decodefmt+0x1d0>
mov    -0x18(%rbp),%rdi
lea    0xd6d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    12e6 <decodefmt+0x1c6>
mov    -0x10(%rbp),%rax
movl   $0xa,(%rax)
jmp    12eb <decodefmt+0x1cb>
jmp    131f <decodefmt+0x1ff>
jmp    12f0 <decodefmt+0x1d0>
jmp    12f5 <decodefmt+0x1d5>
jmp    12fa <decodefmt+0x1da>
jmp    12ff <decodefmt+0x1df>
jmp    1304 <decodefmt+0x1e4>
jmp    1309 <decodefmt+0x1e9>
jmp    130e <decodefmt+0x1ee>
jmp    1313 <decodefmt+0x1f3>
jmp    1318 <decodefmt+0x1f8>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decodefmt>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
movl   $0xffffffff,(%rsi)
mov    $0x23,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     1258 <decodefmt+0x138>
mov    %rax,%rbx
lea    0xeb6(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1218 <decodefmt+0xf8>
lea    0xea6(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     121c <decodefmt+0xfc>
lea    0xe96(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1223 <decodefmt+0x103>
lea    0xe84(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     122a <decodefmt+0x10a>
lea    0xe73(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1231 <decodefmt+0x111>
lea    0xe65(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1238 <decodefmt+0x118>
lea    0xe57(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     123f <decodefmt+0x11f>
lea    0xe4b(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1246 <decodefmt+0x126>
lea    0xe3d(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     124d <decodefmt+0x12d>
lea    0xe31(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1258 <decodefmt+0x138>
mov    $0xa,%eax
jmp    1252 <decodefmt+0x132>
xor    %eax,%eax
jmp    1252 <decodefmt+0x132>
mov    $0x1,%eax
jmp    1252 <decodefmt+0x132>
mov    $0x2,%eax
jmp    1252 <decodefmt+0x132>
mov    $0x3,%eax
jmp    1252 <decodefmt+0x132>
mov    $0x4,%eax
jmp    1252 <decodefmt+0x132>
mov    $0x5,%eax
jmp    1252 <decodefmt+0x132>
mov    $0x6,%eax
jmp    1252 <decodefmt+0x132>
mov    $0x7,%eax
jmp    1252 <decodefmt+0x132>
mov    $0x9,%eax
mov    %eax,(%r14)
movb   $0x0,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"#rtcm2\00"
@.str.1 = [7 x i8] c"#rtcm3\00"
@.str.2 = [5 x i8] c"#nov\00"
@.str.3 = [6 x i8] c"#oem3\00"
@.str.4 = [5 x i8] c"#ubx\00"
@.str.5 = [5 x i8] c"#ss2\00"
@.str.6 = [7 x i8] c"#hemis\00"
@.str.7 = [5 x i8] c"#stq\00"
@.str.8 = [7 x i8] c"#javad\00"
@.str.9 = [5 x i8] c"#nvs\00"
define void @decodefmt(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
store i8* %0, i8** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %4
store i32 -1, i32* %6
%7 = load i8*, i8** %3
%8 = call i8* @strrchr(i8* %7, i8 signext 35)
store i8* %8, i8** %5
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %82
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = call i32 @strcmp(i8* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = load i32*, i32** %4
store i32 0, i32* %15
br label %80
16: ; preds = %10
%17 = load i8*, i8** %5
%18 = call i32 @strcmp(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp ne i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %16
%21 = load i32*, i32** %4
store i32 1, i32* %21
br label %79
22: ; preds = %16
%23 = load i8*, i8** %5
%24 = call i32 @strcmp(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %22
%27 = load i32*, i32** %4
store i32 2, i32* %27
br label %78
28: ; preds = %22
%29 = load i8*, i8** %5
%30 = call i32 @strcmp(i8* %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp ne i32 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %28
%33 = load i32*, i32** %4
store i32 3, i32* %33
br label %77
34: ; preds = %28
%35 = load i8*, i8** %5
%36 = call i32 @strcmp(i8* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%37 = icmp ne i32 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %34
%39 = load i32*, i32** %4
store i32 4, i32* %39
br label %76
40: ; preds = %34
%41 = load i8*, i8** %5
%42 = call i32 @strcmp(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%43 = icmp ne i32 %42, 0
br i1 %43, label %46, label %44
44: ; preds = %40
%45 = load i32*, i32** %4
store i32 5, i32* %45
br label %75
46: ; preds = %40
%47 = load i8*, i8** %5
%48 = call i32 @strcmp(i8* %47, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%49 = icmp ne i32 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %46
%51 = load i32*, i32** %4
store i32 6, i32* %51
br label %74
52: ; preds = %46
%53 = load i8*, i8** %5
%54 = call i32 @strcmp(i8* %53, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%55 = icmp ne i32 %54, 0
br i1 %55, label %58, label %56
56: ; preds = %52
%57 = load i32*, i32** %4
store i32 7, i32* %57
br label %73
58: ; preds = %52
%59 = load i8*, i8** %5
%60 = call i32 @strcmp(i8* %59, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%61 = icmp ne i32 %60, 0
br i1 %61, label %64, label %62
62: ; preds = %58
%63 = load i32*, i32** %4
store i32 9, i32* %63
br label %72
64: ; preds = %58
%65 = load i8*, i8** %5
%66 = call i32 @strcmp(i8* %65, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%67 = icmp ne i32 %66, 0
br i1 %67, label %70, label %68
68: ; preds = %64
%69 = load i32*, i32** %4
store i32 10, i32* %69
br label %71
70: ; preds = %64
br label %82
71: ; preds = %68
br label %72
72: ; preds = %71, %62
br label %73
73: ; preds = %72, %56
br label %74
74: ; preds = %73, %50
br label %75
75: ; preds = %74, %44
br label %76
76: ; preds = %75, %38
br label %77
77: ; preds = %76, %32
br label %78
78: ; preds = %77, %26
br label %79
79: ; preds = %78, %20
br label %80
80: ; preds = %79, %14
%81 = load i8*, i8** %5
store i8 0, i8* %81
br label %82
82: ; preds = %70, %80, %2
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"#rtcm2\00"
@.str.1 = [7 x i8] c"#rtcm3\00"
@.str.2 = [5 x i8] c"#nov\00"
@.str.3 = [6 x i8] c"#oem3\00"
@.str.4 = [5 x i8] c"#ubx\00"
@.str.5 = [5 x i8] c"#ss2\00"
@.str.6 = [7 x i8] c"#hemis\00"
@.str.7 = [5 x i8] c"#stq\00"
@.str.8 = [7 x i8] c"#javad\00"
@.str.9 = [5 x i8] c"#nvs\00"
define void @decodefmt(i8* %0, i32* nocapture writeonly %1) {
store i32 -1, i32* %1
%3 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 35)
%4 = icmp eq i8* %3, null
br i1 %4, label %37, label %5
5: ; preds = %2
%6 = tail call i32 @strcmp(i8* %3, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %35, label %8
8: ; preds = %5
%9 = tail call i32 @strcmp(i8* %3, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %35, label %11
11: ; preds = %8
%12 = tail call i32 @strcmp(i8* %3, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %35, label %14
14: ; preds = %11
%15 = tail call i32 @strcmp(i8* %3, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %35, label %17
17: ; preds = %14
%18 = tail call i32 @strcmp(i8* %3, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %35, label %20
20: ; preds = %17
%21 = tail call i32 @strcmp(i8* %3, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
br i1 %22, label %35, label %23
23: ; preds = %20
%24 = tail call i32 @strcmp(i8* %3, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%25 = icmp eq i32 %24, 0
br i1 %25, label %35, label %26
26: ; preds = %23
%27 = tail call i32 @strcmp(i8* %3, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%28 = icmp eq i32 %27, 0
br i1 %28, label %35, label %29
29: ; preds = %26
%30 = tail call i32 @strcmp(i8* %3, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%31 = icmp eq i32 %30, 0
br i1 %31, label %35, label %32
32: ; preds = %29
%33 = tail call i32 @strcmp(i8* %3, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %32, %29, %26, %23, %20, %17, %14, %11, %8, %5
%36 = phi i32 [ 0, %5 ], [ 1, %8 ], [ 2, %11 ], [ 3, %14 ], [ 4, %17 ], [ 5, %20 ], [ 6, %23 ], [ 7, %26 ], [ 9, %29 ], [ 10, %32 ]
store i32 %36, i32* %1
store i8 0, i8* %3
br label %37
37: ; preds = %2, %35, %32
ret void
}