#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);
int /*<<< orphan*/ putchar(char const);
void quote_string(const char *s) {
  for (; *s; s++) {
    if (isspace(*s) || *s == '\\')
      putchar('\\');
    putchar(*s);
  }
}


x86 assembly (clang, -O0):
<quote_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1186 <quote_string+0x66>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
jne    115f <quote_string+0x3f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1169 <quote_string+0x49>
mov    $0x5c,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112c <quote_string+0xc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quote_string>:
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     1167 <quote_string+0x47>
mov    %rdi,%rbx
jmp    1151 <quote_string+0x31>
nopl   0x0(%rax)
mov    $0x5c,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1167 <quote_string+0x47>
movsbl %al,%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    1130 <quote_string+0x10>
movzbl (%rbx),%eax
cmp    $0x5c,%al
je     1130 <quote_string+0x10>
jmp    113d <quote_string+0x1d>
pop    %rbx
ret

LLVM IR (-O0):
define void @quote_string(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
br label %3
3: ; preds = %23, %1
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = icmp ne i8 %5, 0
br i1 %6, label %7, label %26
7: ; preds = %3
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = call i64 @isspace(i8 signext %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %7
%13 = load i8*, i8** %2
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 92
br i1 %16, label %17, label %19
17: ; preds = %12, %7
%18 = call i32 @putchar(i8 signext 92)
br label %19
19: ; preds = %17, %12
%20 = load i8*, i8** %2
%21 = load i8, i8* %20
%22 = call i32 @putchar(i8 signext %21)
br label %23
23: ; preds = %19
%24 = load i8*, i8** %2
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %2
br label %3
26: ; preds = %3
ret void
}

LLVM IR (-O2):
define void @quote_string(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %21, label %4
4: ; preds = %1, %15
%5 = phi i8 [ %19, %15 ], [ %2, %1 ]
%6 = phi i8* [ %18, %15 ], [ %0, %1 ]
%7 = tail call i64 @isspace(i8 signext %5)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = load i8, i8* %6
%11 = icmp eq i8 %10, 92
br i1 %11, label %12, label %15
12: ; preds = %9, %4
%13 = tail call i32 @putchar(i8 signext 92)
%14 = load i8, i8* %6
br label %15
15: ; preds = %12, %9
%16 = phi i8 [ %14, %12 ], [ %10, %9 ]
%17 = tail call i32 @putchar(i8 signext %16)
%18 = getelementptr inbounds i8, i8* %6, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %4
21: ; preds = %15, %1
ret void
}