#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 */
typedef int /*<<< orphan*/ space_string;

/* Variables and functions */
scalar_t__ isspace(int);
int /*<<< orphan*/ remove_repeated_whitespace(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ trim_whitespace(char *);
void make_regexp(char *string) {
  char temp_string[4096];
  char *read = string, *write = temp_string;
  char c;
  char space_string[] = "\"[[:space:]]+\"";
  remove_repeated_whitespace(string);
  trim_whitespace(string);
  *write = '\"';
  write++;
  while (*read != '\0') {
    c = *read;
    read++;
    if (isspace((int)c)) {
      strcpy(write, space_string);
      write += sizeof(space_string) - 1;
    } else {
      *write = c;
      write++;
    }
  }
  *write = '\"';
  write++;
  *write = '\0';
  strcpy(string, temp_string);
}


x86 assembly (clang, -O0):
<make_regexp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x1018(%rbp)
lea    -0x1010(%rbp),%rax
mov    %rax,-0x1020(%rbp)
mov    0xe91(%rip),%rax
mov    %rax,-0x1030(%rbp)
mov    0xe8c(%rip),%eax
mov    %eax,-0x1028(%rbp)
mov    0xe83(%rip),%ax
mov    %ax,-0x1024(%rbp)
mov    0xe78(%rip),%al
mov    %al,-0x1022(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <remove_repeated_whitespace@plt>
mov    -0x8(%rbp),%rdi
call   1040 <trim_whitespace@plt>
mov    -0x1020(%rbp),%rax
movb   $0x22,(%rax)
mov    -0x1020(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1020(%rbp)
mov    -0x1018(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1264 <make_regexp+0x124>
mov    -0x1018(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x1021(%rbp)
mov    -0x1018(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1018(%rbp)
movsbl -0x1021(%rbp),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     123e <make_regexp+0xfe>
mov    -0x1020(%rbp),%rdi
lea    -0x1030(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x1020(%rbp),%rax
add    $0xe,%rax
mov    %rax,-0x1020(%rbp)
jmp    125f <make_regexp+0x11f>
mov    -0x1021(%rbp),%cl
mov    -0x1020(%rbp),%rax
mov    %cl,(%rax)
mov    -0x1020(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1020(%rbp)
jmp    11ca <make_regexp+0x8a>
mov    -0x1020(%rbp),%rax
movb   $0x22,(%rax)
mov    -0x1020(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1020(%rbp)
mov    -0x1020(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_regexp>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1010,%rsp
mov    %rdi,%r14
movabs $0x222b5d5d3a6563,%rax
mov    %rax,0x7(%rsp)
movabs $0x636170733a5b5b22,%rax
70 61 63
mov    %rax,(%rsp)
call   1060 <remove_repeated_whitespace@plt>
mov    %r14,%rdi
call   1040 <trim_whitespace@plt>
movb   $0x22,0x10(%rsp)
lea    0x11(%rsp),%r12
mov    (%r14),%bpl
test   %bpl,%bpl
je     11d8 <make_regexp+0x98>
lea    0x1(%r14),%rbx
mov    %rsp,%r15
jmp    11b8 <make_regexp+0x78>
nopw   0x0(%rax,%rax,1)
mov    %bpl,(%r12)
mov    $0x1,%eax
add    %rax,%r12
movzbl (%rbx),%ebp
add    $0x1,%rbx
test   %bpl,%bpl
je     11d8 <make_regexp+0x98>
movsbl %bpl,%edi
call   1050 <isspace@plt>
test   %rax,%rax
je     11a0 <make_regexp+0x60>
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    $0xe,%eax
jmp    11a9 <make_regexp+0x69>
movw   $0x22,(%r12)
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
add    $0x1010,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.make_regexp.space_string = [15 x i8] c"\22[[:space:]]+\22\00"
define void @make_regexp(i8* %0) {
%2 = alloca i8*
%3 = alloca [4096 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8
%7 = alloca [15 x i8]
store i8* %0, i8** %2
%8 = load i8*, i8** %2
store i8* %8, i8** %4
%9 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
store i8* %9, i8** %5
%10 = bitcast [15 x i8]* %7 to i8*
%11 = load i8*, i8** %2
%12 = call i32 @remove_repeated_whitespace(i8* %11)
%13 = load i8*, i8** %2
%14 = call i32 @trim_whitespace(i8* %13)
%15 = load i8*, i8** %5
store i8 34, i8* %15
%16 = load i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %5
br label %18
18: ; preds = %43, %1
%19 = load i8*, i8** %4
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %44
23: ; preds = %18
%24 = load i8*, i8** %4
%25 = load i8, i8* %24
store i8 %25, i8* %6
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %4
%28 = load i8, i8* %6
%29 = sext i8 %28 to i32
%30 = call i64 @isspace(i32 %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %38
32: ; preds = %23
%33 = load i8*, i8** %5
%34 = getelementptr inbounds [15 x i8], [15 x i8]* %7, i64 0, i64 0
%35 = call i32 @strcpy(i8* %33, i8* %34)
%36 = load i8*, i8** %5
%37 = getelementptr inbounds i8, i8* %36, i64 14
store i8* %37, i8** %5
br label %43
38: ; preds = %23
%39 = load i8, i8* %6
%40 = load i8*, i8** %5
store i8 %39, i8* %40
%41 = load i8*, i8** %5
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %5
br label %43
43: ; preds = %38, %32
br label %18
44: ; preds = %18
%45 = load i8*, i8** %5
store i8 34, i8* %45
%46 = load i8*, i8** %5
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %5
%48 = load i8*, i8** %5
store i8 0, i8* %48
%49 = load i8*, i8** %2
%50 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%51 = call i32 @strcpy(i8* %49, i8* %50)
ret void
}

LLVM IR (-O2):
@__const.make_regexp.space_string = [15 x i8] c"\22[[:space:]]+\22\00"
define void @make_regexp(i8* %0) {
%2 = alloca [4096 x i8]
%3 = alloca [15 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%6 = tail call i32 @remove_repeated_whitespace(i8* %0)
%7 = tail call i32 @trim_whitespace(i8* %0)
store i8 34, i8* %4
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 1
%9 = load i8, i8* %0
%10 = icmp eq i8 %9, 0
br i1 %10, label %27, label %11
11: ; preds = %1, %22
%12 = phi i8 [ %25, %22 ], [ %9, %1 ]
%13 = phi i8* [ %16, %22 ], [ %0, %1 ]
%14 = phi i8* [ %24, %22 ], [ %8, %1 ]
%15 = sext i8 %12 to i32
%16 = getelementptr inbounds i8, i8* %13, i64 1
%17 = call i64 @isspace(i32 %15)
%18 = icmp eq i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %11
%20 = call i32 @strcpy(i8* %14, i8* %5)
br label %22
21: ; preds = %11
store i8 %12, i8* %14
br label %22
22: ; preds = %21, %19
%23 = phi i64 [ 1, %21 ], [ 14, %19 ]
%24 = getelementptr inbounds i8, i8* %14, i64 %23
%25 = load i8, i8* %16
%26 = icmp eq i8 %25, 0
br i1 %26, label %27, label %11
27: ; preds = %22, %1
%28 = phi i8* [ %8, %1 ], [ %24, %22 ]
store i8 34, i8* %28
%29 = getelementptr inbounds i8, i8* %28, i64 1
store i8 0, i8* %29
%30 = call i32 @strcpy(i8* %0, i8* %4)
ret void
}