#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 */
char *malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int riscv_isa_next(char *, char *);
int strlen(char const *);
scalar_t__ strncasecmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *riscv_isa_to_flags(const char *isa) {
  char *flags = NULL, *ps = (char *)isa, *pd = NULL;
  char flag_buf[64] = "";
  int isa_len = 0, tl = 0, el = 0;
  if (isa) {
    isa_len = strlen(isa);
    flags = malloc(1024);
    if (flags) {
      memset(flags, 0, 1024);
      ps = (char *)isa;
      pd = flags;
      if ((strncasecmp(ps, "RV", 2) == 0)) {
        ps += 2;
      }
      if ((strncasecmp(ps, "32", 2) == 0)) {
        el = strlen("RV32");
        strncpy(pd, "RV32", el);
        strncpy(pd + el, " ", 1);
        pd += el + 1;
        ;
        ps += 2;
      } else if ((strncasecmp(ps, "64", 2) == 0)) {
        el = strlen("RV64");
        strncpy(pd, "RV64", el);
        strncpy(pd + el, " ", 1);
        pd += el + 1;
        ;
        ps += 2;
      } else if ((strncasecmp(ps, "128", 2) == 0)) {
        el = strlen("RV128");
        strncpy(pd, "RV128", el);
        strncpy(pd + el, " ", 1);
        pd += el + 1;
        ;
        ps += 3;
      }
      while ((tl = riscv_isa_next(ps, flag_buf))) {
        if (flag_buf[0] == 'G') {
          flag_buf[0] = 'I';
          el = strlen(flag_buf);
          strncpy(pd, flag_buf, el);
          strncpy(pd + el, " ", 1);
          pd += el + 1;
          ;
          flag_buf[0] = 'M';
          el = strlen(flag_buf);
          strncpy(pd, flag_buf, el);
          strncpy(pd + el, " ", 1);
          pd += el + 1;
          ;
          flag_buf[0] = 'A';
          el = strlen(flag_buf);
          strncpy(pd, flag_buf, el);
          strncpy(pd + el, " ", 1);
          pd += el + 1;
          ;
          flag_buf[0] = 'F';
          el = strlen(flag_buf);
          strncpy(pd, flag_buf, el);
          strncpy(pd + el, " ", 1);
          pd += el + 1;
          ;
          flag_buf[0] = 'D';
          el = strlen(flag_buf);
          strncpy(pd, flag_buf, el);
          strncpy(pd + el, " ", 1);
          pd += el + 1;
          ;
        } else {
          el = strlen(flag_buf);
          strncpy(pd, flag_buf, el);
          strncpy(pd + el, " ", 1);
          pd += el + 1;
          ;
        }
        ps += tl;
        if (ps - isa >= isa_len)
          break;
      }
    }
  }
  return flags;
}


x86 assembly (clang, -O0):
<riscv_isa_to_flags>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
movl   $0x0,-0x64(%rbp)
movl   $0x0,-0x68(%rbp)
movl   $0x0,-0x6c(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     15f8 <riscv_isa_to_flags+0x498>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x64(%rbp)
mov    $0x400,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     15f3 <riscv_isa_to_flags+0x493>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xdfc(%rip),%rsi
mov    $0x2,%edx
call   1080 <strncasecmp@plt>
cmp    $0x0,%rax
jne    1224 <riscv_isa_to_flags+0xc4>
mov    -0x18(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xdd6(%rip),%rsi
mov    $0x2,%edx
call   1080 <strncasecmp@plt>
cmp    $0x0,%rax
jne    12a6 <riscv_isa_to_flags+0x146>
lea    0xdb9(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x6c(%rbp),%edx
lea    0xda3(%rip),%rsi
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rdi
movslq -0x6c(%rbp),%rax
add    %rax,%rdi
lea    0xd91(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x6c(%rbp),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
jmp    13af <riscv_isa_to_flags+0x24f>
mov    -0x18(%rbp),%rdi
lea    0xd5b(%rip),%rsi
mov    $0x2,%edx
call   1080 <strncasecmp@plt>
cmp    $0x0,%rax
jne    1328 <riscv_isa_to_flags+0x1c8>
lea    0xd3e(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x6c(%rbp),%edx
lea    0xd28(%rip),%rsi
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rdi
movslq -0x6c(%rbp),%rax
add    %rax,%rdi
lea    0xd0f(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x6c(%rbp),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
jmp    13aa <riscv_isa_to_flags+0x24a>
mov    -0x18(%rbp),%rdi
lea    0xcde(%rip),%rsi
mov    $0x2,%edx
call   1080 <strncasecmp@plt>
cmp    $0x0,%rax
jne    13a5 <riscv_isa_to_flags+0x245>
lea    0xcc1(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x6c(%rbp),%edx
lea    0xcab(%rip),%rsi
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rdi
movslq -0x6c(%rbp),%rax
add    %rax,%rdi
lea    0xc8d(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x6c(%rbp),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x18(%rbp)
jmp    13aa <riscv_isa_to_flags+0x24a>
jmp    13af <riscv_isa_to_flags+0x24f>
jmp    13b4 <riscv_isa_to_flags+0x254>
mov    -0x18(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1060 <riscv_isa_next@plt>
mov    %eax,-0x68(%rbp)
cmp    $0x0,%eax
je     15ee <riscv_isa_to_flags+0x48e>
movsbl -0x60(%rbp),%eax
cmp    $0x47,%eax
jne    156f <riscv_isa_to_flags+0x40f>
movb   $0x49,-0x60(%rbp)
lea    -0x60(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x6c(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rdi
movslq -0x6c(%rbp),%rax
add    %rax,%rdi
lea    0xbfc(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x6c(%rbp),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
movb   $0x4d,-0x60(%rbp)
lea    -0x60(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x6c(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rdi
movslq -0x6c(%rbp),%rax
add    %rax,%rdi
lea    0xbac(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x6c(%rbp),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
movb   $0x41,-0x60(%rbp)
lea    -0x60(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x6c(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rdi
movslq -0x6c(%rbp),%rax
add    %rax,%rdi
lea    0xb5c(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x6c(%rbp),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
movb   $0x46,-0x60(%rbp)
lea    -0x60(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x6c(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rdi
movslq -0x6c(%rbp),%rax
add    %rax,%rdi
lea    0xb0c(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x6c(%rbp),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
movb   $0x44,-0x60(%rbp)
lea    -0x60(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x6c(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rdi
movslq -0x6c(%rbp),%rax
add    %rax,%rdi
lea    0xabc(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x6c(%rbp),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
jmp    15bb <riscv_isa_to_flags+0x45b>
lea    -0x60(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x6c(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rdi
movslq -0x6c(%rbp),%rax
add    %rax,%rdi
lea    0xa6b(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x6c(%rbp),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x68(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
movslq -0x64(%rbp),%rcx
cmp    %rcx,%rax
jl     15e9 <riscv_isa_to_flags+0x489>
jmp    15ee <riscv_isa_to_flags+0x48e>
jmp    13b4 <riscv_isa_to_flags+0x254>
jmp    15f3 <riscv_isa_to_flags+0x493>
jmp    15f8 <riscv_isa_to_flags+0x498>
mov    -0x10(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<riscv_isa_to_flags>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
test   %rdi,%rdi
je     126b <riscv_isa_to_flags+0x10b>
mov    %rdi,%rbp
call   1040 <strlen@plt>
mov    %eax,%r12d
mov    $0x400,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     126b <riscv_isa_to_flags+0x10b>
mov    %rax,%r14
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    0xe3b(%rip),%rsi
mov    %rbp,%rdi
mov    $0x2,%edx
call   1080 <strncasecmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
lea    0x0(,%rcx,2),%rbx
add    %rbp,%rbx
lea    0xe19(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1080 <strncasecmp@plt>
test   %rax,%rax
mov    %rbp,0x8(%rsp)
mov    %r14,(%rsp)
je     1272 <riscv_isa_to_flags+0x112>
lea    0xdfe(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1080 <strncasecmp@plt>
test   %rax,%rax
je     127e <riscv_isa_to_flags+0x11e>
lea    0xdea(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1080 <strncasecmp@plt>
test   %rax,%rax
jne    12d5 <riscv_isa_to_flags+0x175>
mov    %rbx,%r13
lea    0xdc8(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    (%rsp),%rdi
mov    %r14,%rsi
mov    (%rsp),%rbx
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    $0x3,%r15d
jmp    12aa <riscv_isa_to_flags+0x14a>
xor    %eax,%eax
jmp    1483 <riscv_isa_to_flags+0x323>
mov    %rbx,%r13
lea    0xd87(%rip),%r14
jmp    1288 <riscv_isa_to_flags+0x128>
mov    %rbx,%r13
lea    0xd82(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    (%rsp),%rdi
mov    %r14,%rsi
mov    (%rsp),%rbx
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    $0x2,%r15d
movslq %ebp,%rbp
lea    (%rbx,%rbp,1),%rdi
lea    0xd50(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
lea    (%rbx,%rbp,1),%r14
add    $0x1,%r14
mov    %r13,%rbx
add    %r15,%rbx
mov    0x8(%rsp),%rbp
movslq %r12d,%rax
mov    %rax,0x58(%rsp)
lea    0xd24(%rip),%r13
jmp    1344 <riscv_isa_to_flags+0x1e4>
cs nopw 0x0(%rax,%rax,1)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%r15d
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
movslq %r15d,%rbx
lea    (%r14,%rbx,1),%rdi
mov    %r13,%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
add    %rbx,%r14
add    $0x1,%r14
movslq %r12d,%rax
mov    0x60(%rsp),%rbx
add    %rax,%rbx
mov    %rbx,%rax
sub    %rbp,%rax
cmp    0x58(%rsp),%rax
jge    147f <riscv_isa_to_flags+0x31f>
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
call   1060 <riscv_isa_next@plt>
test   %eax,%eax
je     147f <riscv_isa_to_flags+0x31f>
mov    %eax,%r12d
cmpb   $0x47,0x10(%rsp)
mov    %rbx,0x60(%rsp)
jne    12f0 <riscv_isa_to_flags+0x190>
movb   $0x49,0x10(%rsp)
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
movslq %ebx,%rbp
lea    (%r14,%rbp,1),%r15
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
add    %rbp,%r14
add    $0x1,%r14
movb   $0x4d,0x10(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
movslq %ebp,%rbx
lea    (%rbx,%r15,1),%rbp
add    $0x1,%rbp
mov    %rbp,%rdi
mov    %r13,%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
lea    (%rbx,%r15,1),%r14
add    $0x2,%r14
movb   $0x41,0x10(%rsp)
lea    0x10(%rsp),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
movslq %ebx,%rbx
lea    (%rbx,%rbp,1),%r15
add    $0x1,%r15
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
lea    (%rbx,%rbp,1),%r14
add    $0x2,%r14
movb   $0x46,0x10(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
movslq %ebp,%rbx
mov    0x8(%rsp),%rbp
lea    (%rbx,%r15,1),%rdi
add    $0x1,%rdi
mov    %r13,%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
lea    (%rbx,%r15,1),%r14
add    $0x2,%r14
movb   $0x44,0x10(%rsp)
jmp    12f0 <riscv_isa_to_flags+0x190>
mov    (%rsp),%rax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"RV\00"
@.str.1 = [3 x i8] c"32\00"
@.str.2 = [5 x i8] c"RV32\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [3 x i8] c"64\00"
@.str.5 = [5 x i8] c"RV64\00"
@.str.6 = [4 x i8] c"128\00"
@.str.7 = [6 x i8] c"RV128\00"
define i8* @riscv_isa_to_flags(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [64 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %2
store i8* null, i8** %3
%10 = load i8*, i8** %2
store i8* %10, i8** %4
store i8* null, i8** %5
%11 = bitcast [64 x i8]* %6 to i8*
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
%12 = load i8*, i8** %2
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %227
14: ; preds = %1
%15 = load i8*, i8** %2
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %7
%17 = call i8* @malloc(i32 1024)
store i8* %17, i8** %3
%18 = load i8*, i8** %3
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %226
20: ; preds = %14
%21 = load i8*, i8** %3
%22 = call i32 @memset(i8* %21, i32 0, i32 1024)
%23 = load i8*, i8** %2
store i8* %23, i8** %4
%24 = load i8*, i8** %3
store i8* %24, i8** %5
%25 = load i8*, i8** %4
%26 = call i64 @strncasecmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %20
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i64 2
store i8* %30, i8** %4
br label %31
31: ; preds = %28, %20
%32 = load i8*, i8** %4
%33 = call i64 @strncasecmp(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %52
35: ; preds = %31
%36 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i32 %36, i32* %9
%37 = load i8*, i8** %5
%38 = load i32, i32* %9
%39 = call i32 @strncpy(i8* %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = load i8*, i8** %5
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = call i32 @strncpy(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%45 = load i32, i32* %9
%46 = add nsw i32 %45, 1
%47 = load i8*, i8** %5
%48 = sext i32 %46 to i64
%49 = getelementptr inbounds i8, i8* %47, i64 %48
store i8* %49, i8** %5
%50 = load i8*, i8** %4
%51 = getelementptr inbounds i8, i8* %50, i64 2
store i8* %51, i8** %4
br label %96
52: ; preds = %31
%53 = load i8*, i8** %4
%54 = call i64 @strncasecmp(i8* %53, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 2)
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %73
56: ; preds = %52
%57 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
store i32 %57, i32* %9
%58 = load i8*, i8** %5
%59 = load i32, i32* %9
%60 = call i32 @strncpy(i8* %58, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %59)
%61 = load i8*, i8** %5
%62 = load i32, i32* %9
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %61, i64 %63
%65 = call i32 @strncpy(i8* %64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%66 = load i32, i32* %9
%67 = add nsw i32 %66, 1
%68 = load i8*, i8** %5
%69 = sext i32 %67 to i64
%70 = getelementptr inbounds i8, i8* %68, i64 %69
store i8* %70, i8** %5
%71 = load i8*, i8** %4
%72 = getelementptr inbounds i8, i8* %71, i64 2
store i8* %72, i8** %4
br label %95
73: ; preds = %52
%74 = load i8*, i8** %4
%75 = call i64 @strncasecmp(i8* %74, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 2)
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %94
77: ; preds = %73
%78 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
store i32 %78, i32* %9
%79 = load i8*, i8** %5
%80 = load i32, i32* %9
%81 = call i32 @strncpy(i8* %79, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %80)
%82 = load i8*, i8** %5
%83 = load i32, i32* %9
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i8, i8* %82, i64 %84
%86 = call i32 @strncpy(i8* %85, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%87 = load i32, i32* %9
%88 = add nsw i32 %87, 1
%89 = load i8*, i8** %5
%90 = sext i32 %88 to i64
%91 = getelementptr inbounds i8, i8* %89, i64 %90
store i8* %91, i8** %5
%92 = load i8*, i8** %4
%93 = getelementptr inbounds i8, i8* %92, i64 3
store i8* %93, i8** %4
br label %94
94: ; preds = %77, %73
br label %95
95: ; preds = %94, %56
br label %96
96: ; preds = %95, %35
br label %97
97: ; preds = %224, %96
%98 = load i8*, i8** %4
%99 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%100 = call i32 @riscv_isa_next(i8* %98, i8* %99)
store i32 %100, i32* %8
%101 = icmp ne i32 %100, 0
br i1 %101, label %102, label %225
102: ; preds = %97
%103 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%104 = load i8, i8* %103
%105 = sext i8 %104 to i32
%106 = icmp eq i32 %105, 71
br i1 %106, label %107, label %193
107: ; preds = %102
%108 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
store i8 73, i8* %108
%109 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%110 = call i32 @strlen(i8* %109)
store i32 %110, i32* %9
%111 = load i8*, i8** %5
%112 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%113 = load i32, i32* %9
%114 = call i32 @strncpy(i8* %111, i8* %112, i32 %113)
%115 = load i8*, i8** %5
%116 = load i32, i32* %9
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds i8, i8* %115, i64 %117
%119 = call i32 @strncpy(i8* %118, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%120 = load i32, i32* %9
%121 = add nsw i32 %120, 1
%122 = load i8*, i8** %5
%123 = sext i32 %121 to i64
%124 = getelementptr inbounds i8, i8* %122, i64 %123
store i8* %124, i8** %5
%125 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
store i8 77, i8* %125
%126 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%127 = call i32 @strlen(i8* %126)
store i32 %127, i32* %9
%128 = load i8*, i8** %5
%129 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%130 = load i32, i32* %9
%131 = call i32 @strncpy(i8* %128, i8* %129, i32 %130)
%132 = load i8*, i8** %5
%133 = load i32, i32* %9
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds i8, i8* %132, i64 %134
%136 = call i32 @strncpy(i8* %135, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%137 = load i32, i32* %9
%138 = add nsw i32 %137, 1
%139 = load i8*, i8** %5
%140 = sext i32 %138 to i64
%141 = getelementptr inbounds i8, i8* %139, i64 %140
store i8* %141, i8** %5
%142 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
store i8 65, i8* %142
%143 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%144 = call i32 @strlen(i8* %143)
store i32 %144, i32* %9
%145 = load i8*, i8** %5
%146 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%147 = load i32, i32* %9
%148 = call i32 @strncpy(i8* %145, i8* %146, i32 %147)
%149 = load i8*, i8** %5
%150 = load i32, i32* %9
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds i8, i8* %149, i64 %151
%153 = call i32 @strncpy(i8* %152, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%154 = load i32, i32* %9
%155 = add nsw i32 %154, 1
%156 = load i8*, i8** %5
%157 = sext i32 %155 to i64
%158 = getelementptr inbounds i8, i8* %156, i64 %157
store i8* %158, i8** %5
%159 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
store i8 70, i8* %159
%160 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%161 = call i32 @strlen(i8* %160)
store i32 %161, i32* %9
%162 = load i8*, i8** %5
%163 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%164 = load i32, i32* %9
%165 = call i32 @strncpy(i8* %162, i8* %163, i32 %164)
%166 = load i8*, i8** %5
%167 = load i32, i32* %9
%168 = sext i32 %167 to i64
%169 = getelementptr inbounds i8, i8* %166, i64 %168
%170 = call i32 @strncpy(i8* %169, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%171 = load i32, i32* %9
%172 = add nsw i32 %171, 1
%173 = load i8*, i8** %5
%174 = sext i32 %172 to i64
%175 = getelementptr inbounds i8, i8* %173, i64 %174
store i8* %175, i8** %5
%176 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
store i8 68, i8* %176
%177 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%178 = call i32 @strlen(i8* %177)
store i32 %178, i32* %9
%179 = load i8*, i8** %5
%180 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%181 = load i32, i32* %9
%182 = call i32 @strncpy(i8* %179, i8* %180, i32 %181)
%183 = load i8*, i8** %5
%184 = load i32, i32* %9
%185 = sext i32 %184 to i64
%186 = getelementptr inbounds i8, i8* %183, i64 %185
%187 = call i32 @strncpy(i8* %186, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%188 = load i32, i32* %9
%189 = add nsw i32 %188, 1
%190 = load i8*, i8** %5
%191 = sext i32 %189 to i64
%192 = getelementptr inbounds i8, i8* %190, i64 %191
store i8* %192, i8** %5
br label %210
193: ; preds = %102
%194 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%195 = call i32 @strlen(i8* %194)
store i32 %195, i32* %9
%196 = load i8*, i8** %5
%197 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%198 = load i32, i32* %9
%199 = call i32 @strncpy(i8* %196, i8* %197, i32 %198)
%200 = load i8*, i8** %5
%201 = load i32, i32* %9
%202 = sext i32 %201 to i64
%203 = getelementptr inbounds i8, i8* %200, i64 %202
%204 = call i32 @strncpy(i8* %203, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%205 = load i32, i32* %9
%206 = add nsw i32 %205, 1
%207 = load i8*, i8** %5
%208 = sext i32 %206 to i64
%209 = getelementptr inbounds i8, i8* %207, i64 %208
store i8* %209, i8** %5
br label %210
210: ; preds = %193, %107
%211 = load i32, i32* %8
%212 = load i8*, i8** %4
%213 = sext i32 %211 to i64
%214 = getelementptr inbounds i8, i8* %212, i64 %213
store i8* %214, i8** %4
%215 = load i8*, i8** %4
%216 = load i8*, i8** %2
%217 = ptrtoint i8* %215 to i64
%218 = ptrtoint i8* %216 to i64
%219 = sub i64 %217, %218
%220 = load i32, i32* %7
%221 = sext i32 %220 to i64
%222 = icmp sge i64 %219, %221
br i1 %222, label %223, label %224
223: ; preds = %210
br label %225
224: ; preds = %210
br label %97
225: ; preds = %223, %97
br label %226
226: ; preds = %225, %14
br label %227
227: ; preds = %226, %1
%228 = load i8*, i8** %3
ret i8* %228
}

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