#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 *mangle(char *string) {
  char *p;
  while (*string == ' ')
    string++;
  p = string;
  for (p = string; *p != 0; p++) {
    if (*p == ' ')
      *p = 0;
    *p = tolower(*p);
  }
  return string;
}


x86 assembly (clang, -O0):
<mangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    113d <mangle+0x2d>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    111c <mangle+0xc>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1199 <mangle+0x89>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1174 <mangle+0x64>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    114d <mangle+0x3d>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mangle>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
nopw   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
add    $0x1,%rbx
cmp    $0x20,%al
je     1120 <mangle+0x10>
lea    -0x1(%rbx),%r14
jmp    1158 <mangle+0x48>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movb   $0x0,-0x1(%rbx)
xor    %eax,%eax
movsbl %al,%edi
call   1030 <tolower@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
cmp    $0x20,%al
je     1140 <mangle+0x30>
test   %al,%al
jne    1146 <mangle+0x36>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @mangle(i8* %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i8* [ %0, %1 ], [ %6, %2 ]
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 32
%6 = getelementptr inbounds i8, i8* %3, i64 1
br i1 %5, label %2, label %7
7: ; preds = %2, %11
%8 = phi i8 [ %15, %11 ], [ %4, %2 ]
%9 = phi i8* [ %14, %11 ], [ %3, %2 ]
switch i8 %8, label %11 [
i8 0, label %16
i8 32, label %10
]
10: ; preds = %7
store i8 0, i8* %9
br label %11
11: ; preds = %7, %10
%12 = phi i8 [ %8, %7 ], [ 0, %10 ]
%13 = tail call signext i8 @tolower(i8 signext %12)
store i8 %13, i8* %9
%14 = getelementptr inbounds i8, i8* %9, i64 1
%15 = load i8, i8* %14
br label %7
16: ; preds = %7
ret i8* %3
}