#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 */
char **malloc(int);
int my_str_tw_count(char *);
int /*<<< orphan*/ my_str_tw_put(char *, char **, int);
char **my_str_to_wordtab(char *str) {
  int l;
  char **dest;
  l = my_str_tw_count(str);
  if ((dest = malloc(sizeof(char *) * (l + 1))) == NULL)
    return (NULL);
  my_str_tw_put(str, dest, l);
  dest[l] = 0;
  return (dest);
}


x86 assembly (clang, -O0):
<my_str_to_wordtab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <my_str_tw_count@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1176 <my_str_to_wordtab+0x46>
movq   $0x0,-0x8(%rbp)
jmp    119e <my_str_to_wordtab+0x6e>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <my_str_tw_put@plt>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_str_to_wordtab>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1040 <my_str_tw_count@plt>
mov    %eax,%r15d
lea    0x8(,%r15,8),%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     116e <my_str_to_wordtab+0x3e>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <my_str_tw_put@plt>
movslq %r15d,%rax
movq   $0x0,(%rbx,%rax,8)
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8** @my_str_to_wordtab(i8* %0) {
%2 = alloca i8**
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8**
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @my_str_tw_count(i8* %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = add nsw i32 %8, 1
%10 = sext i32 %9 to i64
%11 = mul i64 8, %10
%12 = trunc i64 %11 to i32
%13 = call i8** @malloc(i32 %12)
store i8** %13, i8*** %5
%14 = icmp eq i8** %13, null
br i1 %14, label %15, label %16
15: ; preds = %1
store i8** null, i8*** %2
br label %26
16: ; preds = %1
%17 = load i8*, i8** %3
%18 = load i8**, i8*** %5
%19 = load i32, i32* %4
%20 = call i32 @my_str_tw_put(i8* %17, i8** %18, i32 %19)
%21 = load i8**, i8*** %5
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
store i8* null, i8** %24
%25 = load i8**, i8*** %5
store i8** %25, i8*** %2
br label %26
26: ; preds = %16, %15
%27 = load i8**, i8*** %2
ret i8** %27
}

LLVM IR (-O2):
define i8** @my_str_to_wordtab(i8* %0) {
%2 = tail call i32 @my_str_tw_count(i8* %0)
%3 = shl i32 %2, 3
%4 = add i32 %3, 8
%5 = tail call i8** @malloc(i32 %4)
%6 = icmp eq i8** %5, null
br i1 %6, label %11, label %7
7: ; preds = %1
%8 = tail call i32 @my_str_tw_put(i8* %0, i8** %5, i32 %2)
%9 = sext i32 %2 to i64
%10 = getelementptr inbounds i8*, i8** %5, i64 %9
store i8* null, i8** %10
br label %11
11: ; preds = %1, %7
ret i8** %5
}