#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 */
int /*<<< orphan*/ addWord(char *, char *);
char *find(char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ mid(char *, int, int);
int strlen(char *);
char tolower(char);
void lowerCamelCase(char *word, char *newWord) {
  char *found;
  found = find(word);
  int len = strlen(found);
  if (len <= 0) {
    free(found);
    newWord[0] = tolower(newWord[0]);
    return;
  }
  addWord(newWord, found);
  free(found);
  if (strlen(word) <= len) {
    newWord[0] = tolower(newWord[0]);
    return;
  }
  mid(word, len, strlen(word) - len);
  return lowerCamelCase(word, newWord);
}


x86 assembly (clang, -O0):
<lowerCamelCase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <find@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jg     11c5 <lowerCamelCase+0x55>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1070 <tolower@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
jmp    123b <lowerCamelCase+0xcb>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1090 <addWord@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    -0x1c(%rbp),%eax
jg     1206 <lowerCamelCase+0x96>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1070 <tolower@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
jmp    123b <lowerCamelCase+0xcb>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    %eax,%edx
sub    -0x1c(%rbp),%edx
call   1050 <mid@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <lowerCamelCase@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lowerCamelCase>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1060 <find@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11de <lowerCamelCase+0x7e>
mov    %eax,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <addWord@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
cmp    %ebp,%eax
jle    11e6 <lowerCamelCase+0x86>
mov    %r15,%rdi
call   1040 <strlen@plt>
sub    %ebp,%eax
mov    %r15,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1050 <mid@plt>
mov    %r15,%rdi
call   1060 <find@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
test   %eax,%eax
jg     1190 <lowerCamelCase+0x30>
mov    %rbx,%rdi
call   1030 <free@plt>
movsbl (%r14),%edi
call   1070 <tolower@plt>
mov    %al,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @lowerCamelCase(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i8* @find(i8* %7)
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = icmp sle i32 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %2
%14 = load i8*, i8** %5
%15 = call i32 @free(i8* %14)
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = call signext i8 @tolower(i8 signext %18)
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i64 0
store i8 %19, i8* %21
br label %49
22: ; preds = %2
%23 = load i8*, i8** %4
%24 = load i8*, i8** %5
%25 = call i32 @addWord(i8* %23, i8* %24)
%26 = load i8*, i8** %5
%27 = call i32 @free(i8* %26)
%28 = load i8*, i8** %3
%29 = call i32 @strlen(i8* %28)
%30 = load i32, i32* %6
%31 = icmp sle i32 %29, %30
br i1 %31, label %32, label %39
32: ; preds = %22
%33 = load i8*, i8** %4
%34 = getelementptr inbounds i8, i8* %33, i64 0
%35 = load i8, i8* %34
%36 = call signext i8 @tolower(i8 signext %35)
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i64 0
store i8 %36, i8* %38
br label %49
39: ; preds = %22
%40 = load i8*, i8** %3
%41 = load i32, i32* %6
%42 = load i8*, i8** %3
%43 = call i32 @strlen(i8* %42)
%44 = load i32, i32* %6
%45 = sub nsw i32 %43, %44
%46 = call i32 @mid(i8* %40, i32 %41, i32 %45)
%47 = load i8*, i8** %3
%48 = load i8*, i8** %4
br label %49
49: ; preds = %39, %32, %13
ret void
}

LLVM IR (-O2):
define void @lowerCamelCase(i8* %0, i8* %1) {
%3 = tail call i8* @find(i8* %0)
%4 = tail call i32 @strlen(i8* %3)
%5 = icmp slt i32 %4, 1
br i1 %5, label %6, label %9
6: ; preds = %16, %2
%7 = phi i8* [ %3, %2 ], [ %20, %16 ]
%8 = tail call i32 @free(i8* %7)
br label %23
9: ; preds = %2, %16
%10 = phi i32 [ %21, %16 ], [ %4, %2 ]
%11 = phi i8* [ %20, %16 ], [ %3, %2 ]
%12 = tail call i32 @addWord(i8* %1, i8* %11)
%13 = tail call i32 @free(i8* %11)
%14 = tail call i32 @strlen(i8* %0)
%15 = icmp sgt i32 %14, %10
br i1 %15, label %16, label %23
16: ; preds = %9
%17 = tail call i32 @strlen(i8* %0)
%18 = sub nsw i32 %17, %10
%19 = tail call i32 @mid(i8* %0, i32 %10, i32 %18)
%20 = tail call i8* @find(i8* %0)
%21 = tail call i32 @strlen(i8* %20)
%22 = icmp slt i32 %21, 1
br i1 %22, label %6, label %9
23: ; preds = %9, %6
%24 = load i8, i8* %1
%25 = tail call signext i8 @tolower(i8 signext %24)
store i8 %25, i8* %1
ret void
}