#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 main() {
  printf("Testing colors\n");
  printf("\033[47m\033[30mblack on white\033[0m\n");
  printf("\033[37m c\033[31m O\033[32m S\033[33m i\033[34m r\033[35m i\033[36m "
         "s\033[30m. \033[0m\n");
  printf("\033[30m\033[47m c\033[41m O\033[42m S\033[43m i\033[44m r\033[45m "
         "i\033[46m s\033[40m. \033[0m\n");
  printf("\033[37;1m c\033[31;1m O\033[32;1m S\033[33;1m i\033[34;1m "
         "r\033[35;1m i\033[36;1m s\033[30;1m. \033[0m\n");
  printf("Test backward\r");
  printf("This should overwrite previous line\n");
  printf("Testing backspaa\bce\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
call   1030 <printf@plt>
lea    0xede(%rip),%rdi
call   1030 <printf@plt>
lea    0xef0(%rip),%rdi
call   1030 <printf@plt>
lea    0xf22(%rip),%rdi
call   1030 <printf@plt>
lea    0xf59(%rip),%rdi
call   1030 <printf@plt>
lea    0xf9b(%rip),%rdi
call   1030 <printf@plt>
lea    0xf9e(%rip),%rdi
call   1030 <printf@plt>
lea    0xfb7(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee7(%rip),%rdi
call   1030 <puts@plt>
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
lea    0xefb(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2c(%rip),%rdi
call   1030 <puts@plt>
lea    0xf62(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9c(%rip),%rdi
call   1040 <printf@plt>
lea    0xf97(%rip),%rdi
call   1030 <puts@plt>
lea    0xfaf(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Testing colors\0A\00"
@.str.1 = [30 x i8] c"\1B[47m\1B[30mblack on white\1B[0m\0A\00"
@.str.2 = [62 x i8] c"\1B[37m c\1B[31m O\1B[32m S\1B[33m i\1B[34m r\1B[35m i\1B[36m s\1B[30m. \1B[0m\0A\00"
@.str.3 = [67 x i8] c"\1B[30m\1B[47m c\1B[41m O\1B[42m S\1B[43m i\1B[44m r\1B[45m i\1B[46m s\1B[40m. \1B[0m\0A\00"
@.str.4 = [78 x i8] c"\1B[37;1m c\1B[31;1m O\1B[32;1m S\1B[33;1m i\1B[34;1m r\1B[35;1m i\1B[36;1m s\1B[30;1m. \1B[0m\0A\00"
@.str.5 = [15 x i8] c"Test backward\0D\00"
@.str.6 = [37 x i8] c"This should overwrite previous line\0A\00"
@.str.7 = [21 x i8] c"Testing backspaa\08ce\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.3, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.4, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.5 = [15 x i8] c"Test backward\0D\00"
@str = [15 x i8] c"Testing colors\00"
@str.8 = [29 x i8] c"\1B[47m\1B[30mblack on white\1B[0m\00"
@str.9 = [61 x i8] c"\1B[37m c\1B[31m O\1B[32m S\1B[33m i\1B[34m r\1B[35m i\1B[36m s\1B[30m. \1B[0m\00"
@str.10 = [66 x i8] c"\1B[30m\1B[47m c\1B[41m O\1B[42m S\1B[43m i\1B[44m r\1B[45m i\1B[46m s\1B[40m. \1B[0m\00"
@str.11 = [77 x i8] c"\1B[37;1m c\1B[31;1m O\1B[32;1m S\1B[33;1m i\1B[34;1m r\1B[35;1m i\1B[36;1m s\1B[30;1m. \1B[0m\00"
@str.12 = [36 x i8] c"This should overwrite previous line\00"
@str.13 = [20 x i8] c"Testing backspaa\08ce\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.8, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str.9, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str.10, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @str.11, i64 0, i64 0))
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.12, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.13, i64 0, i64 0))
ret i32 0
}