#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 *find_next_non_whitespace(char const *);
char *find_next_whitespace(char const *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy_alloc(char **, char const *);
int /*<<< orphan*/ strncpy_alloc(char **, char const *, int);
int main() {
  const char *str = "-D /home/gurtha/terminalAppDebug";
  char *buff[2];
  int i = 0;
  for (; str; ++i) {
    const char *end_ptr = find_next_whitespace(str);
    if (end_ptr)
      strncpy_alloc(&buff[i], str, end_ptr - str);
    else
      strcpy_alloc(&buff[i], str);
    str = find_next_non_whitespace(end_ptr);
  }
  for (i = 0; i < 2; ++i)
    printf("buff[%d]: %s\n", i, buff[i]);
  printf("Application closing!\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11f1 <main+0xa1>
mov    -0x10(%rbp),%rdi
call   1060 <find_next_whitespace@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11be <main+0x6e>
movslq -0x24(%rbp),%rax
lea    -0x20(%rbp),%rdi
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1070 <strncpy_alloc@plt>
jmp    11d6 <main+0x86>
movslq -0x24(%rbp),%rax
lea    -0x20(%rbp),%rdi
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcpy_alloc@plt>
mov    -0x30(%rbp),%rdi
call   1030 <find_next_non_whitespace@plt>
mov    %rax,-0x10(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1171 <main+0x21>
movl   $0x0,-0x24(%rbp)
cmpl   $0x2,-0x24(%rbp)
jge    122a <main+0xda>
mov    -0x24(%rbp),%esi
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,8),%rdx
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11f8 <main+0xa8>
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe90(%rip),%rbx
mov    %rsp,%r14
jmp    119f <main+0x3f>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcpy_alloc@plt>
mov    %r15,%rdi
call   1030 <find_next_non_whitespace@plt>
mov    %rax,%rbx
add    $0x8,%r14
test   %rax,%rax
je     11c1 <main+0x61>
mov    %rbx,%rdi
call   1070 <find_next_whitespace@plt>
mov    %rax,%r15
test   %rax,%rax
je     1180 <main+0x20>
mov    %r15d,%edx
sub    %ebx,%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <strncpy_alloc@plt>
jmp    118b <main+0x2b>
mov    (%rsp),%rdx
lea    0xe55(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%rdx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe3c(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [33 x i8] c"-D /home/gurtha/terminalAppDebug\00"
@.str.1 = [14 x i8] c"buff[%d]: %s\0A\00"
@.str.2 = [22 x i8] c"Application closing!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [2 x i8*]
%4 = alloca i32
%5 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8** %2
store i32 0, i32* %4
br label %6
6: ; preds = %35, %0
%7 = load i8*, i8** %2
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %38
9: ; preds = %6
%10 = load i8*, i8** %2
%11 = call i8* @find_next_whitespace(i8* %10)
store i8* %11, i8** %5
%12 = load i8*, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %26
14: ; preds = %9
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 %16
%18 = load i8*, i8** %2
%19 = load i8*, i8** %5
%20 = load i8*, i8** %2
%21 = ptrtoint i8* %19 to i64
%22 = ptrtoint i8* %20 to i64
%23 = sub i64 %21, %22
%24 = trunc i64 %23 to i32
%25 = call i32 @strncpy_alloc(i8** %17, i8* %18, i32 %24)
br label %32
26: ; preds = %9
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 %28
%30 = load i8*, i8** %2
%31 = call i32 @strcpy_alloc(i8** %29, i8* %30)
br label %32
32: ; preds = %26, %14
%33 = load i8*, i8** %5
%34 = call i8* @find_next_non_whitespace(i8* %33)
store i8* %34, i8** %2
br label %35
35: ; preds = %32
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
br label %6
38: ; preds = %6
store i32 0, i32* %4
br label %39
39: ; preds = %49, %38
%40 = load i32, i32* %4
%41 = icmp slt i32 %40, 2
br i1 %41, label %42, label %52
42: ; preds = %39
%43 = load i32, i32* %4
%44 = load i32, i32* %4
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 %45
%47 = load i8*, i8** %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %43, i8* %47)
br label %49
49: ; preds = %42
%50 = load i32, i32* %4
%51 = add nsw i32 %50, 1
store i32 %51, i32* %4
br label %39
52: ; preds = %39
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"-D /home/gurtha/terminalAppDebug\00"
@.str.1 = [14 x i8] c"buff[%d]: %s\0A\00"
@str = [21 x i8] c"Application closing!\00"
define i32 @main() {
%1 = alloca [2 x i8*]
%2 = bitcast [2 x i8*]* %1 to i8*
br label %3
3: ; preds = %0, %17
%4 = phi i64 [ 0, %0 ], [ %19, %17 ]
%5 = phi i8* [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), %0 ], [ %18, %17 ]
%6 = call i8* @find_next_whitespace(i8* %5)
%7 = icmp eq i8* %6, null
%8 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 %4
br i1 %7, label %15, label %9
9: ; preds = %3
%10 = ptrtoint i8* %6 to i64
%11 = ptrtoint i8* %5 to i64
%12 = sub i64 %10, %11
%13 = trunc i64 %12 to i32
%14 = call i32 @strncpy_alloc(i8** %8, i8* %5, i32 %13)
br label %17
15: ; preds = %3
%16 = call i32 @strcpy_alloc(i8** %8, i8* %5)
br label %17
17: ; preds = %15, %9
%18 = call i8* @find_next_non_whitespace(i8* %6)
%19 = add nuw i64 %4, 1
%20 = icmp eq i8* %18, null
br i1 %20, label %21, label %3
21: ; preds = %17
%22 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 0
%23 = load i8*, i8** %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 0, i8* %23)
%25 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 1
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 1, i8* %26)
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
ret i32 0
}