#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 BUFSIZ;
char *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main(int argc, char **argv) {
  char buffer[BUFSIZ], *result;
  int i;
  int quotes_open = 0;
  while (1) {
    result = fgets(buffer, BUFSIZ, stdin);
    if (result == NULL)
      return 0;
    printf("\t.byte ");
    for (i = 0; i < strlen(buffer); i++) {
      if (buffer[i] < 32) {
        if (quotes_open)
          printf("\",");
        printf("$%02x", buffer[i]);
        if (i < strlen(buffer) - 1)
          printf(", ");
        quotes_open = 0;
      } else {
        if (!quotes_open)
          printf("\"");
        printf("%c", buffer[i]);
        quotes_open = 1;
      }
    }
    if (quotes_open)
      printf("\"");
    quotes_open = 0;
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x30(%rbp)
jmp    117e <main+0x4e>
mov    -0x38(%rbp),%rdi
mov    0x2e4f(%rip),%rax
mov    (%rax),%esi
mov    0x2e56(%rip),%rax
mov    (%rax),%edx
call   1050 <fgets@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11be <main+0x8e>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
cmp    %ecx,%eax
jge    12bb <main+0x18b>
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jge    126f <main+0x13f>
cmpl   $0x0,-0x30(%rbp)
je     121c <main+0xec>
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%eax
mov    %eax,-0x40(%rbp)
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1263 <main+0x133>
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x30(%rbp)
jmp    12a8 <main+0x178>
cmpl   $0x0,-0x30(%rbp)
jne    1287 <main+0x157>
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x30(%rbp)
jmp    12ad <main+0x17d>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11d3 <main+0xa3>
cmpl   $0x0,-0x30(%rbp)
je     12d3 <main+0x1a3>
lea    0xd48(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x30(%rbp)
lea    0xd38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1179 <main+0x49>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rbx
mov    %rsi,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0x2e76(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
call   1060 <fgets@plt>
test   %rax,%rax
je     1298 <main+0x158>
lea    0xe7f(%rip),%r15
jmp    11bd <main+0x7d>
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2e37(%rip),%rax
mov    (%rax),%esi
mov    0x2e3e(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
call   1060 <fgets@plt>
test   %rax,%rax
je     1298 <main+0x158>
lea    0xe3c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1190 <main+0x50>
xor    %r14d,%r14d
xor    %r12d,%r12d
jmp    1209 <main+0xc9>
nop
test   %r12d,%r12d
je     1262 <main+0x122>
movsbl %al,%edi
call   1030 <putchar@plt>
mov    $0x1,%r12d
xor    %r13d,%r13d
add    $0x1,%r14
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%r14
jge    1280 <main+0x140>
movzbl (%rbx,%r14,1),%eax
cmp    $0x1f,%al
jg     11e0 <main+0xa0>
test   %r12d,%r12d
je     122a <main+0xea>
lea    0xdea(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl (%rbx,%r14,1),%eax
movsbl %al,%esi
xor    %r12d,%r12d
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
add    $0xffffffff,%eax
cltq
mov    $0x1,%r13b
cmp    %rax,%r14
jge    11f6 <main+0xb6>
xor    %r12d,%r12d
lea    0xdb8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11f6 <main+0xb6>
mov    $0x22,%edi
call   1030 <putchar@plt>
movzbl (%rbx,%r14,1),%eax
jmp    11e5 <main+0xa5>
cs nopw 0x0(%rax,%rax,1)
test   %r13b,%r13b
jne    1190 <main+0x50>
mov    $0x22,%edi
call   1030 <putchar@plt>
jmp    1190 <main+0x50>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@stdin = global i32 0
@.str = [8 x i8] c"\09.byte \00"
@.str.1 = [3 x i8] c"\22,\00"
@.str.2 = [6 x i8] c"$%02x\00"
@.str.3 = [3 x i8] c", \00"
@.str.4 = [2 x i8] c"\22\00"
@.str.5 = [3 x i8] c"%c\00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* @BUFSIZ
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %6
%14 = alloca i8, i64 %12
store i64 %12, i64* %7
store i32 0, i32* %10
br label %15
15: ; preds = %78, %2
br label %16
16: ; preds = %15
%17 = load i32, i32* @BUFSIZ
%18 = load i32, i32* @stdin
%19 = call i8* @fgets(i8* %14, i32 %17, i32 %18)
store i8* %19, i8** %8
%20 = load i8*, i8** %8
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %25
22: ; preds = %16
store i32 0, i32* %3
%23 = load i8*, i8** %6
%24 = load i32, i32* %3
ret i32 %24
25: ; preds = %16
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %9
br label %27
27: ; preds = %70, %25
%28 = load i32, i32* %9
%29 = call i32 @strlen(i8* %14)
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %73
31: ; preds = %27
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %14, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp slt i32 %36, 32
br i1 %37, label %38, label %57
38: ; preds = %31
%39 = load i32, i32* %10
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %43
43: ; preds = %41, %38
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %14, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %9
%51 = call i32 @strlen(i8* %14)
%52 = sub nsw i32 %51, 1
%53 = icmp slt i32 %50, %52
br i1 %53, label %54, label %56
54: ; preds = %43
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %56
56: ; preds = %54, %43
store i32 0, i32* %10
br label %69
57: ; preds = %31
%58 = load i32, i32* %10
%59 = icmp ne i32 %58, 0
br i1 %59, label %62, label %60
60: ; preds = %57
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %62
62: ; preds = %60, %57
%63 = load i32, i32* %9
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %14, i64 %64
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %67)
store i32 1, i32* %10
br label %69
69: ; preds = %62, %56
br label %70
70: ; preds = %69
%71 = load i32, i32* %9
%72 = add nsw i32 %71, 1
store i32 %72, i32* %9
br label %27
73: ; preds = %27
%74 = load i32, i32* %10
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %73
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %78
78: ; preds = %76, %73
store i32 0, i32* %10
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %15
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@stdin = global i32 0
@.str = [8 x i8] c"\09.byte \00"
@.str.1 = [3 x i8] c"\22,\00"
@.str.2 = [6 x i8] c"$%02x\00"
@.str.3 = [3 x i8] c", \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @BUFSIZ
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = load i32, i32* @stdin
%7 = call i8* @fgets(i8* %5, i32 %3, i32 %6)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %53, %2
ret i32 0
10: ; preds = %2, %53
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @strlen(i8* %5)
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %53
14: ; preds = %10, %43
%15 = phi i64 [ %46, %43 ], [ 0, %10 ]
%16 = phi i32 [ %45, %43 ], [ 0, %10 ]
%17 = getelementptr inbounds i8, i8* %5, i64 %15
%18 = load i8, i8* %17
%19 = icmp slt i8 %18, 32
%20 = icmp eq i32 %16, 0
br i1 %19, label %21, label %35
21: ; preds = %14
br i1 %20, label %25, label %22
22: ; preds = %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%24 = load i8, i8* %17
br label %25
25: ; preds = %22, %21
%26 = phi i8 [ %24, %22 ], [ %18, %21 ]
%27 = sext i8 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = call i32 @strlen(i8* %5)
%30 = add nsw i32 %29, -1
%31 = sext i32 %30 to i64
%32 = icmp slt i64 %15, %31
br i1 %32, label %33, label %43
33: ; preds = %25
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %43
35: ; preds = %14
br i1 %20, label %36, label %39
36: ; preds = %35
%37 = call i32 @putchar(i32 34)
%38 = load i8, i8* %17
br label %39
39: ; preds = %36, %35
%40 = phi i8 [ %38, %36 ], [ %18, %35 ]
%41 = sext i8 %40 to i32
%42 = call i32 @putchar(i32 %41)
br label %43
43: ; preds = %25, %33, %39
%44 = phi i1 [ true, %25 ], [ true, %33 ], [ false, %39 ]
%45 = phi i32 [ 0, %25 ], [ 0, %33 ], [ 1, %39 ]
%46 = add nuw nsw i64 %15, 1
%47 = call i32 @strlen(i8* %5)
%48 = sext i32 %47 to i64
%49 = icmp slt i64 %46, %48
br i1 %49, label %14, label %50
50: ; preds = %43
br i1 %44, label %53, label %51
51: ; preds = %50
%52 = call i32 @putchar(i32 34)
br label %53
53: ; preds = %10, %51, %50
%54 = call i32 @putchar(i32 10)
%55 = load i32, i32* @BUFSIZ
%56 = load i32, i32* @stdin
%57 = call i8* @fgets(i8* %5, i32 %55, i32 %56)
%58 = icmp eq i8* %57, null
br i1 %58, label %9, label %10
}