#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 /*<<< orphan*/ memmove(char *, char *, int);
int strlen(char *);
void double_quote_if_has_spaces(char *s) {
  int i, len;
  for (i = 0; s[i] != '\0' && s[i] != ' ' && s[i] != '\t'; i++)
    ;
  if (s[i] == '\0')
    return;
  len = strlen(s);
  memmove(&s[1], s, len);
  s[0] = '\"';
  s[len + 1] = '\"';
  s[len + 2] = '\0';
}


x86 assembly (clang, -O0):
<double_quote_if_has_spaces>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     117c <double_quote_if_has_spaces+0x5c>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x11(%rbp)
je     117c <double_quote_if_has_spaces+0x5c>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x9,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    118c <double_quote_if_has_spaces+0x6c>
jmp    119f <double_quote_if_has_spaces+0x7f>
jmp    1191 <double_quote_if_has_spaces+0x71>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <double_quote_if_has_spaces+0x13>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    11b9 <double_quote_if_has_spaces+0x99>
jmp    1202 <double_quote_if_has_spaces+0xe2>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x1,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%edx
call   1040 <memmove@plt>
mov    -0x8(%rbp),%rax
movb   $0x22,(%rax)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x22,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<double_quote_if_has_spaces>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    %rdi,%rax
nopl   0x0(%rax)
movzbl (%rax),%ecx
test   %cl,%cl
je     116c <double_quote_if_has_spaces+0x4c>
cmp    $0x9,%cl
je     1147 <double_quote_if_has_spaces+0x27>
cmp    $0x20,%cl
je     1147 <double_quote_if_has_spaces+0x27>
add    $0x1,%rax
jmp    1130 <double_quote_if_has_spaces+0x10>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
lea    0x1(%rbx),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <memmove@plt>
movb   $0x22,(%rbx)
movslq %ebp,%rax
movw   $0x22,0x1(%rax,%rbx,1)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define void @double_quote_if_has_spaces(i8* %0) {
br label %2
2: ; preds = %6, %1
%3 = phi i64 [ %7, %6 ], [ 0, %1 ]
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = load i8, i8* %4
switch i8 %5, label %6 [
i8 0, label %18
i8 9, label %8
i8 32, label %8
]
6: ; preds = %2
%7 = add nuw i64 %3, 1
br label %2
8: ; preds = %2, %2
%9 = tail call i32 @strlen(i8* %0)
%10 = getelementptr inbounds i8, i8* %0, i64 1
%11 = tail call i32 @memmove(i8* %10, i8* %0, i32 %9)
store i8 34, i8* %0
%12 = add nsw i32 %9, 1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %0, i64 %13
store i8 34, i8* %14
%15 = add nsw i32 %9, 2
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %0, i64 %16
store i8 0, i8* %17
br label %18
18: ; preds = %2, %8
ret void
}