#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 */
scalar_t__ strcmp(char *, char *);
int str2fmt(char *s) {
  if (s == NULL)
    return 0;
  if ((*s == 'D') || (*s == 'd'))
    return (1);
  else if ((*s == 'T') || (*s == 't'))
    return (2);
  else if ((*s == 'N') || (*s == 'n'))
    return (4);
  else if ((*s == 'S') || (*s == 's'))
    return (6);
  else if ((*s == 'M') || (*s == 'm'))
    return (11);
  else if ((*s == '1') || (strcmp(s, "PKCS12") == 0) ||
           (strcmp(s, "pkcs12") == 0) || (strcmp(s, "P12") == 0) ||
           (strcmp(s, "p12") == 0))
    return (5);
  else if ((*s == 'P') || (*s == 'p')) {
    if (s[1] == 'V' || s[1] == 'v')
      return 12;
    else
      return (3);
  } else
    return (0);
}


x86 assembly (clang, -O0):
<str2fmt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <str2fmt+0x23>
movl   $0x0,-0x4(%rbp)
jmp    12f4 <str2fmt+0x1e4>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x44,%eax
je     1153 <str2fmt+0x43>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x64,%eax
jne    115f <str2fmt+0x4f>
movl   $0x1,-0x4(%rbp)
jmp    12f4 <str2fmt+0x1e4>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x54,%eax
je     117f <str2fmt+0x6f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x74,%eax
jne    118b <str2fmt+0x7b>
movl   $0x2,-0x4(%rbp)
jmp    12f4 <str2fmt+0x1e4>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4e,%eax
je     11ab <str2fmt+0x9b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x6e,%eax
jne    11b7 <str2fmt+0xa7>
movl   $0x4,-0x4(%rbp)
jmp    12f4 <str2fmt+0x1e4>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x53,%eax
je     11d7 <str2fmt+0xc7>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x73,%eax
jne    11e3 <str2fmt+0xd3>
movl   $0x6,-0x4(%rbp)
jmp    12f4 <str2fmt+0x1e4>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4d,%eax
je     1203 <str2fmt+0xf3>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x6d,%eax
jne    120f <str2fmt+0xff>
movl   $0xb,-0x4(%rbp)
jmp    12f4 <str2fmt+0x1e4>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x31,%eax
je     1287 <str2fmt+0x177>
mov    -0x10(%rbp),%rdi
lea    0xdd6(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1287 <str2fmt+0x177>
mov    -0x10(%rbp),%rdi
lea    0xdc3(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1287 <str2fmt+0x177>
mov    -0x10(%rbp),%rdi
lea    0xdb0(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1287 <str2fmt+0x177>
mov    -0x10(%rbp),%rdi
lea    0xd9a(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1293 <str2fmt+0x183>
movl   $0x5,-0x4(%rbp)
jmp    12f4 <str2fmt+0x1e4>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x50,%eax
je     12b3 <str2fmt+0x1a3>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x70,%eax
jne    12ed <str2fmt+0x1dd>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x56,%eax
je     12d5 <str2fmt+0x1c5>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x76,%eax
jne    12e1 <str2fmt+0x1d1>
movl   $0xc,-0x4(%rbp)
jmp    12f4 <str2fmt+0x1e4>
movl   $0x3,-0x4(%rbp)
jmp    12f4 <str2fmt+0x1e4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str2fmt>:
push   %rbx
xor    %eax,%eax
test   %rdi,%rdi
je     113d <str2fmt+0x2d>
mov    %rdi,%rbx
mov    (%rdi),%cl
add    $0xcf,%cl
cmp    $0x43,%cl
ja     115b <str2fmt+0x4b>
mov    $0x1,%eax
movzbl %cl,%ecx
lea    0xecc(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
pop    %rbx
ret
mov    $0xb,%eax
pop    %rbx
ret
mov    $0x4,%eax
pop    %rbx
ret
mov    $0x6,%eax
pop    %rbx
ret
mov    $0x2,%eax
pop    %rbx
ret
lea    0xfae(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11ce <str2fmt+0xbe>
lea    0xfa1(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11ce <str2fmt+0xbe>
lea    0xf94(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11ce <str2fmt+0xbe>
lea    0xf84(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11ce <str2fmt+0xbe>
mov    (%rbx),%cl
or     $0x20,%cl
mov    $0x0,%eax
cmp    $0x70,%cl
jne    113d <str2fmt+0x2d>
mov    0x1(%rbx),%al
and    $0xdf,%al
xor    %ecx,%ecx
cmp    $0x56,%al
sete   %cl
lea    (%rcx,%rcx,8),%eax
add    $0x3,%eax
pop    %rbx
ret
mov    $0x5,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"PKCS12\00"
@.str.1 = [7 x i8] c"pkcs12\00"
@.str.2 = [4 x i8] c"P12\00"
@.str.3 = [4 x i8] c"p12\00"
define i32 @str2fmt(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 0, i32* %2
br label %109
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 68
br i1 %11, label %17, label %12
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 100
br i1 %16, label %17, label %18
17: ; preds = %12, %7
store i32 1, i32* %2
br label %109
18: ; preds = %12
%19 = load i8*, i8** %3
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 84
br i1 %22, label %28, label %23
23: ; preds = %18
%24 = load i8*, i8** %3
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 116
br i1 %27, label %28, label %29
28: ; preds = %23, %18
store i32 2, i32* %2
br label %109
29: ; preds = %23
%30 = load i8*, i8** %3
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 78
br i1 %33, label %39, label %34
34: ; preds = %29
%35 = load i8*, i8** %3
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 110
br i1 %38, label %39, label %40
39: ; preds = %34, %29
store i32 4, i32* %2
br label %109
40: ; preds = %34
%41 = load i8*, i8** %3
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 83
br i1 %44, label %50, label %45
45: ; preds = %40
%46 = load i8*, i8** %3
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 115
br i1 %49, label %50, label %51
50: ; preds = %45, %40
store i32 6, i32* %2
br label %109
51: ; preds = %45
%52 = load i8*, i8** %3
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 77
br i1 %55, label %61, label %56
56: ; preds = %51
%57 = load i8*, i8** %3
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 109
br i1 %60, label %61, label %62
61: ; preds = %56, %51
store i32 11, i32* %2
br label %109
62: ; preds = %56
%63 = load i8*, i8** %3
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 49
br i1 %66, label %83, label %67
67: ; preds = %62
%68 = load i8*, i8** %3
%69 = call i64 @strcmp(i8* %68, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%70 = icmp eq i64 %69, 0
br i1 %70, label %83, label %71
71: ; preds = %67
%72 = load i8*, i8** %3
%73 = call i64 @strcmp(i8* %72, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%74 = icmp eq i64 %73, 0
br i1 %74, label %83, label %75
75: ; preds = %71
%76 = load i8*, i8** %3
%77 = call i64 @strcmp(i8* %76, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%78 = icmp eq i64 %77, 0
br i1 %78, label %83, label %79
79: ; preds = %75
%80 = load i8*, i8** %3
%81 = call i64 @strcmp(i8* %80, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%82 = icmp eq i64 %81, 0
br i1 %82, label %83, label %84
83: ; preds = %79, %75, %71, %67, %62
store i32 5, i32* %2
br label %109
84: ; preds = %79
%85 = load i8*, i8** %3
%86 = load i8, i8* %85
%87 = sext i8 %86 to i32
%88 = icmp eq i32 %87, 80
br i1 %88, label %94, label %89
89: ; preds = %84
%90 = load i8*, i8** %3
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = icmp eq i32 %92, 112
br i1 %93, label %94, label %108
94: ; preds = %89, %84
%95 = load i8*, i8** %3
%96 = getelementptr inbounds i8, i8* %95, i64 1
%97 = load i8, i8* %96
%98 = sext i8 %97 to i32
%99 = icmp eq i32 %98, 86
br i1 %99, label %106, label %100
100: ; preds = %94
%101 = load i8*, i8** %3
%102 = getelementptr inbounds i8, i8* %101, i64 1
%103 = load i8, i8* %102
%104 = sext i8 %103 to i32
%105 = icmp eq i32 %104, 118
br i1 %105, label %106, label %107
106: ; preds = %100, %94
store i32 12, i32* %2
br label %109
107: ; preds = %100
store i32 3, i32* %2
br label %109
108: ; preds = %89
store i32 0, i32* %2
br label %109
109: ; preds = %108, %107, %106, %83, %61, %50, %39, %28, %17, %6
%110 = load i32, i32* %2
ret i32 %110
}

LLVM IR (-O2):
@.str = [7 x i8] c"PKCS12\00"
@.str.1 = [7 x i8] c"pkcs12\00"
@.str.2 = [4 x i8] c"P12\00"
@.str.3 = [4 x i8] c"p12\00"
define i32 @str2fmt(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %30, label %3
3: ; preds = %1
%4 = load i8, i8* %0
switch i8 %4, label %9 [
i8 68, label %30
i8 100, label %30
i8 84, label %5
i8 116, label %5
i8 78, label %6
i8 110, label %6
i8 83, label %7
i8 115, label %7
i8 77, label %8
i8 109, label %8
i8 49, label %21
]
5: ; preds = %3, %3
br label %30
6: ; preds = %3, %3
br label %30
7: ; preds = %3, %3
br label %30
8: ; preds = %3, %3
br label %30
9: ; preds = %3
%10 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %21, label %12
12: ; preds = %9
%13 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %3, %18, %15, %12, %9
br label %30
22: ; preds = %18
%23 = load i8, i8* %0
switch i8 %23, label %30 [
i8 80, label %24
i8 112, label %24
]
24: ; preds = %22, %22
%25 = getelementptr inbounds i8, i8* %0, i64 1
%26 = load i8, i8* %25
%27 = and i8 %26, -33
%28 = icmp eq i8 %27, 86
%29 = select i1 %28, i32 12, i32 3
br label %30
30: ; preds = %24, %22, %3, %3, %1, %21, %8, %7, %6, %5
%31 = phi i32 [ 2, %5 ], [ 4, %6 ], [ 6, %7 ], [ 11, %8 ], [ 5, %21 ], [ 0, %1 ], [ 1, %3 ], [ 1, %3 ], [ 0, %22 ], [ %29, %24 ]
ret i32 %31
}