#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 *, ...);
int read(int /*<<< orphan*/, unsigned char *, int);
int main(int argc, char *argv[]) {
  unsigned char buf[256];
  int l, i;
  while (1) {
    if ((l = read(0, buf, 256)) <= 0)
      break;
    printf("echo -n -e \"");
    for (i = 0; i < l; i++)
      printf("\\\\x%02x", buf[i]);
    printf("\" >> k\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x110(%rbp),%rsi
xor    %edi,%edi
mov    $0x100,%edx
call   1040 <read@plt>
mov    %eax,-0x114(%rbp)
cmp    $0x0,%eax
jg     1160 <main+0x40>
jmp    11ce <main+0xae>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x118(%rbp)
mov    -0x118(%rbp),%eax
cmp    -0x114(%rbp),%eax
jge    11bb <main+0x9b>
movslq -0x118(%rbp),%rax
movzbl -0x110(%rbp,%rax,1),%esi
ff
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x118(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x118(%rbp)
jmp    1178 <main+0x58>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1139 <main+0x19>
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rsp,%rsi
xor    %edi,%edi
mov    $0x100,%edx
call   1050 <read@plt>
test   %eax,%eax
jle    11b4 <main+0x84>
mov    %eax,%ebp
lea    0xea3(%rip),%r14
lea    0xea9(%rip),%r13
lea    0xeaa(%rip),%r15
mov    %rsp,%r12
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%ebp
xor    %ebx,%ebx
xchg   %ax,%ax
movzbl (%rsp,%rbx,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1180 <main+0x50>
mov    %r15,%rdi
call   1030 <puts@plt>
xor    %edi,%edi
mov    %r12,%rsi
mov    $0x100,%edx
call   1050 <read@plt>
mov    %eax,%ebp
test   %eax,%eax
jg     1170 <main+0x40>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"echo -n -e \22\00"
@.str.1 = [8 x i8] c"\\\\x%02x\00"
@.str.2 = [8 x i8] c"\22 >> k\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %9
9: ; preds = %2, %30
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%11 = call i32 @read(i32 0, i8* %10, i32 256)
store i32 %11, i32* %7
%12 = icmp sle i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %9
br label %32
14: ; preds = %9
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %8
br label %16
16: ; preds = %27, %14
%17 = load i32, i32* %8
%18 = load i32, i32* %7
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %30
20: ; preds = %16
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %20
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
store i32 %29, i32* %8
br label %16
30: ; preds = %16
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %9
32: ; preds = %13
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [13 x i8] c"echo -n -e \22\00"
@.str.1 = [8 x i8] c"\\\\x%02x\00"
@str = [7 x i8] c"\22 >> k\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = call i32 @read(i32 0, i8* %4, i32 256)
%6 = icmp slt i32 %5, 1
br i1 %6, label %23, label %7
7: ; preds = %2, %19
%8 = phi i32 [ %21, %19 ], [ %5, %2 ]
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%10 = zext i32 %8 to i64
br label %11
11: ; preds = %7, %11
%12 = phi i64 [ 0, %7 ], [ %17, %11 ]
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = add nuw nsw i64 %12, 1
%18 = icmp eq i64 %17, %10
br i1 %18, label %19, label %11
19: ; preds = %11
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%21 = call i32 @read(i32 0, i8* %4, i32 256)
%22 = icmp slt i32 %21, 1
br i1 %22, label %23, label %7
23: ; preds = %19, %2
ret i32 0
}