char *read_label(const char **code_ptr) {
  static char label_name[65536];
  char *ptr = label_name;
  const char *code = *code_ptr;
  char ch;
  while ((ch = *++code) != '\n') {
    switch (ch) {
    case ' ':
      *ptr++ = 'S';
      break;
    case '\t':
      *ptr++ = 'T';
      break;
    }
  }
  *ptr = '\0';
  *code_ptr = code;
  return label_name;
}


x86 assembly (clang, -O0):
<read_label>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
lea    0x2f21(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    0x1(%rax),%al
mov    %al,-0x19(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     1193 <read_label+0x93>
movsbl -0x19(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x9,%eax
je     117c <read_label+0x7c>
jmp    1154 <read_label+0x54>
mov    -0x20(%rbp),%eax
sub    $0x20,%eax
jne    118e <read_label+0x8e>
jmp    1165 <read_label+0x65>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x53,(%rax)
jmp    118e <read_label+0x8e>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x54,(%rax)
jmp    111e <read_label+0x1e>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
lea    0x2e84(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_label>:
mov    (%rdi),%rax
mov    0x1(%rax),%dl
add    $0x1,%rax
lea    0x2f1f(%rip),%rcx
jmp    1130 <read_label+0x30>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x53,%dl
mov    %dl,(%rcx)
add    $0x1,%rcx
movzbl 0x1(%rax),%edx
add    $0x1,%rax
cmp    $0xa,%dl
je     1146 <read_label+0x46>
movsbl %dl,%edx
cmp    $0x20,%edx
je     1120 <read_label+0x20>
cmp    $0x9,%edx
jne    1128 <read_label+0x28>
mov    $0x54,%dl
jmp    1122 <read_label+0x22>
movb   $0x0,(%rcx)
mov    %rax,(%rdi)
lea    0x2edd(%rip),%rax
ret

LLVM IR (-O0):
@read_label.label_name = internal global [65536 x i8] zeroinitializer
define i8* @read_label(i8** %0) {
%2 = alloca i8**
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
store i8** %0, i8*** %2
store i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @read_label.label_name, i64 0, i64 0), i8** %3
%6 = load i8**, i8*** %2
%7 = load i8*, i8** %6
store i8* %7, i8** %4
br label %8
8: ; preds = %23, %1
%9 = load i8*, i8** %4
%10 = getelementptr inbounds i8, i8* %9, i32 1
store i8* %10, i8** %4
%11 = load i8, i8* %10
store i8 %11, i8* %5
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 10
br i1 %13, label %14, label %24
14: ; preds = %8
%15 = load i8, i8* %5
%16 = sext i8 %15 to i32
switch i32 %16, label %23 [
i32 32, label %17
i32 9, label %20
]
17: ; preds = %14
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
store i8 83, i8* %18
br label %23
20: ; preds = %14
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %3
store i8 84, i8* %21
br label %23
23: ; preds = %14, %20, %17
br label %8
24: ; preds = %8
%25 = load i8*, i8** %3
store i8 0, i8* %25
%26 = load i8*, i8** %4
%27 = load i8**, i8*** %2
store i8* %26, i8** %27
ret i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @read_label.label_name, i64 0, i64 0)
}

LLVM IR (-O2):
@read_label.label_name = internal global [65536 x i8] zeroinitializer
define i8* @read_label(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = getelementptr inbounds i8, i8* %2, i64 1
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 10
br i1 %5, label %20, label %6
6: ; preds = %1, %15
%7 = phi i8 [ %18, %15 ], [ %4, %1 ]
%8 = phi i8* [ %17, %15 ], [ %3, %1 ]
%9 = phi i8* [ %16, %15 ], [ getelementptr inbounds ([65536 x i8], [65536 x i8]* @read_label.label_name, i64 0, i64 0), %1 ]
%10 = sext i8 %7 to i32
switch i32 %10, label %15 [
i32 32, label %12
i32 9, label %11
]
11: ; preds = %6
br label %12
12: ; preds = %6, %11
%13 = phi i8 [ 84, %11 ], [ 83, %6 ]
%14 = getelementptr inbounds i8, i8* %9, i64 1
store i8 %13, i8* %9
br label %15
15: ; preds = %12, %6
%16 = phi i8* [ %9, %6 ], [ %14, %12 ]
%17 = getelementptr inbounds i8, i8* %8, i64 1
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 10
br i1 %19, label %20, label %6
20: ; preds = %15, %1
%21 = phi i8* [ getelementptr inbounds ([65536 x i8], [65536 x i8]* @read_label.label_name, i64 0, i64 0), %1 ], [ %16, %15 ]
%22 = phi i8* [ %3, %1 ], [ %17, %15 ]
store i8 0, i8* %21
store i8* %22, i8** %0
ret i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @read_label.label_name, i64 0, i64 0)
}