#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 *, ...);
main() {
  int x;
  printf("If you can read this, CSI is not working.\n");
  printf("%c2J", 155);
  printf("If this is the first thing you can read, CSI is OK.\n");
  for (x = 0; x < 5; x++) {
    printf("%c[%u;%uH*\n", 27, 1 + x, 21 + x);
    printf("%c[%u;%uH*\n", 27, 5 - x, 21 + x);
  }
  printf("%c[1mBold Text\n", 27);
  printf("%c[2mDim text\n", 27);
  printf("%c[4mUnderlined Text\n", 27);
  printf("%c[24mUn-underlined text\n", 27);
  printf("%c[7mReverse Text\n", 27);
  printf("%c[27mUn-reverse text\n", 27);
  printf("%c[m", 27);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef7(%rip),%rdi
mov    $0x9b,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    11ad <main+0x9d>
mov    -0x8(%rbp),%edx
add    $0x1,%edx
mov    -0x8(%rbp),%ecx
add    $0x15,%ecx
lea    0xef3(%rip),%rdi
mov    $0x1b,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x5,%edx
sub    -0x8(%rbp),%edx
mov    -0x8(%rbp),%ecx
add    $0x15,%ecx
lea    0xed2(%rip),%rdi
mov    $0x1b,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1155 <main+0x45>
lea    0xebd(%rip),%rdi
mov    $0x1b,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeba(%rip),%rdi
mov    $0x1b,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
mov    $0x1b,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
mov    $0x1b,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
mov    $0x1b,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
mov    $0x1b,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
mov    $0x1b,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xf67(%rip),%rdi
call   1030 <puts@plt>
lea    0xecc(%rip),%rdi
mov    $0x9b,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf72(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb2(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1b,%esi
mov    $0x1,%edx
mov    $0x15,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1b,%esi
mov    $0x5,%edx
mov    $0x15,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1b,%esi
mov    $0x2,%edx
mov    $0x16,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1b,%esi
mov    $0x4,%edx
mov    $0x16,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1b,%esi
mov    $0x3,%edx
mov    $0x17,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1b,%esi
mov    $0x3,%edx
mov    $0x17,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1b,%esi
mov    $0x4,%edx
mov    $0x18,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1b,%esi
mov    $0x2,%edx
mov    $0x18,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1b,%esi
mov    $0x5,%edx
mov    $0x19,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1b,%esi
mov    $0x1,%edx
mov    $0x19,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdbd(%rip),%rdi
mov    $0x1b,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdba(%rip),%rdi
mov    $0x1b,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdb6(%rip),%rdi
mov    $0x1b,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdb9(%rip),%rdi
mov    $0x1b,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdc0(%rip),%rdi
mov    $0x1b,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdc0(%rip),%rdi
mov    $0x1b,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdc4(%rip),%rdi
mov    $0x1b,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [43 x i8] c"If you can read this, CSI is not working.\0A\00"
@.str.1 = [5 x i8] c"%c2J\00"
@.str.2 = [53 x i8] c"If this is the first thing you can read, CSI is OK.\0A\00"
@.str.3 = [12 x i8] c"%c[%u;%uH*\0A\00"
@.str.4 = [16 x i8] c"%c[1mBold Text\0A\00"
@.str.5 = [15 x i8] c"%c[2mDim text\0A\00"
@.str.6 = [22 x i8] c"%c[4mUnderlined Text\0A\00"
@.str.7 = [26 x i8] c"%c[24mUn-underlined text\0A\00"
@.str.8 = [19 x i8] c"%c[7mReverse Text\0A\00"
@.str.9 = [23 x i8] c"%c[27mUn-reverse text\0A\00"
@.str.10 = [5 x i8] c"%c[m\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 155)
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %6
6: ; preds = %20, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 5
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = load i32, i32* %2
%11 = add nsw i32 1, %10
%12 = load i32, i32* %2
%13 = add nsw i32 21, %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 27, i32 %11, i32 %13)
%15 = load i32, i32* %2
%16 = sub nsw i32 5, %15
%17 = load i32, i32* %2
%18 = add nsw i32 21, %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 27, i32 %16, i32 %18)
br label %20
20: ; preds = %9
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %6
23: ; preds = %6
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 27)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 27)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 27)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 27)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 27)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i32 27)
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%c2J\00"
@.str.3 = [12 x i8] c"%c[%u;%uH*\0A\00"
@.str.4 = [16 x i8] c"%c[1mBold Text\0A\00"
@.str.5 = [15 x i8] c"%c[2mDim text\0A\00"
@.str.6 = [22 x i8] c"%c[4mUnderlined Text\0A\00"
@.str.7 = [26 x i8] c"%c[24mUn-underlined text\0A\00"
@.str.8 = [19 x i8] c"%c[7mReverse Text\0A\00"
@.str.9 = [23 x i8] c"%c[27mUn-reverse text\0A\00"
@.str.10 = [5 x i8] c"%c[m\00"
@str = [42 x i8] c"If you can read this, CSI is not working.\00"
@str.11 = [52 x i8] c"If this is the first thing you can read, CSI is OK.\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 155)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.11, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 27, i32 1, i32 21)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 27, i32 5, i32 21)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 27, i32 2, i32 22)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 27, i32 4, i32 22)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 27, i32 3, i32 23)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 27, i32 3, i32 23)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 27, i32 4, i32 24)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 27, i32 2, i32 24)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 27, i32 5, i32 25)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 27, i32 1, i32 25)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 27)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 27)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 27)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 27)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 27)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 27)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i32 27)
ret i32 0
}