#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 */
scalar_t__ isupper(char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void splitNames(char string[], char *firstName, char *lastName) {
  int i = 0, strLen = strlen(string);
  for (i = 0; i <= strLen; i++) {
    if (isupper(string[i]) &&
        (isupper(string[i + 1]) || string[i + 1] == '\'')) {
      strncpy(firstName, string, i - 1);
      firstName[i] = '\0';
      strcpy(lastName, &string[i]);
    }
  }
}


x86 assembly (clang, -O0):
<splitNames>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     1215 <splitNames+0xd5>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1060 <isupper@plt>
cmp    $0x0,%rax
je     1202 <splitNames+0xc2>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1060 <isupper@plt>
cmp    $0x0,%rax
jne    11cf <splitNames+0x8f>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x27,%eax
jne    1202 <splitNames+0xc2>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x1c(%rbp),%rax
add    %rax,%rsi
call   1040 <strcpy@plt>
jmp    1207 <splitNames+0xc7>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116e <splitNames+0x2e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<splitNames>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,(%rsp)
mov    %rsi,%r15
mov    %rdi,%rbx
call   1050 <strlen@plt>
test   %eax,%eax
js     11c6 <splitNames+0x86>
mov    %eax,%r12d
add    $0x1,%r12d
xor    %r14d,%r14d
jmp    1198 <splitNames+0x58>
nopw   0x0(%rax,%rax,1)
lea    (%rbx,%rbp,1),%r13
lea    -0x1(%rbp),%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strncpy@plt>
movb   $0x0,(%r15,%rbp,1)
mov    (%rsp),%rdi
mov    %r13,%rsi
call   1040 <strcpy@plt>
cmp    %r14,%r12
je     11c6 <splitNames+0x86>
mov    %r14,%rbp
movsbl (%rbx,%r14,1),%edi
call   1060 <isupper@plt>
add    $0x1,%r14
test   %rax,%rax
je     1193 <splitNames+0x53>
movsbl 0x1(%rbx,%rbp,1),%edi
call   1060 <isupper@plt>
test   %rax,%rax
jne    1170 <splitNames+0x30>
cmpb   $0x27,0x1(%rbx,%rbp,1)
je     1170 <splitNames+0x30>
jmp    1193 <splitNames+0x53>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @splitNames(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %7
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %8
store i32 0, i32* %7
br label %11
11: ; preds = %58, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %8
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %61
15: ; preds = %11
%16 = load i8*, i8** %4
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = call i64 @isupper(i8 signext %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %57
23: ; preds = %15
%24 = load i8*, i8** %4
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %24, i64 %27
%29 = load i8, i8* %28
%30 = call i64 @isupper(i8 signext %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %41, label %32
32: ; preds = %23
%33 = load i8*, i8** %4
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %33, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 39
br i1 %40, label %41, label %57
41: ; preds = %32, %23
%42 = load i8*, i8** %5
%43 = load i8*, i8** %4
%44 = load i32, i32* %7
%45 = sub nsw i32 %44, 1
%46 = call i32 @strncpy(i8* %42, i8* %43, i32 %45)
%47 = load i8*, i8** %5
%48 = load i32, i32* %7
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
store i8 0, i8* %50
%51 = load i8*, i8** %6
%52 = load i8*, i8** %4
%53 = load i32, i32* %7
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %52, i64 %54
%56 = call i32 @strcpy(i8* %51, i8* %55)
br label %57
57: ; preds = %41, %32, %15
br label %58
58: ; preds = %57
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %11
61: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @splitNames(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp slt i32 %4, 0
br i1 %5, label %32, label %6
6: ; preds = %3
%7 = add nuw i32 %4, 1
%8 = zext i32 %7 to i64
br label %9
9: ; preds = %6, %30
%10 = phi i64 [ 0, %6 ], [ %15, %30 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = tail call i64 @isupper(i8 signext %12)
%14 = icmp eq i64 %13, 0
%15 = add nuw nsw i64 %10, 1
br i1 %14, label %30, label %16
16: ; preds = %9
%17 = getelementptr inbounds i8, i8* %0, i64 %15
%18 = load i8, i8* %17
%19 = tail call i64 @isupper(i8 signext %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = load i8, i8* %17
%23 = icmp eq i8 %22, 39
br i1 %23, label %24, label %30
24: ; preds = %21, %16
%25 = trunc i64 %10 to i32
%26 = add i32 %25, -1
%27 = tail call i32 @strncpy(i8* %1, i8* %0, i32 %26)
%28 = getelementptr inbounds i8, i8* %1, i64 %10
store i8 0, i8* %28
%29 = tail call i32 @strcpy(i8* %2, i8* %11)
br label %30
30: ; preds = %9, %21, %24
%31 = icmp eq i64 %15, %8
br i1 %31, label %32, label %9
32: ; preds = %30, %3
ret void
}