#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__ isspace(unsigned char);
int strlen(char const *);
int /*<<< orphan*/ strncmp(char const *, char *, int);
int v3_check_generic(const char **value) {
  int gen_type = 0;
  const char *p = *value;
  if ((strlen(p) >= 4) && !strncmp(p, "DER:", 4)) {
    p += 4;
    gen_type = 1;
  } else if ((strlen(p) >= 5) && !strncmp(p, "ASN1:", 5)) {
    p += 5;
    gen_type = 2;
  } else
    return 0;
  while (isspace((unsigned char)*p))
    p++;
  *value = p;
  return gen_type;
}


x86 assembly (clang, -O0):
<v3_check_generic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x4,%eax
jl     1196 <v3_check_generic+0x66>
mov    -0x20(%rbp),%rdi
lea    0xe95(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1196 <v3_check_generic+0x66>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x14(%rbp)
jmp    11ef <v3_check_generic+0xbf>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x5,%eax
jl     11de <v3_check_generic+0xae>
mov    -0x20(%rbp),%rdi
lea    0xe52(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11de <v3_check_generic+0xae>
mov    -0x20(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x20(%rbp)
movl   $0x2,-0x14(%rbp)
jmp    11ea <v3_check_generic+0xba>
movl   $0x0,-0x4(%rbp)
jmp    122c <v3_check_generic+0xfc>
jmp    11ef <v3_check_generic+0xbf>
jmp    11f4 <v3_check_generic+0xc4>
mov    -0x20(%rbp),%rax
movzbl (%rax),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     121b <v3_check_generic+0xeb>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11f4 <v3_check_generic+0xc4>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<v3_check_generic>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    (%rdi),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x4,%eax
jl     115f <v3_check_generic+0x2f>
lea    0xeb2(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1192 <v3_check_generic+0x62>
mov    %rbx,%rdi
call   1040 <strlen@plt>
xor    %ebp,%ebp
cmp    $0x5,%eax
jl     11c5 <v3_check_generic+0x95>
lea    0xe90(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    11c5 <v3_check_generic+0x95>
mov    $0x2,%ebp
mov    $0x5,%eax
jmp    119c <v3_check_generic+0x6c>
mov    $0x1,%ebp
mov    $0x4,%eax
add    %rax,%rbx
add    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1050 <isspace@plt>
test   %rax,%rax
jne    11b0 <v3_check_generic+0x80>
mov    %rbx,(%r14)
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"DER:\00"
@.str.1 = [6 x i8] c"ASN1:\00"
define i32 @v3_check_generic(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i8*
store i8** %0, i8*** %3
store i32 0, i32* %4
%6 = load i8**, i8*** %3
%7 = load i8*, i8** %6
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = call i32 @strlen(i8* %8)
%10 = icmp sge i32 %9, 4
br i1 %10, label %11, label %18
11: ; preds = %1
%12 = load i8*, i8** %5
%13 = call i32 @strncmp(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%14 = icmp ne i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %11
%16 = load i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, i64 4
store i8* %17, i8** %5
store i32 1, i32* %4
br label %31
18: ; preds = %11, %1
%19 = load i8*, i8** %5
%20 = call i32 @strlen(i8* %19)
%21 = icmp sge i32 %20, 5
br i1 %21, label %22, label %29
22: ; preds = %18
%23 = load i8*, i8** %5
%24 = call i32 @strncmp(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%25 = icmp ne i32 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %22
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i64 5
store i8* %28, i8** %5
store i32 2, i32* %4
br label %30
29: ; preds = %22, %18
store i32 0, i32* %2
br label %44
30: ; preds = %26
br label %31
31: ; preds = %30, %15
br label %32
32: ; preds = %37, %31
%33 = load i8*, i8** %5
%34 = load i8, i8* %33
%35 = call i64 @isspace(i8 zeroext %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = load i8*, i8** %5
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %5
br label %32
40: ; preds = %32
%41 = load i8*, i8** %5
%42 = load i8**, i8*** %3
store i8* %41, i8** %42
%43 = load i32, i32* %4
store i32 %43, i32* %2
br label %44
44: ; preds = %40, %29
%45 = load i32, i32* %2
ret i32 %45
}

LLVM IR (-O2):
@.str = [5 x i8] c"DER:\00"
@.str.1 = [6 x i8] c"ASN1:\00"
define i32 @v3_check_generic(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = tail call i32 @strlen(i8* %2)
%4 = icmp sgt i32 %3, 3
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = tail call i32 @strncmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%7 = icmp eq i32 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %5, %1
%9 = tail call i32 @strlen(i8* %2)
%10 = icmp sgt i32 %9, 4
br i1 %10, label %11, label %25
11: ; preds = %8
%12 = tail call i32 @strncmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %25
14: ; preds = %11, %5
%15 = phi i64 [ 4, %5 ], [ 5, %11 ]
%16 = phi i32 [ 1, %5 ], [ 2, %11 ]
%17 = getelementptr inbounds i8, i8* %2, i64 %15
br label %18
18: ; preds = %18, %14
%19 = phi i8* [ %17, %14 ], [ %23, %18 ]
%20 = load i8, i8* %19
%21 = tail call i64 @isspace(i8 zeroext %20)
%22 = icmp eq i64 %21, 0
%23 = getelementptr inbounds i8, i8* %19, i64 1
br i1 %22, label %24, label %18
24: ; preds = %18
store i8* %19, i8** %0
br label %25
25: ; preds = %8, %11, %24
%26 = phi i32 [ %16, %24 ], [ 0, %11 ], [ 0, %8 ]
ret i32 %26
}