#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 is_strip_character(char);
int isspace(char);
char *trim(int /*<<< orphan*/);
int /*<<< orphan*/ up_string(char *);
char *make_key(char *s) {
  static char buffer[2048];
  char *buf_ptr = buffer;
  char c;
  int inside_space = 0;
  int is_space;
  int is_strip;
  while ((c = *s++)) {
    is_space = isspace(c);
    is_strip = is_strip_character(c);
    if ((is_space && inside_space) || is_strip)
      continue;
    if (is_space) {
      inside_space = 1;
      *buf_ptr++ = ' ';
      continue;
    } else
      inside_space = 0;
    *buf_ptr++ = c;
  }
  return trim(up_string(buffer));
}


x86 assembly (clang, -O0):
<make_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0x2efd(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    %al,-0x11(%rbp)
cmp    $0x0,%al
je     11fd <make_key+0xbd>
movsbl -0x11(%rbp),%edi
call   1040 <isspace@plt>
mov    %eax,-0x1c(%rbp)
movsbl -0x11(%rbp),%edi
call   1050 <is_strip_character@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11a6 <make_key+0x66>
cmpl   $0x0,-0x18(%rbp)
jne    11b0 <make_key+0x70>
cmpl   $0x0,-0x20(%rbp)
je     11b5 <make_key+0x75>
jmp    115e <make_key+0x1e>
cmpl   $0x0,-0x1c(%rbp)
je     11dd <make_key+0x9d>
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x20,(%rax)
jmp    115e <make_key+0x1e>
movl   $0x0,-0x18(%rbp)
mov    -0x11(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    115e <make_key+0x1e>
lea    0x2e4c(%rip),%rdi
call   1060 <up_string@plt>
mov    %eax,%edi
call   1030 <trim@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_key>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0x2efb(%rip),%rax
mov    %rax,(%rsp)
xor    %r13d,%r13d
nopl   0x0(%rax)
movzbl (%r14),%r12d
test   %r12b,%r12b
je     11bb <make_key+0x7b>
add    $0x1,%r14
test   %r13d,%r13d
setne  %r15b
movsbl %r12b,%ebx
mov    %ebx,%edi
call   1040 <isspace@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1050 <is_strip_character@plt>
test   %ebp,%ebp
setne  %cl
test   %r15b,%cl
jne    1160 <make_key+0x20>
test   %eax,%eax
jne    1160 <make_key+0x20>
xor    %r13d,%r13d
test   %ebp,%ebp
setne  %r13b
movzbl %r12b,%eax
mov    $0x20,%ecx
cmovne %ecx,%eax
mov    (%rsp),%rcx
mov    %al,(%rcx)
add    $0x1,%rcx
mov    %rcx,(%rsp)
jmp    1160 <make_key+0x20>
lea    0x2e8e(%rip),%rdi
call   1060 <up_string@plt>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <trim@plt>

LLVM IR (-O0):
@make_key.buffer = internal global [2048 x i8] zeroinitializer
define i8* @make_key(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %2
store i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @make_key.buffer, i64 0, i64 0), i8** %3
store i32 0, i32* %5
br label %8
8: ; preds = %34, %30, %26, %1
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i32 1
store i8* %10, i8** %2
%11 = load i8, i8* %9
store i8 %11, i8* %4
%12 = icmp ne i8 %11, 0
br i1 %12, label %13, label %38
13: ; preds = %8
%14 = load i8, i8* %4
%15 = call i32 @isspace(i8 signext %14)
store i32 %15, i32* %6
%16 = load i8, i8* %4
%17 = call i32 @is_strip_character(i8 signext %16)
store i32 %17, i32* %7
%18 = load i32, i32* %6
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %13
%21 = load i32, i32* %5
%22 = icmp ne i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %20, %13
%24 = load i32, i32* %7
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %23, %20
br label %8
27: ; preds = %23
%28 = load i32, i32* %6
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %27
store i32 1, i32* %5
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %3
store i8 32, i8* %31
br label %8
33: ; preds = %27
store i32 0, i32* %5
br label %34
34: ; preds = %33
%35 = load i8, i8* %4
%36 = load i8*, i8** %3
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %3
store i8 %35, i8* %36
br label %8
38: ; preds = %8
%39 = call i32 @up_string(i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @make_key.buffer, i64 0, i64 0))
%40 = call i8* @trim(i32 %39)
ret i8* %40
}

LLVM IR (-O2):
@make_key.buffer = internal global [2048 x i8] zeroinitializer
define i8* @make_key(i8* nocapture %0) {
br label %2
2: ; preds = %19, %1
%3 = phi i32 [ 0, %1 ], [ %21, %19 ]
%4 = phi i8* [ getelementptr inbounds ([2048 x i8], [2048 x i8]* @make_key.buffer, i64 0, i64 0), %1 ], [ %22, %19 ]
%5 = phi i8* [ %0, %1 ], [ %9, %19 ]
%6 = icmp ne i32 %3, 0
br label %7
7: ; preds = %2, %12
%8 = phi i8* [ %9, %12 ], [ %5, %2 ]
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8, i8* %8
%11 = icmp eq i8 %10, 0
br i1 %11, label %23, label %12
12: ; preds = %7
%13 = tail call i32 @isspace(i8 signext %10)
%14 = tail call i32 @is_strip_character(i8 signext %10)
%15 = icmp ne i32 %13, 0
%16 = and i1 %15, %6
%17 = icmp ne i32 %14, 0
%18 = select i1 %16, i1 true, i1 %17
br i1 %18, label %7, label %19
19: ; preds = %12
%20 = select i1 %15, i8 32, i8 %10
%21 = zext i1 %15 to i32
%22 = getelementptr inbounds i8, i8* %4, i64 1
store i8 %20, i8* %4
br label %2
23: ; preds = %7
%24 = tail call i32 @up_string(i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @make_key.buffer, i64 0, i64 0))
%25 = tail call i8* @trim(i32 %24)
ret i8* %25
}