int strgetfrags(const char *str, const char *delimiter, char ***frags) {
  int i, num;
  char *p, **pp;
  num = strfragnum(str, delimiter);
  if (!num)
    return 0;
  p = xstrdup(str);
  pp = (char **)xcalloc(num, sizeof(char *));
  split(p, delimiter, pp, num);
  *frags = (char **)xcalloc(num, sizeof(char *));
  for (i = 0; i < num; i++) {
    trim(pp[i]);
    (*frags)[i] = xstrdup(pp[i]);
  }
  xfree(p);
  xfree(pp);
  return num;
}


x86 assembly (clang, -O0):
<strgetfrags>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1030 <strfragnum@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    119c <strgetfrags+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    1266 <strgetfrags+0x106>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1060 <xstrdup@plt>
cltq
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%edi
mov    $0x8,%esi
mov    $0x0,%al
call   1080 <xcalloc@plt>
cltq
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x28(%rbp),%ecx
mov    $0x0,%al
call   1070 <split@plt>
mov    -0x28(%rbp),%edi
mov    $0x8,%esi
mov    $0x0,%al
call   1080 <xcalloc@plt>
movslq %eax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    124a <strgetfrags+0xea>
mov    -0x38(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x0,%al
call   1050 <trim@plt>
mov    -0x38(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x0,%al
call   1060 <xstrdup@plt>
movslq %eax,%rdx
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11f8 <strgetfrags+0x98>
mov    -0x30(%rbp),%rdi
mov    $0x0,%al
call   1040 <xfree@plt>
mov    -0x38(%rbp),%rdi
mov    $0x0,%al
call   1040 <xfree@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strgetfrags>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r13
mov    %rsi,%r12
mov    %rdi,%rbp
xor    %eax,%eax
call   1030 <strfragnum@plt>
mov    %eax,%r15d
test   %eax,%eax
je     121f <strgetfrags+0xbf>
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <xstrdup@plt>
movslq %eax,%r14
mov    $0x8,%esi
mov    %r15d,%edi
xor    %eax,%eax
call   1080 <xcalloc@plt>
movslq %eax,%rbp
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
mov    %r15d,%ecx
xor    %eax,%eax
call   1070 <split@plt>
mov    $0x8,%esi
mov    %r15d,%edi
xor    %eax,%eax
call   1080 <xcalloc@plt>
cltq
mov    %rax,0x0(%r13)
test   %r15d,%r15d
jle    120b <strgetfrags+0xab>
mov    %r15d,%r12d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    0x0(%rbp,%rbx,8),%rdi
xor    %eax,%eax
call   1050 <trim@plt>
mov    0x0(%rbp,%rbx,8),%rdi
xor    %eax,%eax
call   1060 <xstrdup@plt>
cltq
mov    0x0(%r13),%rcx
mov    %rax,(%rcx,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11e0 <strgetfrags+0x80>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <xfree@plt>
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <xfree@plt>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @strgetfrags(i8* %0, i8* %1, i8*** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8***
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8**
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8*** %2, i8**** %7
%12 = load i8*, i8** %5
%13 = load i8*, i8** %6
%14 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @strfragnum to i32 (i8*, i8*, ...)*)(i8* %12, i8* %13)
store i32 %14, i32* %9
%15 = load i32, i32* %9
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %3
store i32 0, i32* %4
br label %70
18: ; preds = %3
%19 = load i8*, i8** %5
%20 = call i32 (i8*, ...) bitcast (i32 (...)* @xstrdup to i32 (i8*, ...)*)(i8* %19)
%21 = sext i32 %20 to i64
%22 = inttoptr i64 %21 to i8*
store i8* %22, i8** %10
%23 = load i32, i32* %9
%24 = call i32 (i32, i64, ...) bitcast (i32 (...)* @xcalloc to i32 (i32, i64, ...)*)(i32 %23, i64 8)
%25 = sext i32 %24 to i64
%26 = inttoptr i64 %25 to i8**
store i8** %26, i8*** %11
%27 = load i8*, i8** %10
%28 = load i8*, i8** %6
%29 = load i8**, i8*** %11
%30 = load i32, i32* %9
%31 = call i32 (i8*, i8*, i8**, i32, ...) bitcast (i32 (...)* @split to i32 (i8*, i8*, i8**, i32, ...)*)(i8* %27, i8* %28, i8** %29, i32 %30)
%32 = load i32, i32* %9
%33 = call i32 (i32, i64, ...) bitcast (i32 (...)* @xcalloc to i32 (i32, i64, ...)*)(i32 %32, i64 8)
%34 = sext i32 %33 to i64
%35 = inttoptr i64 %34 to i8**
%36 = load i8***, i8**** %7
store i8** %35, i8*** %36
store i32 0, i32* %8
br label %37
37: ; preds = %61, %18
%38 = load i32, i32* %8
%39 = load i32, i32* %9
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %64
41: ; preds = %37
%42 = load i8**, i8*** %11
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %42, i64 %44
%46 = load i8*, i8** %45
%47 = call i32 (i8*, ...) bitcast (i32 (...)* @trim to i32 (i8*, ...)*)(i8* %46)
%48 = load i8**, i8*** %11
%49 = load i32, i32* %8
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %48, i64 %50
%52 = load i8*, i8** %51
%53 = call i32 (i8*, ...) bitcast (i32 (...)* @xstrdup to i32 (i8*, ...)*)(i8* %52)
%54 = sext i32 %53 to i64
%55 = inttoptr i64 %54 to i8*
%56 = load i8***, i8**** %7
%57 = load i8**, i8*** %56
%58 = load i32, i32* %8
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8*, i8** %57, i64 %59
store i8* %55, i8** %60
br label %61
61: ; preds = %41
%62 = load i32, i32* %8
%63 = add nsw i32 %62, 1
store i32 %63, i32* %8
br label %37
64: ; preds = %37
%65 = load i8*, i8** %10
%66 = call i32 (i8*, ...) bitcast (i32 (...)* @xfree to i32 (i8*, ...)*)(i8* %65)
%67 = load i8**, i8*** %11
%68 = call i32 (i8**, ...) bitcast (i32 (...)* @xfree to i32 (i8**, ...)*)(i8** %67)
%69 = load i32, i32* %9
store i32 %69, i32* %4
br label %70
70: ; preds = %64, %17
%71 = load i32, i32* %4
ret i32 %71
}

LLVM IR (-O2):
define i32 @strgetfrags(i8* %0, i8* %1, i8*** nocapture %2) {
%4 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @strfragnum to i32 (i8*, i8*, ...)*)(i8* %0, i8* %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %36, label %6
6: ; preds = %3
%7 = tail call i32 (i8*, ...) bitcast (i32 (...)* @xstrdup to i32 (i8*, ...)*)(i8* %0)
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i8*
%10 = tail call i32 (i32, i64, ...) bitcast (i32 (...)* @xcalloc to i32 (i32, i64, ...)*)(i32 %4, i64 8)
%11 = sext i32 %10 to i64
%12 = inttoptr i64 %11 to i8**
%13 = tail call i32 (i8*, i8*, i8**, i32, ...) bitcast (i32 (...)* @split to i32 (i8*, i8*, i8**, i32, ...)*)(i8* %9, i8* %1, i8** %12, i32 %4)
%14 = tail call i32 (i32, i64, ...) bitcast (i32 (...)* @xcalloc to i32 (i32, i64, ...)*)(i32 %4, i64 8)
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to i8**
store i8** %16, i8*** %2
%17 = icmp sgt i32 %4, 0
br i1 %17, label %18, label %33
18: ; preds = %6
%19 = zext i32 %4 to i64
br label %20
20: ; preds = %18, %20
%21 = phi i64 [ 0, %18 ], [ %31, %20 ]
%22 = getelementptr inbounds i8*, i8** %12, i64 %21
%23 = load i8*, i8** %22
%24 = tail call i32 (i8*, ...) bitcast (i32 (...)* @trim to i32 (i8*, ...)*)(i8* %23)
%25 = load i8*, i8** %22
%26 = tail call i32 (i8*, ...) bitcast (i32 (...)* @xstrdup to i32 (i8*, ...)*)(i8* %25)
%27 = sext i32 %26 to i64
%28 = inttoptr i64 %27 to i8*
%29 = load i8**, i8*** %2
%30 = getelementptr inbounds i8*, i8** %29, i64 %21
store i8* %28, i8** %30
%31 = add nuw nsw i64 %21, 1
%32 = icmp eq i64 %31, %19
br i1 %32, label %33, label %20
33: ; preds = %20, %6
%34 = tail call i32 (i8*, ...) bitcast (i32 (...)* @xfree to i32 (i8*, ...)*)(i8* %9)
%35 = tail call i32 (i8**, ...) bitcast (i32 (...)* @xfree to i32 (i8**, ...)*)(i8** %12)
br label %36
36: ; preds = %3, %33
ret i32 %4
}