#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 tolower(char);
char toupper(char);
void System_ToCamelCase(char *target, char *source) {
  char *p;
  char *q;
  int toUp;
  p = source;
  q = target;
  toUp = 1;
  while (*p) {
    if (*p == ' ') {
      toUp = 1;
      p++;
    }
    if (toUp) {
      *q = toupper(*p);
      toUp = 0;
    } else {
      *q = tolower(*p);
    }
    p++;
    q++;
  }
  *q = '\0';
}


x86 assembly (clang, -O0):
<System_ToCamelCase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11d2 <System_ToCamelCase+0xb2>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1177 <System_ToCamelCase+0x57>
movl   $0x1,-0x24(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11a1 <System_ToCamelCase+0x81>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
movl   $0x0,-0x24(%rbp)
jmp    11b5 <System_ToCamelCase+0x95>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <tolower@plt>
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1147 <System_ToCamelCase+0x27>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<System_ToCamelCase>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %eax,%eax
jmp    1149 <System_ToCamelCase+0x29>
xchg   %ax,%ax
add    $0x1,%rbx
movsbl (%rbx),%edi
call   1030 <toupper@plt>
mov    %al,(%r14)
add    $0x1,%rbx
add    $0x1,%r14
mov    $0x1,%al
movzbl (%rbx),%ecx
cmp    $0x20,%cl
je     1130 <System_ToCamelCase+0x10>
test   %cl,%cl
je     1163 <System_ToCamelCase+0x43>
test   $0x1,%al
je     1134 <System_ToCamelCase+0x14>
movsbl (%rbx),%edi
call   1040 <tolower@plt>
jmp    113c <System_ToCamelCase+0x1c>
movb   $0x0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @System_ToCamelCase(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
store i8* %8, i8** %5
%9 = load i8*, i8** %3
store i8* %9, i8** %6
store i32 1, i32* %7
br label %10
10: ; preds = %35, %2
%11 = load i8*, i8** %5
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 0
br i1 %13, label %14, label %40
14: ; preds = %10
%15 = load i8*, i8** %5
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 32
br i1 %18, label %19, label %22
19: ; preds = %14
store i32 1, i32* %7
%20 = load i8*, i8** %5
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %5
br label %22
22: ; preds = %19, %14
%23 = load i32, i32* %7
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load i8*, i8** %5
%27 = load i8, i8* %26
%28 = call signext i8 @toupper(i8 signext %27)
%29 = load i8*, i8** %6
store i8 %28, i8* %29
store i32 0, i32* %7
br label %35
30: ; preds = %22
%31 = load i8*, i8** %5
%32 = load i8, i8* %31
%33 = call signext i8 @tolower(i8 signext %32)
%34 = load i8*, i8** %6
store i8 %33, i8* %34
br label %35
35: ; preds = %30, %25
%36 = load i8*, i8** %5
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %5
%38 = load i8*, i8** %6
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %6
br label %10
40: ; preds = %10
%41 = load i8*, i8** %6
store i8 0, i8* %41
ret void
}

LLVM IR (-O2):
define void @System_ToCamelCase(i8* nocapture writeonly %0, i8* nocapture %1) {
br label %3
3: ; preds = %18, %2
%4 = phi i8* [ %1, %2 ], [ %21, %18 ]
%5 = phi i8* [ %0, %2 ], [ %22, %18 ]
%6 = phi i1 [ false, %2 ], [ true, %18 ]
%7 = load i8, i8* %4
switch i8 %7, label %10 [
i8 0, label %23
i8 32, label %8
]
8: ; preds = %3
%9 = getelementptr inbounds i8, i8* %4, i64 1
br label %11
10: ; preds = %3
br i1 %6, label %15, label %11
11: ; preds = %8, %10
%12 = phi i8* [ %9, %8 ], [ %4, %10 ]
%13 = load i8, i8* %12
%14 = tail call signext i8 @toupper(i8 signext %13)
br label %18
15: ; preds = %10
%16 = load i8, i8* %4
%17 = tail call signext i8 @tolower(i8 signext %16)
br label %18
18: ; preds = %15, %11
%19 = phi i8* [ %4, %15 ], [ %12, %11 ]
%20 = phi i8 [ %17, %15 ], [ %14, %11 ]
store i8 %20, i8* %5
%21 = getelementptr inbounds i8, i8* %19, i64 1
%22 = getelementptr inbounds i8, i8* %5, i64 1
br label %3
23: ; preds = %3
store i8 0, i8* %5
ret void
}