#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 */
void *calloc(int, int);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok(char *, char *);
char **getMessageParts(char *message) {
  static char **toReturn;
  char *temp;
  int i;
  toReturn = calloc(500, sizeof(char *));
  for (i = 0; i < 500; ++i)
    toReturn[i] = calloc(128, sizeof(char));
  i = 0;
  temp = strtok(message, " :!\r\n");
  while (temp != NULL) {
    strcpy(toReturn[i], temp);
    temp = strtok(NULL, " :!\r\n");
    ++i;
  }
  return toReturn;
}


x86 assembly (clang, -O0):
<getMessageParts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x1f4,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,0x2eee(%rip)
movl   $0x0,-0x14(%rbp)
cmpl   $0x1f4,-0x14(%rbp)
jge    1195 <getMessageParts+0x65>
mov    $0x80,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,%rdx
mov    0x2ec1(%rip),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1159 <getMessageParts+0x29>
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11f5 <getMessageParts+0xc5>
mov    0x2e7e(%rip),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe22(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b0 <getMessageParts+0x80>
mov    0x2e44(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getMessageParts>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x1f4,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%r15
mov    %rax,0x2eef(%rip)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x80,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    $0x1f4,%rbx
jne    1160 <getMessageParts+0x30>
lea    0xe79(%rip),%rsi
mov    %r14,%rdi
call   1050 <strtok@plt>
test   %rax,%rax
je     11c6 <getMessageParts+0x96>
xor    %ebx,%ebx
lea    0xe63(%rip),%r14
nopl   (%rax)
mov    0x2e99(%rip),%rcx
mov    (%rcx,%rbx,1),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <strtok@plt>
add    $0x8,%rbx
test   %rax,%rax
jne    11a0 <getMessageParts+0x70>
mov    0x2e73(%rip),%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@getMessageParts.toReturn = internal global i8** null
@.str = [6 x i8] c" :!\0D\0A\00"
define i8** @getMessageParts(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i8* @calloc(i32 500, i32 8)
%6 = bitcast i8* %5 to i8**
store i8** %6, i8*** @getMessageParts.toReturn
store i32 0, i32* %4
br label %7
7: ; preds = %16, %1
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 500
br i1 %9, label %10, label %19
10: ; preds = %7
%11 = call i8* @calloc(i32 128, i32 1)
%12 = load i8**, i8*** @getMessageParts.toReturn
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %12, i64 %14
store i8* %11, i8** %15
br label %16
16: ; preds = %10
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
br label %7
19: ; preds = %7
store i32 0, i32* %4
%20 = load i8*, i8** %2
%21 = call i8* @strtok(i8* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i8* %21, i8** %3
br label %22
22: ; preds = %25, %19
%23 = load i8*, i8** %3
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %36
25: ; preds = %22
%26 = load i8**, i8*** @getMessageParts.toReturn
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = load i8*, i8** %3
%32 = call i32 @strcpy(i8* %30, i8* %31)
%33 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i8* %33, i8** %3
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %22
36: ; preds = %22
%37 = load i8**, i8*** @getMessageParts.toReturn
ret i8** %37
}

LLVM IR (-O2):
@getMessageParts.toReturn = internal unnamed_addr global i8** null
@.str = [6 x i8] c" :!\0D\0A\00"
define i8** @getMessageParts(i8* %0) {
%2 = tail call dereferenceable_or_null(4000) i8* @calloc(i32 500, i32 8)
store i8* %2, i8** bitcast (i8*** @getMessageParts.toReturn to i8**)
%3 = bitcast i8* %2 to i8**
br label %4
4: ; preds = %1, %4
%5 = phi i64 [ 0, %1 ], [ %8, %4 ]
%6 = tail call dereferenceable_or_null(128) i8* @calloc(i32 128, i32 1)
%7 = getelementptr inbounds i8*, i8** %3, i64 %5
store i8* %6, i8** %7
%8 = add nuw nsw i64 %5, 1
%9 = icmp eq i64 %8, 500
br i1 %9, label %10, label %4
10: ; preds = %4
%11 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %23, label %13
13: ; preds = %10, %13
%14 = phi i64 [ %21, %13 ], [ 0, %10 ]
%15 = phi i8* [ %20, %13 ], [ %11, %10 ]
%16 = load i8**, i8*** @getMessageParts.toReturn
%17 = getelementptr inbounds i8*, i8** %16, i64 %14
%18 = load i8*, i8** %17
%19 = tail call i32 @strcpy(i8* %18, i8* %15)
%20 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%21 = add nuw i64 %14, 1
%22 = icmp eq i8* %20, null
br i1 %22, label %23, label %13
23: ; preds = %13, %10
%24 = load i8**, i8*** @getMessageParts.toReturn
ret i8** %24
}