#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 */
typedef int wchar_t;

/* Variables and functions */
int /*<<< orphan*/ extract_class(int **, int **);
int /*<<< orphan*/ extract_name(int **, int **);
int *malloc(int);
int mywcscspn(int const *, char *, int);
int /*<<< orphan*/ wmemcpy(int *, int const *, int);
int read_type(const wchar_t **text, wchar_t **type, wchar_t **name,
              wchar_t **cls) {
  int len = mywcscspn(*text, L" \t\r\n:{}", 0x01 | 0x02);
  if ((*text)[len] == L':' || len == 0)
    return 0;
  *type = malloc((len + 1) * sizeof(wchar_t));
  wmemcpy(*type, *text, len);
  (*type)[len] = 0;
  *text += len;
  extract_name(type, name);
  extract_class(type, cls);
  return 1;
}


x86 assembly (clang, -O0):
<read_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe8a(%rip),%rsi
mov    $0x3,%edx
call   1030 <mywcscspn@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x2c(%rbp),%rcx
cmpl   $0x3a,(%rax,%rcx,4)
je     11a2 <read_type+0x52>
cmpl   $0x0,-0x2c(%rbp)
jne    11ae <read_type+0x5e>
movl   $0x0,-0x4(%rbp)
jmp    122b <read_type+0xdb>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x2c(%rbp),%edx
call   1040 <wmemcpy@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movslq -0x2c(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x2c(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
movslq %edx,%rdx
shl    $0x2,%rdx
add    %rdx,%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <extract_name@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <extract_class@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_type>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
mov    (%rdi),%rdi
lea    0xe91(%rip),%rsi
mov    $0x3,%edx
call   1030 <mywcscspn@plt>
mov    0x0(%r13),%rdx
movslq %eax,%rbx
xor    %ecx,%ecx
cmpl   $0x3a,(%rdx,%rbx,4)
je     11d8 <read_type+0x88>
test   %eax,%eax
je     11d8 <read_type+0x88>
lea    0x4(,%rax,4),%edi
call   1070 <malloc@plt>
mov    %rax,(%r12)
mov    0x0(%r13),%rsi
mov    %rax,%rdi
mov    %ebx,%edx
call   1040 <wmemcpy@plt>
mov    (%r12),%rax
movl   $0x0,(%rax,%rbx,4)
shl    $0x2,%rbx
add    %rbx,0x0(%r13)
mov    %r12,%rdi
mov    %r15,%rsi
call   1060 <extract_name@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1050 <extract_class@plt>
mov    $0x1,%ecx
mov    %ecx,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i32] [i32 32, i32 9, i32 13, i32 10, i32 58, i32 123, i32 125, i32 0]
define i32 @read_type(i32** %0, i32** %1, i32** %2, i32** %3) {
%5 = alloca i32
%6 = alloca i32**
%7 = alloca i32**
%8 = alloca i32**
%9 = alloca i32**
%10 = alloca i32
store i32** %0, i32*** %6
store i32** %1, i32*** %7
store i32** %2, i32*** %8
store i32** %3, i32*** %9
%11 = load i32**, i32*** %6
%12 = load i32*, i32** %11
%13 = call i32 @mywcscspn(i32* %12, i8* bitcast ([8 x i32]* @.str to i8*), i32 3)
store i32 %13, i32* %10
%14 = load i32**, i32*** %6
%15 = load i32*, i32** %14
%16 = load i32, i32* %10
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 58
br i1 %20, label %24, label %21
21: ; preds = %4
%22 = load i32, i32* %10
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %21, %4
store i32 0, i32* %5
br label %55
25: ; preds = %21
%26 = load i32, i32* %10
%27 = add nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = mul i64 %28, 4
%30 = trunc i64 %29 to i32
%31 = call i32* @malloc(i32 %30)
%32 = load i32**, i32*** %7
store i32* %31, i32** %32
%33 = load i32**, i32*** %7
%34 = load i32*, i32** %33
%35 = load i32**, i32*** %6
%36 = load i32*, i32** %35
%37 = load i32, i32* %10
%38 = call i32 @wmemcpy(i32* %34, i32* %36, i32 %37)
%39 = load i32**, i32*** %7
%40 = load i32*, i32** %39
%41 = load i32, i32* %10
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %40, i64 %42
store i32 0, i32* %43
%44 = load i32, i32* %10
%45 = load i32**, i32*** %6
%46 = load i32*, i32** %45
%47 = sext i32 %44 to i64
%48 = getelementptr inbounds i32, i32* %46, i64 %47
store i32* %48, i32** %45
%49 = load i32**, i32*** %7
%50 = load i32**, i32*** %8
%51 = call i32 @extract_name(i32** %49, i32** %50)
%52 = load i32**, i32*** %7
%53 = load i32**, i32*** %9
%54 = call i32 @extract_class(i32** %52, i32** %53)
store i32 1, i32* %5
br label %55
55: ; preds = %25, %24
%56 = load i32, i32* %5
ret i32 %56
}

LLVM IR (-O2):
@.str = [8 x i32] [i32 32, i32 9, i32 13, i32 10, i32 58, i32 123, i32 125, i32 0]
define i32 @read_type(i32** nocapture %0, i32** %1, i32** %2, i32** %3) {
%5 = load i32*, i32** %0
%6 = tail call i32 @mywcscspn(i32* %5, i8* bitcast ([8 x i32]* @.str to i8*), i32 3)
%7 = load i32*, i32** %0
%8 = sext i32 %6 to i64
%9 = getelementptr inbounds i32, i32* %7, i64 %8
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 58
%12 = icmp eq i32 %6, 0
%13 = select i1 %11, i1 true, i1 %12
br i1 %13, label %26, label %14
14: ; preds = %4
%15 = shl i32 %6, 2
%16 = add i32 %15, 4
%17 = tail call i32* @malloc(i32 %16)
store i32* %17, i32** %1
%18 = load i32*, i32** %0
%19 = tail call i32 @wmemcpy(i32* %17, i32* %18, i32 %6)
%20 = load i32*, i32** %1
%21 = getelementptr inbounds i32, i32* %20, i64 %8
store i32 0, i32* %21
%22 = load i32*, i32** %0
%23 = getelementptr inbounds i32, i32* %22, i64 %8
store i32* %23, i32** %0
%24 = tail call i32 @extract_name(i32** %1, i32** %2)
%25 = tail call i32 @extract_class(i32** %1, i32** %3)
br label %26
26: ; preds = %4, %14
%27 = phi i32 [ 1, %14 ], [ 0, %4 ]
ret i32 %27
}