#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 == 'D') || (*s == 'd'))
    return (1);
  else if ((*s == 'T') || (*s == 't'))
    return (2);
  else if ((*s == 'P') || (*s == 'p'))
    return (3);
  else if ((*s == 'N') || (*s == 'n'))
    return (4);
  else if ((*s == 'S') || (*s == 's'))
    return (6);
  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 == 'E') || (*s == 'e'))
    return (7);
  else
    return (0);
}


x86 assembly (clang, -O0):
<str2fmt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x44,%eax
je     113c <str2fmt+0x2c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x64,%eax
jne    1148 <str2fmt+0x38>
movl   $0x1,-0x4(%rbp)
jmp    12af <str2fmt+0x19f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x54,%eax
je     1168 <str2fmt+0x58>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x74,%eax
jne    1174 <str2fmt+0x64>
movl   $0x2,-0x4(%rbp)
jmp    12af <str2fmt+0x19f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x50,%eax
je     1194 <str2fmt+0x84>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x70,%eax
jne    11a0 <str2fmt+0x90>
movl   $0x3,-0x4(%rbp)
jmp    12af <str2fmt+0x19f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4e,%eax
je     11c0 <str2fmt+0xb0>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x6e,%eax
jne    11cc <str2fmt+0xbc>
movl   $0x4,-0x4(%rbp)
jmp    12af <str2fmt+0x19f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x53,%eax
je     11ec <str2fmt+0xdc>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x73,%eax
jne    11f8 <str2fmt+0xe8>
movl   $0x6,-0x4(%rbp)
jmp    12af <str2fmt+0x19f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x31,%eax
je     1270 <str2fmt+0x160>
mov    -0x10(%rbp),%rdi
lea    0xded(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1270 <str2fmt+0x160>
mov    -0x10(%rbp),%rdi
lea    0xdda(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1270 <str2fmt+0x160>
mov    -0x10(%rbp),%rdi
lea    0xdc7(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1270 <str2fmt+0x160>
mov    -0x10(%rbp),%rdi
lea    0xdb1(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    127c <str2fmt+0x16c>
movl   $0x5,-0x4(%rbp)
jmp    12af <str2fmt+0x19f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x45,%eax
je     129c <str2fmt+0x18c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x65,%eax
jne    12a8 <str2fmt+0x198>
movl   $0x7,-0x4(%rbp)
jmp    12af <str2fmt+0x19f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str2fmt>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%cl
add    $0xcf,%cl
cmp    $0x43,%cl
ja     1154 <str2fmt+0x44>
mov    $0x1,%eax
movzbl %cl,%ecx
lea    0xed3(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
pop    %rbx
ret
mov    $0x4,%eax
pop    %rbx
ret
mov    $0x3,%eax
pop    %rbx
ret
mov    $0x6,%eax
pop    %rbx
ret
mov    $0x2,%eax
pop    %rbx
ret
lea    0xfb5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b6 <str2fmt+0xa6>
lea    0xfa8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b6 <str2fmt+0xa6>
lea    0xf9b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b6 <str2fmt+0xa6>
lea    0xf8b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b6 <str2fmt+0xa6>
mov    (%rbx),%al
and    $0xdf,%al
xor    %ecx,%ecx
cmp    $0x45,%al
mov    $0x7,%eax
cmovne %ecx,%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 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = icmp eq i32 %6, 68
br i1 %7, label %13, label %8
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 100
br i1 %12, label %13, label %14
13: ; preds = %8, %1
store i32 1, i32* %2
br label %92
14: ; preds = %8
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 84
br i1 %18, label %24, label %19
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 116
br i1 %23, label %24, label %25
24: ; preds = %19, %14
store i32 2, i32* %2
br label %92
25: ; preds = %19
%26 = load i8*, i8** %3
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 80
br i1 %29, label %35, label %30
30: ; preds = %25
%31 = load i8*, i8** %3
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 112
br i1 %34, label %35, label %36
35: ; preds = %30, %25
store i32 3, i32* %2
br label %92
36: ; preds = %30
%37 = load i8*, i8** %3
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 78
br i1 %40, label %46, label %41
41: ; preds = %36
%42 = load i8*, i8** %3
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 110
br i1 %45, label %46, label %47
46: ; preds = %41, %36
store i32 4, i32* %2
br label %92
47: ; preds = %41
%48 = load i8*, i8** %3
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 83
br i1 %51, label %57, label %52
52: ; preds = %47
%53 = load i8*, i8** %3
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 115
br i1 %56, label %57, label %58
57: ; preds = %52, %47
store i32 6, i32* %2
br label %92
58: ; preds = %52
%59 = load i8*, i8** %3
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 49
br i1 %62, label %79, label %63
63: ; preds = %58
%64 = load i8*, i8** %3
%65 = call i64 @strcmp(i8* %64, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%66 = icmp eq i64 %65, 0
br i1 %66, label %79, label %67
67: ; preds = %63
%68 = load i8*, i8** %3
%69 = call i64 @strcmp(i8* %68, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%70 = icmp eq i64 %69, 0
br i1 %70, label %79, label %71
71: ; preds = %67
%72 = load i8*, i8** %3
%73 = call i64 @strcmp(i8* %72, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%74 = icmp eq i64 %73, 0
br i1 %74, label %79, 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.3, i64 0, i64 0))
%78 = icmp eq i64 %77, 0
br i1 %78, label %79, label %80
79: ; preds = %75, %71, %67, %63, %58
store i32 5, i32* %2
br label %92
80: ; preds = %75
%81 = load i8*, i8** %3
%82 = load i8, i8* %81
%83 = sext i8 %82 to i32
%84 = icmp eq i32 %83, 69
br i1 %84, label %90, label %85
85: ; preds = %80
%86 = load i8*, i8** %3
%87 = load i8, i8* %86
%88 = sext i8 %87 to i32
%89 = icmp eq i32 %88, 101
br i1 %89, label %90, label %91
90: ; preds = %85, %80
store i32 7, i32* %2
br label %92
91: ; preds = %85
store i32 0, i32* %2
br label %92
92: ; preds = %91, %90, %79, %57, %46, %35, %24, %13
%93 = load i32, i32* %2
ret i32 %93
}

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 = load i8, i8* %0
switch i8 %2, label %7 [
i8 68, label %25
i8 100, label %25
i8 84, label %3
i8 116, label %3
i8 80, label %4
i8 112, label %4
i8 78, label %5
i8 110, label %5
i8 83, label %6
i8 115, label %6
i8 49, label %19
]
3: ; preds = %1, %1
br label %25
4: ; preds = %1, %1
br label %25
5: ; preds = %1, %1
br label %25
6: ; preds = %1, %1
br label %25
7: ; preds = %1
%8 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %7
%11 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %10
%14 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %1, %16, %13, %10, %7
br label %25
20: ; preds = %16
%21 = load i8, i8* %0
%22 = and i8 %21, -33
%23 = icmp eq i8 %22, 69
%24 = select i1 %23, i32 7, i32 0
br label %25
25: ; preds = %20, %1, %1, %19, %6, %5, %4, %3
%26 = phi i32 [ 2, %3 ], [ 3, %4 ], [ 4, %5 ], [ 6, %6 ], [ 5, %19 ], [ 1, %1 ], [ 1, %1 ], [ %24, %20 ]
ret i32 %26
}