#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 */
scalar_t__ isspace(char const);
char *munge_space_for_match(const char *name) {
  static char buffer[8192], *q;
  const char *p;
  p = name;
  q = buffer;
  while (isspace(*p)) {
    p++;
  }
  while (*p) {
    while (*p && !isspace(*p)) {
      *q++ = *p++;
    }
    while (*p && isspace(*++p))
      ;
    if (*p) {
      *q++ = ' ';
    }
  }
  *q = '\0';
  return (buffer);
}


x86 assembly (clang, -O0):
<munge_space_for_match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    0x2f15(%rip),%rax
mov    %rax,0x4f0e(%rip)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     1159 <munge_space_for_match+0x49>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1132 <munge_space_for_match+0x22>
jmp    115e <munge_space_for_match+0x4e>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1255 <munge_space_for_match+0x145>
jmp    1170 <munge_space_for_match+0x60>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     119d <munge_space_for_match+0x8d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11ad <munge_space_for_match+0x9d>
jmp    11da <munge_space_for_match+0xca>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    0x4e7b(%rip),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,0x4e6d(%rip)
mov    %cl,(%rax)
jmp    1170 <munge_space_for_match+0x60>
jmp    11df <munge_space_for_match+0xcf>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x12(%rbp)
je     1216 <munge_space_for_match+0x106>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl 0x1(%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    1226 <munge_space_for_match+0x116>
jmp    122b <munge_space_for_match+0x11b>
jmp    11df <munge_space_for_match+0xcf>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1250 <munge_space_for_match+0x140>
mov    0x4e01(%rip),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,0x4df3(%rip)
movb   $0x20,(%rax)
jmp    115e <munge_space_for_match+0x4e>
mov    0x4de4(%rip),%rax
movb   $0x0,(%rax)
lea    0x2dda(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<munge_space_for_match>:
push   %rbx
mov    %rdi,%rbx
lea    0x2f25(%rip),%rax
mov    %rax,0x4f1e(%rip)
add    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1030 <isspace@plt>
test   %rax,%rax
jne    1130 <munge_space_for_match+0x20>
jmp    1165 <munge_space_for_match+0x55>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x4ee9(%rip),%rax
lea    0x1(%rax),%rcx
mov    %rcx,0x4ede(%rip)
movb   $0x20,(%rax)
mov    (%rbx),%al
test   %al,%al
je     11bc <munge_space_for_match+0xac>
movsbl %al,%edi
call   1030 <isspace@plt>
test   %rax,%rax
jne    11a0 <munge_space_for_match+0x90>
movzbl (%rbx),%eax
mov    0x4ebe(%rip),%rcx
lea    0x1(%rcx),%rdx
mov    %rdx,0x4eb3(%rip)
mov    %al,(%rcx)
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    116b <munge_space_for_match+0x5b>
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,(%rbx)
je     11bc <munge_space_for_match+0xac>
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1030 <isspace@plt>
test   %rax,%rax
jne    11a0 <munge_space_for_match+0x90>
cmpb   $0x0,(%rbx)
jne    1150 <munge_space_for_match+0x40>
mov    0x4e7d(%rip),%rax
movb   $0x0,(%rax)
lea    0x2e73(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@munge_space_for_match.buffer = internal global [8192 x i8] zeroinitializer
@munge_space_for_match.q = internal global i8* null
define i8* @munge_space_for_match(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
store i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @munge_space_for_match.buffer, i64 0, i64 0), i8** @munge_space_for_match.q
br label %5
5: ; preds = %10, %1
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = call i64 @isspace(i8 signext %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i32 1
store i8* %12, i8** %3
br label %5
13: ; preds = %5
br label %14
14: ; preds = %60, %13
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = icmp ne i8 %16, 0
br i1 %17, label %18, label %61
18: ; preds = %14
br label %19
19: ; preds = %32, %18
%20 = load i8*, i8** %3
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %19
%25 = load i8*, i8** %3
%26 = load i8, i8* %25
%27 = call i64 @isspace(i8 signext %26)
%28 = icmp ne i64 %27, 0
%29 = xor i1 %28, true
br label %30
30: ; preds = %24, %19
%31 = phi i1 [ false, %19 ], [ %29, %24 ]
br i1 %31, label %32, label %38
32: ; preds = %30
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %3
%35 = load i8, i8* %33
%36 = load i8*, i8** @munge_space_for_match.q
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** @munge_space_for_match.q
store i8 %35, i8* %36
br label %19
38: ; preds = %30
br label %39
39: ; preds = %52, %38
%40 = load i8*, i8** %3
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %50
44: ; preds = %39
%45 = load i8*, i8** %3
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %3
%47 = load i8, i8* %46
%48 = call i64 @isspace(i8 signext %47)
%49 = icmp ne i64 %48, 0
br label %50
50: ; preds = %44, %39
%51 = phi i1 [ false, %39 ], [ %49, %44 ]
br i1 %51, label %52, label %53
52: ; preds = %50
br label %39
53: ; preds = %50
%54 = load i8*, i8** %3
%55 = load i8, i8* %54
%56 = icmp ne i8 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %53
%58 = load i8*, i8** @munge_space_for_match.q
%59 = getelementptr inbounds i8, i8* %58, i32 1
store i8* %59, i8** @munge_space_for_match.q
store i8 32, i8* %58
br label %60
60: ; preds = %57, %53
br label %14
61: ; preds = %14
%62 = load i8*, i8** @munge_space_for_match.q
store i8 0, i8* %62
ret i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @munge_space_for_match.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@munge_space_for_match.buffer = internal global [8192 x i8] zeroinitializer
@munge_space_for_match.q = internal unnamed_addr global i8* null
define i8* @munge_space_for_match(i8* nocapture %0) {
store i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @munge_space_for_match.buffer, i64 0, i64 0), i8** @munge_space_for_match.q
br label %2
2: ; preds = %2, %1
%3 = phi i8* [ %0, %1 ], [ %7, %2 ]
%4 = load i8, i8* %3
%5 = tail call i64 @isspace(i8 signext %4)
%6 = icmp eq i64 %5, 0
%7 = getelementptr inbounds i8, i8* %3, i64 1
br i1 %6, label %8, label %2
8: ; preds = %2
%9 = load i8, i8* %3
%10 = icmp eq i8 %9, 0
br i1 %10, label %45, label %11
11: ; preds = %8, %23
%12 = phi i8* [ %24, %23 ], [ %3, %8 ]
%13 = phi i8 [ %25, %23 ], [ %9, %8 ]
%14 = tail call i64 @isspace(i8 signext %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %11
%17 = getelementptr inbounds i8, i8* %12, i64 1
%18 = load i8, i8* %12
%19 = load i8*, i8** @munge_space_for_match.q
%20 = getelementptr inbounds i8, i8* %19, i64 1
store i8* %20, i8** @munge_space_for_match.q
store i8 %18, i8* %19
%21 = load i8, i8* %17
%22 = icmp eq i8 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %16, %40
%24 = phi i8* [ %17, %16 ], [ %33, %40 ]
%25 = phi i8 [ %21, %16 ], [ %43, %40 ]
br label %11
26: ; preds = %11, %16
%27 = phi i8* [ %12, %11 ], [ %17, %16 ]
br label %28
28: ; preds = %26, %32
%29 = phi i8* [ %33, %32 ], [ %27, %26 ]
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 0
br i1 %31, label %45, label %32
32: ; preds = %28
%33 = getelementptr inbounds i8, i8* %29, i64 1
%34 = load i8, i8* %33
%35 = tail call i64 @isspace(i8 signext %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %28
37: ; preds = %32
%38 = load i8, i8* %33
%39 = icmp eq i8 %38, 0
br i1 %39, label %45, label %40
40: ; preds = %37
%41 = load i8*, i8** @munge_space_for_match.q
%42 = getelementptr inbounds i8, i8* %41, i64 1
store i8* %42, i8** @munge_space_for_match.q
store i8 32, i8* %41
%43 = load i8, i8* %33
%44 = icmp eq i8 %43, 0
br i1 %44, label %45, label %23
45: ; preds = %37, %40, %28, %8
%46 = load i8*, i8** @munge_space_for_match.q
store i8 0, i8* %46
ret i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @munge_space_for_match.buffer, i64 0, i64 0)
}