#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 */
size_t strlen(char *);
scalar_t__ strtouint64(char *);
void parse_cos_mask_type(char *str, int *scope, unsigned *id) {
  size_t len = 0;
  ;
  ;
  ;
  len = strlen(str);
  if (len > 1 && (str[len - 1] == 'c' || str[len - 1] == 'C')) {
    *scope = 2;
    str[len - 1] = '\0';
  } else if (len > 1 && (str[len - 1] == 'd' || str[len - 1] == 'D')) {
    *scope = 1;
    str[len - 1] = '\0';
  } else {
    *scope = 0;
  }
  *id = (unsigned)strtouint64(str);
}


x86 assembly (clang, -O0):
<parse_cos_mask_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x1,-0x20(%rbp)
jbe    11a5 <parse_cos_mask_type+0x85>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x63,%eax
je     1186 <parse_cos_mask_type+0x66>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x43,%eax
jne    11a5 <parse_cos_mask_type+0x85>
mov    -0x10(%rbp),%rax
movl   $0x2,(%rax)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1210 <parse_cos_mask_type+0xf0>
cmpq   $0x1,-0x20(%rbp)
jbe    1201 <parse_cos_mask_type+0xe1>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x64,%eax
je     11e2 <parse_cos_mask_type+0xc2>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x44,%eax
jne    1201 <parse_cos_mask_type+0xe1>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    120b <parse_cos_mask_type+0xeb>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
jmp    1210 <parse_cos_mask_type+0xf0>
mov    -0x8(%rbp),%rdi
call   1040 <strtouint64@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_cos_mask_type>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x2,%rax
jb     1161 <parse_cos_mask_type+0x41>
mov    -0x1(%rax,%rbx,1),%cl
add    $0xbd,%cl
cmp    $0x21,%cl
ja     1161 <parse_cos_mask_type+0x41>
movzbl %cl,%ecx
lea    0xeb1(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
movl   $0x2,(%r15)
jmp    1171 <parse_cos_mask_type+0x51>
movl   $0x0,(%r15)
jmp    1176 <parse_cos_mask_type+0x56>
movl   $0x1,(%r15)
movb   $0x0,-0x1(%rbx,%rax,1)
mov    %rbx,%rdi
call   1040 <strtouint64@plt>
mov    %eax,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @parse_cos_mask_type(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i64
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
store i64 0, i64* %7
%8 = load i8*, i8** %4
%9 = call i64 @strlen(i8* %8)
store i64 %9, i64* %7
%10 = load i64, i64* %7
%11 = icmp ugt i64 %10, 1
br i1 %11, label %12, label %34
12: ; preds = %3
%13 = load i8*, i8** %4
%14 = load i64, i64* %7
%15 = sub i64 %14, 1
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 99
br i1 %19, label %28, label %20
20: ; preds = %12
%21 = load i8*, i8** %4
%22 = load i64, i64* %7
%23 = sub i64 %22, 1
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 67
br i1 %27, label %28, label %34
28: ; preds = %20, %12
%29 = load i32*, i32** %5
store i32 2, i32* %29
%30 = load i8*, i8** %4
%31 = load i64, i64* %7
%32 = sub i64 %31, 1
%33 = getelementptr inbounds i8, i8* %30, i64 %32
store i8 0, i8* %33
br label %62
34: ; preds = %20, %3
%35 = load i64, i64* %7
%36 = icmp ugt i64 %35, 1
br i1 %36, label %37, label %59
37: ; preds = %34
%38 = load i8*, i8** %4
%39 = load i64, i64* %7
%40 = sub i64 %39, 1
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 100
br i1 %44, label %53, label %45
45: ; preds = %37
%46 = load i8*, i8** %4
%47 = load i64, i64* %7
%48 = sub i64 %47, 1
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 68
br i1 %52, label %53, label %59
53: ; preds = %45, %37
%54 = load i32*, i32** %5
store i32 1, i32* %54
%55 = load i8*, i8** %4
%56 = load i64, i64* %7
%57 = sub i64 %56, 1
%58 = getelementptr inbounds i8, i8* %55, i64 %57
store i8 0, i8* %58
br label %61
59: ; preds = %45, %34
%60 = load i32*, i32** %5
store i32 0, i32* %60
br label %61
61: ; preds = %59, %53
br label %62
62: ; preds = %61, %28
%63 = load i8*, i8** %4
%64 = call i64 @strtouint64(i8* %63)
%65 = trunc i64 %64 to i32
%66 = load i32*, i32** %6
store i32 %65, i32* %66
ret void
}

LLVM IR (-O2):
define void @parse_cos_mask_type(i8* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%5 = icmp ugt i64 %4, 1
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = add i64 %4, -1
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
switch i8 %9, label %12 [
i8 99, label %10
i8 67, label %10
i8 100, label %11
i8 68, label %11
]
10: ; preds = %6, %6
store i32 2, i32* %1
store i8 0, i8* %8
br label %13
11: ; preds = %6, %6
store i32 1, i32* %1
store i8 0, i8* %8
br label %13
12: ; preds = %6, %3
store i32 0, i32* %1
br label %13
13: ; preds = %11, %12, %10
%14 = tail call i64 @strtouint64(i8* %0)
%15 = trunc i64 %14 to i32
store i32 %15, i32* %2
ret void
}