#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 scalar_t__ ptrdiff_t;

/* Variables and functions */
int /*<<< orphan*/ LoadExtByName(char *);
char *strchr(char const *, char);
size_t strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
void ProcExtsFromExtString(const char *strExtList) {
  size_t iExtListLen = strlen(strExtList);
  const char *strExtListEnd = strExtList + iExtListLen;
  const char *strCurrPos = strExtList;
  char strWorkBuff[256];
  while (*strCurrPos) {
    int iStrLen = 0;
    const char *strEndStr = strchr(strCurrPos, ' ');
    int iStop = 0;
    if (strEndStr == NULL) {
      strEndStr = strExtListEnd;
      iStop = 1;
    }
    iStrLen = (int)((ptrdiff_t)strEndStr - (ptrdiff_t)strCurrPos);
    if (iStrLen > 255)
      return;
    strncpy(strWorkBuff, strCurrPos, iStrLen);
    strWorkBuff[iStrLen] = '\0';
    LoadExtByName(strWorkBuff);
    strCurrPos = strEndStr + 1;
    if (iStop)
      break;
  }
}


x86 assembly (clang, -O0):
<ProcExtsFromExtString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     1249 <ProcExtsFromExtString+0x109>
movl   $0x0,-0x124(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1060 <strchr@plt>
mov    %rax,-0x130(%rbp)
movl   $0x0,-0x134(%rbp)
cmpq   $0x0,-0x130(%rbp)
jne    11c9 <ProcExtsFromExtString+0x89>
mov    -0x18(%rbp),%rax
mov    %rax,-0x130(%rbp)
movl   $0x1,-0x134(%rbp)
mov    -0x130(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x124(%rbp)
cmpl   $0xff,-0x124(%rbp)
jle    11f2 <ProcExtsFromExtString+0xb2>
jmp    1249 <ProcExtsFromExtString+0x109>
lea    -0x120(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x124(%rbp),%edx
call   1040 <strncpy@plt>
movslq -0x124(%rbp),%rax
movb   $0x0,-0x120(%rbp,%rax,1)
lea    -0x120(%rbp),%rdi
call   1030 <LoadExtByName@plt>
mov    -0x130(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x134(%rbp)
je     1244 <ProcExtsFromExtString+0x104>
jmp    1249 <ProcExtsFromExtString+0x109>
jmp    1170 <ProcExtsFromExtString+0x30>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ProcExtsFromExtString>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%r13
call   1050 <strlen@plt>
mov    %rax,%r15
add    %r13,%r15
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpb   $0x0,0x0(%r13)
je     11c7 <ProcExtsFromExtString+0x87>
mov    %r13,%rdi
mov    $0x20,%esi
call   1060 <strchr@plt>
test   %rax,%rax
mov    %rax,%rbp
cmove  %r15,%rbp
mov    %rbp,%rbx
sub    %r13,%rbx
cmp    $0xff,%ebx
jg     11c7 <ProcExtsFromExtString+0x87>
mov    %rax,%r12
mov    %r14,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
call   1040 <strncpy@plt>
movslq %ebx,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %r14,%rdi
call   1030 <LoadExtByName@plt>
add    $0x1,%rbp
mov    %rbp,%r13
test   %r12,%r12
jne    1170 <ProcExtsFromExtString+0x30>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ProcExtsFromExtString(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [256 x i8]
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %2
%10 = load i8*, i8** %2
%11 = call i64 @strlen(i8* %10)
store i64 %11, i64* %3
%12 = load i8*, i8** %2
%13 = load i64, i64* %3
%14 = getelementptr inbounds i8, i8* %12, i64 %13
store i8* %14, i8** %4
%15 = load i8*, i8** %2
store i8* %15, i8** %5
br label %16
16: ; preds = %52, %1
%17 = load i8*, i8** %5
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
br i1 %19, label %20, label %53
20: ; preds = %16
store i32 0, i32* %7
%21 = load i8*, i8** %5
%22 = call i8* @strchr(i8* %21, i8 signext 32)
store i8* %22, i8** %8
store i32 0, i32* %9
%23 = load i8*, i8** %8
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = load i8*, i8** %4
store i8* %26, i8** %8
store i32 1, i32* %9
br label %27
27: ; preds = %25, %20
%28 = load i8*, i8** %8
%29 = ptrtoint i8* %28 to i64
%30 = load i8*, i8** %5
%31 = ptrtoint i8* %30 to i64
%32 = sub nsw i64 %29, %31
%33 = trunc i64 %32 to i32
store i32 %33, i32* %7
%34 = load i32, i32* %7
%35 = icmp sgt i32 %34, 255
br i1 %35, label %36, label %37
36: ; preds = %27
br label %53
37: ; preds = %27
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%39 = load i8*, i8** %5
%40 = load i32, i32* %7
%41 = call i32 @strncpy(i8* %38, i8* %39, i32 %40)
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %43
store i8 0, i8* %44
%45 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%46 = call i32 @LoadExtByName(i8* %45)
%47 = load i8*, i8** %8
%48 = getelementptr inbounds i8, i8* %47, i64 1
store i8* %48, i8** %5
%49 = load i32, i32* %9
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %37
br label %53
52: ; preds = %37
br label %16
53: ; preds = %36, %51, %16
ret void
}

LLVM IR (-O2):
define void @ProcExtsFromExtString(i8* %0) {
%2 = alloca [256 x i8]
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
br label %6
6: ; preds = %19, %1
%7 = phi i8* [ %0, %1 ], [ %25, %19 ]
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %26, label %10
10: ; preds = %6
%11 = call i8* @strchr(i8* %7, i8 signext 32)
%12 = icmp eq i8* %11, null
%13 = select i1 %12, i8* %4, i8* %11
%14 = ptrtoint i8* %13 to i64
%15 = ptrtoint i8* %7 to i64
%16 = sub nsw i64 %14, %15
%17 = trunc i64 %16 to i32
%18 = icmp sgt i32 %17, 255
br i1 %18, label %26, label %19
19: ; preds = %10
%20 = call i32 @strncpy(i8* %5, i8* %7, i32 %17)
%21 = shl i64 %16, 32
%22 = ashr exact i64 %21, 32
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %22
store i8 0, i8* %23
%24 = call i32 @LoadExtByName(i8* %5)
%25 = getelementptr inbounds i8, i8* %13, i64 1
br i1 %12, label %26, label %6
26: ; preds = %19, %10, %6
ret void
}