#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 */
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
size_t strlen(char const *);
char *strstr(char const *, char *);
int GetLabel_name_id(const char *lpString, char *lpName, char *lpID) {
  if (strlen(lpString) == 0) {
    return -1;
  }
  char *ptr = strstr(lpString, "BrL");
  if (ptr != NULL) {
    char lp[100] = {0};
    memcpy(lp, ptr + strlen("BrL"), 2);
    lp[2] = 0;
    int iStrLen;
    sscanf(lp, "%X", &iStrLen);
    if (*(ptr + 15) != '/') {
      return 0;
    }
    memcpy(lp, ptr + 16, iStrLen);
    lp[iStrLen] = 0;
    memcpy(lpName, lp, strlen(lp));
    lpName[strlen(lp)] = 0;
    memcpy(lpID, ptr, 15);
    lpID[15] = 0;
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<GetLabel_name_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jne    1186 <GetLabel_name_id+0x36>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c4 <GetLabel_name_id+0x174>
mov    -0x10(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12bd <GetLabel_name_id+0x16d>
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
lea    -0x90(%rbp),%rdi
mov    -0x28(%rbp),%rsi
add    $0x3,%rsi
mov    $0x2,%edx
call   1050 <memcpy@plt>
movb   $0x0,-0x8e(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xe1e(%rip),%rsi
lea    -0x94(%rbp),%rdx
call   1060 <sscanf@plt>
mov    -0x28(%rbp),%rax
movsbl 0xf(%rax),%eax
cmp    $0x2f,%eax
je     120f <GetLabel_name_id+0xbf>
movl   $0x0,-0x4(%rbp)
jmp    12c4 <GetLabel_name_id+0x174>
lea    -0x90(%rbp),%rdi
mov    -0x28(%rbp),%rsi
add    $0x10,%rsi
mov    -0x94(%rbp),%edx
call   1050 <memcpy@plt>
movslq -0x94(%rbp),%rax
movb   $0x0,-0x90(%rbp,%rax,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0xb0(%rbp)
lea    -0x90(%rbp),%rax
mov    %rax,-0xa8(%rbp)
lea    -0x90(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0xb0(%rbp),%rdi
mov    -0xa8(%rbp),%rsi
mov    %eax,%edx
call   1050 <memcpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0xa0(%rbp)
lea    -0x90(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0xa0(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0xf,%edx
call   1050 <memcpy@plt>
mov    -0x20(%rbp),%rax
movb   $0x0,0xf(%rax)
movl   $0x1,-0x4(%rbp)
jmp    12c4 <GetLabel_name_id+0x174>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetLabel_name_id>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x78,%rsp
cmpb   $0x0,(%rdi)
je     1232 <GetLabel_name_id+0xf2>
mov    %rdx,%r14
mov    %rsi,%r15
lea    0xe9f(%rip),%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     1239 <GetLabel_name_id+0xf9>
mov    %rax,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
lea    0x3(%rax),%rsi
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    $0x2,%edx
call   1040 <memcpy@plt>
movb   $0x0,0x12(%rsp)
lea    0xe47(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %r12,%rdi
call   1050 <sscanf@plt>
xor    %eax,%eax
cmpb   $0x2f,0xf(%rbx)
jne    123b <GetLabel_name_id+0xfb>
mov    %rbx,%rsi
add    $0x10,%rsi
mov    0xc(%rsp),%edx
lea    0x10(%rsp),%r12
mov    %r12,%rdi
call   1040 <memcpy@plt>
movslq 0xc(%rsp),%rax
movb   $0x0,0x10(%rsp,%rax,1)
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
movb   $0x0,(%r15,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0xf,%edx
call   1040 <memcpy@plt>
movb   $0x0,0xf(%r14)
mov    $0x1,%eax
jmp    123b <GetLabel_name_id+0xfb>
mov    $0xffffffff,%eax
jmp    123b <GetLabel_name_id+0xfb>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"BrL\00"
@.str.1 = [3 x i8] c"%X\00"
define i32 @GetLabel_name_id(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [100 x i8]
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%11 = load i8*, i8** %5
%12 = call i64 @strlen(i8* %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 -1, i32* %4
br label %60
15: ; preds = %3
%16 = load i8*, i8** %5
%17 = call i8* @strstr(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %17, i8** %8
%18 = load i8*, i8** %8
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %59
20: ; preds = %15
%21 = bitcast [100 x i8]* %9 to i8*
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%23 = load i8*, i8** %8
%24 = getelementptr inbounds i8, i8* %23, i64 3
%25 = call i32 @memcpy(i8* %22, i8* %24, i32 2)
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 2
store i8 0, i8* %26
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%28 = call i32 @sscanf(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%29 = load i8*, i8** %8
%30 = getelementptr inbounds i8, i8* %29, i64 15
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 47
br i1 %33, label %34, label %35
34: ; preds = %20
store i32 0, i32* %4
br label %60
35: ; preds = %20
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%37 = load i8*, i8** %8
%38 = getelementptr inbounds i8, i8* %37, i64 16
%39 = load i32, i32* %10
%40 = call i32 @memcpy(i8* %36, i8* %38, i32 %39)
%41 = load i32, i32* %10
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 %42
store i8 0, i8* %43
%44 = load i8*, i8** %6
%45 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%46 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%47 = call i64 @strlen(i8* %46)
%48 = trunc i64 %47 to i32
%49 = call i32 @memcpy(i8* %44, i8* %45, i32 %48)
%50 = load i8*, i8** %6
%51 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%52 = call i64 @strlen(i8* %51)
%53 = getelementptr inbounds i8, i8* %50, i64 %52
store i8 0, i8* %53
%54 = load i8*, i8** %7
%55 = load i8*, i8** %8
%56 = call i32 @memcpy(i8* %54, i8* %55, i32 15)
%57 = load i8*, i8** %7
%58 = getelementptr inbounds i8, i8* %57, i64 15
store i8 0, i8* %58
store i32 1, i32* %4
br label %60
59: ; preds = %15
store i32 0, i32* %4
br label %60
60: ; preds = %59, %35, %34, %14
%61 = load i32, i32* %4
ret i32 %61
}

LLVM IR (-O2):
@.str = [4 x i8] c"BrL\00"
@.str.1 = [3 x i8] c"%X\00"
define i32 @GetLabel_name_id(i8* %0, i8* %1, i8* %2) {
%4 = alloca [100 x i8]
%5 = alloca i32
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 0
br i1 %7, label %37, label %8
8: ; preds = %3
%9 = tail call i8* @strstr(i8* %0, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %37, label %11
11: ; preds = %8
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds i8, i8* %9, i64 3
%14 = call i32 @memcpy(i8* %12, i8* %13, i32 2)
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 2
store i8 0, i8* %15
%16 = bitcast i32* %5 to i8*
%17 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%18 = getelementptr inbounds i8, i8* %9, i64 15
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 47
br i1 %20, label %21, label %35
21: ; preds = %11
%22 = getelementptr inbounds i8, i8* %9, i64 16
%23 = load i32, i32* %5
%24 = call i32 @memcpy(i8* %12, i8* %22, i32 %23)
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %26
store i8 0, i8* %27
%28 = call i64 @strlen(i8* %12)
%29 = trunc i64 %28 to i32
%30 = call i32 @memcpy(i8* %1, i8* %12, i32 %29)
%31 = call i64 @strlen(i8* %12)
%32 = getelementptr inbounds i8, i8* %1, i64 %31
store i8 0, i8* %32
%33 = call i32 @memcpy(i8* %2, i8* %9, i32 15)
%34 = getelementptr inbounds i8, i8* %2, i64 15
store i8 0, i8* %34
br label %35
35: ; preds = %11, %21
%36 = phi i32 [ 1, %21 ], [ 0, %11 ]
br label %37
37: ; preds = %35, %8, %3
%38 = phi i32 [ -1, %3 ], [ %36, %35 ], [ 0, %8 ]
ret i32 %38
}