#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*/ printf(char *, ...);
void print_arg_quoted(char *string) {
  while (*string != ' ' && *string != '\0') {
    printf("%c", *string);
    ++string;
  }
  if (*string != '\0') {
    printf("%c", *string);
  } else {
    printf("\n");
    return;
  }
  ++string;
  printf("'");
  while (*string != '\0') {
    if (*string == '\'') {
      printf("'\"'\"'");
    } else {
      printf("%c", *string);
    }
    ++string;
  }
  printf("'");
  printf("\n");
  return;
}


x86 assembly (clang, -O0):
<print_arg_quoted>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x9(%rbp)
je     1141 <print_arg_quoted+0x31>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    1151 <print_arg_quoted+0x41>
jmp    1177 <print_arg_quoted+0x67>
mov    -0x8(%rbp),%rax
movsbl (%rax),%esi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    111c <print_arg_quoted+0xc>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a1 <print_arg_quoted+0x91>
mov    -0x8(%rbp),%rax
movsbl (%rax),%esi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b4 <print_arg_quoted+0xa4>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1243 <print_arg_quoted+0x133>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1227 <print_arg_quoted+0x117>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
jne    1201 <print_arg_quoted+0xf1>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1216 <print_arg_quoted+0x106>
mov    -0x8(%rbp),%rax
movsbl (%rax),%esi
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11ce <print_arg_quoted+0xbe>
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_arg_quoted>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
movsbl -0x1(%rbx),%edi
test   %edi,%edi
je     11a0 <print_arg_quoted+0x80>
cmp    $0x20,%dil
je     1149 <print_arg_quoted+0x29>
call   1030 <putchar@plt>
jmp    1130 <print_arg_quoted+0x10>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x27,%edi
call   1030 <putchar@plt>
lea    0xe9c(%rip),%r14
jmp    117e <print_arg_quoted+0x5e>
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
movsbl (%rbx),%edi
cmp    $0x27,%edi
je     1170 <print_arg_quoted+0x50>
test   %dil,%dil
je     1196 <print_arg_quoted+0x76>
call   1030 <putchar@plt>
add    $0x1,%rbx
jmp    117e <print_arg_quoted+0x5e>
mov    $0x27,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str.3 = [6 x i8] c"'\22'\22'\00"
define void @print_arg_quoted(i8* nocapture %0) {
br label %2
2: ; preds = %5, %1
%3 = phi i8* [ %0, %1 ], [ %8, %5 ]
%4 = load i8, i8* %3
switch i8 %4, label %5 [
i8 0, label %24
i8 32, label %9
]
5: ; preds = %2
%6 = sext i8 %4 to i32
%7 = tail call i32 @putchar(i32 %6)
%8 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
9: ; preds = %2
%10 = tail call i32 @putchar(i32 32)
%11 = tail call i32 @putchar(i32 39)
br label %12
12: ; preds = %21, %9
%13 = phi i8* [ %3, %9 ], [ %14, %21 ]
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8, i8* %14
switch i8 %15, label %18 [
i8 0, label %22
i8 39, label %16
]
16: ; preds = %12
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %21
18: ; preds = %12
%19 = sext i8 %15 to i32
%20 = tail call i32 @putchar(i32 %19)
br label %21
21: ; preds = %18, %16
br label %12
22: ; preds = %12
%23 = tail call i32 @putchar(i32 39)
br label %24
24: ; preds = %2, %22
%25 = tail call i32 @putchar(i32 10)
ret void
}