#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*/ fatal(char *, ...);
int /*<<< orphan*/ lib_add_map(char *, char *);
scalar_t__ strcasecmp(char *, char *);
char *strchr(char *, char);
void parse_library_map(char *str) {
  char *split = strchr(str, ':');
  if (split == NULL)
    fatal("invalid library map syntax '%s': use NAME:PATH", str);
  *split = '\0';
  if (strcasecmp(str, "work") == 0)
    fatal("use --work option to specify work library name and path");
  lib_add_map(str, split + 1);
}


x86 assembly (clang, -O0):
<parse_library_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117b <parse_library_map+0x3b>
mov    -0x8(%rbp),%rsi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1060 <fatal@plt>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11aa <parse_library_map+0x6a>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1060 <fatal@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
call   1040 <lib_add_map@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_library_map>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x3a,%esi
call   1050 <strchr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    116a <parse_library_map+0x2a>
lea    0xea0(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <fatal@plt>
movb   $0x0,(%rbx)
lea    0xebb(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    118f <parse_library_map+0x4f>
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1060 <fatal@plt>
add    $0x1,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <lib_add_map@plt>

LLVM IR (-O0):
@.str = [47 x i8] c"invalid library map syntax '%s': use NAME:PATH\00"
@.str.1 = [5 x i8] c"work\00"
@.str.2 = [56 x i8] c"use --work option to specify work library name and path\00"
define void @parse_library_map(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i8* @strchr(i8* %4, i8 signext 58)
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i32 (i8*, ...) @fatal(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %11
11: ; preds = %8, %1
%12 = load i8*, i8** %3
store i8 0, i8* %12
%13 = load i8*, i8** %2
%14 = call i64 @strcasecmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 (i8*, ...) @fatal(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %11
%19 = load i8*, i8** %2
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = call i32 @lib_add_map(i8* %19, i8* %21)
ret void
}

LLVM IR (-O2):
@.str = [47 x i8] c"invalid library map syntax '%s': use NAME:PATH\00"
@.str.1 = [5 x i8] c"work\00"
@.str.2 = [56 x i8] c"use --work option to specify work library name and path\00"
define void @parse_library_map(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 58)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 (i8*, ...) @fatal(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %6
6: ; preds = %4, %1
store i8 0, i8* %2
%7 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 (i8*, ...) @fatal(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %9, %6
%12 = getelementptr inbounds i8, i8* %2, i64 1
%13 = tail call i32 @lib_add_map(i8* %0, i8* %12)
ret void
}