#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 const);
char *getref(const char *s) {
  static char buf[1024];
  char *t = buf;
  for (;;) {
    if (*s == '\0')
      break;
    if (*s == ' ') {
      *t++ = '-';
      s++;
    } else if (*s >= '0' && *s <= '9') {
      *t++ = *s++;
    } else if (*s < 'A') {
      s++;
    } else {
      *t = tolower(*s);
      t++;
      s++;
    }
  }
  *t = '\0';
  return buf;
}


x86 assembly (clang, -O0):
<getref>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0x2f1d(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    113c <getref+0x2c>
jmp    1212 <getref+0x102>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    116f <getref+0x5f>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x2d,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    120d <getref+0xfd>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     11b6 <getref+0xa6>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jg     11b6 <getref+0xa6>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    1208 <getref+0xf8>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x41,%eax
jge    11d7 <getref+0xc7>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1203 <getref+0xf3>
mov    -0x8(%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)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1208 <getref+0xf8>
jmp    120d <getref+0xfd>
jmp    1127 <getref+0x17>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2e20(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getref>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0x2f22(%rip),%r14
jmp    112c <getref+0x1c>
movb   $0x2d,(%r14)
add    $0x1,%r14
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x20,%al
je     1120 <getref+0x10>
test   %al,%al
je     1161 <getref+0x51>
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
ja     1150 <getref+0x40>
mov    %al,(%r14)
jmp    1124 <getref+0x14>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x41,%al
jl     1128 <getref+0x18>
movsbl %al,%edi
call   1030 <tolower@plt>
mov    %al,(%r14)
jmp    1124 <getref+0x14>
movb   $0x0,(%r14)
lea    0x2ed4(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@getref.buf = internal global [1024 x i8] zeroinitializer
define i8* @getref(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @getref.buf, i64 0, i64 0), i8** %3
br label %4
4: ; preds = %55, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %4
br label %56
10: ; preds = %4
%11 = load i8*, i8** %2
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 32
br i1 %14, label %15, label %20
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %3
store i8 45, i8* %16
%18 = load i8*, i8** %2
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %2
br label %55
20: ; preds = %10
%21 = load i8*, i8** %2
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp sge i32 %23, 48
br i1 %24, label %25, label %36
25: ; preds = %20
%26 = load i8*, i8** %2
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp sle i32 %28, 57
br i1 %29, label %30, label %36
30: ; preds = %25
%31 = load i8*, i8** %2
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %2
%33 = load i8, i8* %31
%34 = load i8*, i8** %3
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %3
store i8 %33, i8* %34
br label %54
36: ; preds = %25, %20
%37 = load i8*, i8** %2
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp slt i32 %39, 65
br i1 %40, label %41, label %44
41: ; preds = %36
%42 = load i8*, i8** %2
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %2
br label %53
44: ; preds = %36
%45 = load i8*, i8** %2
%46 = load i8, i8* %45
%47 = call signext i8 @tolower(i8 signext %46)
%48 = load i8*, i8** %3
store i8 %47, i8* %48
%49 = load i8*, i8** %3
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %3
%51 = load i8*, i8** %2
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %2
br label %53
53: ; preds = %44, %41
br label %54
54: ; preds = %53, %30
br label %55
55: ; preds = %54, %15
br label %4
56: ; preds = %9
%57 = load i8*, i8** %3
store i8 0, i8* %57
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @getref.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@getref.buf = internal global [1024 x i8] zeroinitializer
define i8* @getref(i8* nocapture %0) {
br label %2
2: ; preds = %18, %1
%3 = phi i8* [ %0, %1 ], [ %20, %18 ]
%4 = phi i8* [ getelementptr inbounds ([1024 x i8], [1024 x i8]* @getref.buf, i64 0, i64 0), %1 ], [ %19, %18 ]
%5 = load i8, i8* %3
switch i8 %5, label %8 [
i8 0, label %21
i8 32, label %6
]
6: ; preds = %2
%7 = getelementptr inbounds i8, i8* %4, i64 1
store i8 45, i8* %4
br label %18
8: ; preds = %2
%9 = add i8 %5, -48
%10 = icmp ult i8 %9, 10
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = getelementptr inbounds i8, i8* %4, i64 1
store i8 %5, i8* %4
br label %18
13: ; preds = %8
%14 = icmp slt i8 %5, 65
br i1 %14, label %18, label %15
15: ; preds = %13
%16 = tail call signext i8 @tolower(i8 signext %5)
store i8 %16, i8* %4
%17 = getelementptr inbounds i8, i8* %4, i64 1
br label %18
18: ; preds = %13, %11, %15, %6
%19 = phi i8* [ %7, %6 ], [ %12, %11 ], [ %17, %15 ], [ %4, %13 ]
%20 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
21: ; preds = %2
store i8 0, i8* %4
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @getref.buf, i64 0, i64 0)
}