#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 atoi(char const *);
int /*<<< orphan*/ simple_write(int, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
void test_cc(int fd, const char *args) {
  switch (atoi(args)) {
  case 1:
    simple_write(fd,
                 "\e[3H\e[2J>\e[HX\e[;5HV\e[1;1H "
                 "\r\n"
                 "\e[3;5H"
                 "* - should be pointed to by V and > (line 3, column 5)\r\n"
                 "\r\nThe screen should only contain this text, "
                 "the message above, \"V\", \">\"\r\n"
                 "and \"* -\" plus the new prompt. "
                 "The V should be on the first line,\r\n"
                 "the > in the first column and this is the only X.\r\n");
    break;
  case 2:
    simple_write(fd, "\e[H\e[2J"
                     "123456789>\r\n"
                     "2   YY\r\n"
                     "3  YabY\r\n"
                     "4  YcdY\r\n"
                     "5   YY\r\n"
                     "V\r\n"
                     "\e[H"
                     "\e[B\e[2B\e[C\e[4CDX"
                     "\e[2A\e[3D  \e[D\e[2D\e[B AX "
                     "\e[E"
                     "\e[3C C"
                     "\e[F\e[2F\e[5C\e[2BB"
                     "\e[6G\e[2B \e[5G "
                     "\e[4;7H "
                     "\r\n\r\n\r\n\r\n"
                     "The screen should now show \"AB\" "
                     "and below it \"CD\".\r\n"
                     "A should be shown in the third row, "
                     "fifth column.\r\n");
    break;
  case 3:
    simple_write(
        fd, "\e[H\e[2J"
            "XXXXXXXXXXXXXXXXXXXX\r\n"
            "XXXXXXXXX#XXXXXXXXXX\r\n"
            "XXXXXXX#####XXXXXXXX\r\n"
            "XXXXXXXXXXXXXXXXXXXX\r\n"
            "XXXXXXXXX#XXXXXXXXXX\r\n"
            "XXXXXXXXXXXXXXXXXXXX\r\n"
            "\e[2;9H\e[1J"
            "\e[11G\e[K"
            "\e[3;7H\e[1K"
            "\e[13G\e[0K"
            "\e[5;11H\e[J\e[2D\e[1K"
            "\e[A\e[2K"
            "\r\n\r\n\r\n\r\n"
            "This is the only \"X\" that should be visible. "
            "Line one, four and six should\r\n"
            "be empty. If line four were to be removed, a 3x5 character\r\n"
            "large plus-sign would be visible, "
            "made of 7 characters.\r\n");
    break;
  case 4:
    simple_write(
        fd, "\r\n"
            "\e(0"
            "lqwqk    "
            "\r\n"
            "xAxBx    "
            "\r\n"
            "tqnqu    "
            "\r\n"
            "xCxDx    "
            "\r\n"
            "mqvqj    "
            "\r\n"
            "y z a ` f g\e(B\r\n\r\n"
            "A, B, C and D should be nicely framed with lines, then a line of "
            "symbols;\r\n"
            "<=, >=, checkers, a diamond, a degree-sign and finally +-\r\n");
    break;
  case 5:
    simple_write(
        fd,
        "\r\n"
        "\e[2J\e[H\r\n"
        "\e[33;41;1m"
        "Storing the cursor here.\e7XXXXXX\r\n"
        "\e[0;32;40mChanging cursor colour.\r\n"
        "\e8XXXXXXXXXXXXX\r\n"
        "\e8 After restoration of cursor.\e[m\r\n\r\n\r\n"
        "The first row is empty, the second row should read:\r\n"
        "Storing the cursor here. After restoration of cursor.\r\n"
        "The colour of the second row is bright yellow on a red background,\r\n"
        "the third row is written in dark green above a black background.\r\n"
        "This is the only X.\r\n");
    break;
  case 6:
    simple_write(
        fd, "\e[2J\e[H"
            "1\r\n"
            "X\r\n"
            "X\r\n"
            "X\r\n"
            "5\r\n"
            "\e[;3HXXXACF"
            "\e[3G"
            "\e[P"
            "\e[2P"
            "\e[4G"
            "\e[@"
            "\e[2C"
            "\e[2@"
            "\e[4G"
            "B"
            "\e[6G"
            "DE"
            "\e[2H"
            "\e[M"
            "\e[2M"
            "\e[L"
            "\e[2L"
            "\e[2H"
            "2\r\n3\r\n4"
            "\e[5;3H"
            "a\e[2b"
            "b\e[b"
            "c\e[1b\e[b"
            "d"
            "\r\n\r\n\r\n"
            "The first row should be: \"1 ABCDEF\".\r\n"
            "There should be a column with 1..5 "
            "and this is the only X.\r\n"
            "The fifth row should be \"5 aaabbccd\" or \"5 aaabbcccd\"\r\n");
    break;
  case 7:
    simple_write(fd, "\e]0;Window and icon name\007"
                     "\e]1;Icon name\007"
                     "\e]2;Window title\007"
                     "The window title should now be \"Window title\"\r\n"
                     "The icon name should now be \"Icon name\"\r\n");
    break;
  case 8:
    simple_write(fd, "\e[2J"
                     "\e[6;0H"
                     "6"
                     "\e[;4r"
                     "X\r\n"
                     "X\r\n"
                     "X\r\n"
                     "X\r\n"
                     "2\r\n"
                     "X\r\n"
                     "X"
                     "\e[3;5r"
                     "X\r\n"
                     "\r\n"
                     "X\r\n"
                     "X\r\n"
                     "3\r\n"
                     "4\r\n"
                     "\e[r1"
                     "\e[5;1H"
                     "5"
                     "\r\n"
                     "\r\n"
                     "\r\n"
                     "A column with 1..6 is shown, starting at the first row. "
                     "This is the only X.\r\n");
    simple_write(fd, "\e[10H");
    break;
  case 9:
    simple_write(fd, "\ec\r\n");
    break;
  case 10:
    simple_write(
        fd,
        "\e[2J"
        "\e[5;1H"
        "6"
        "\e[1;1H"
        "2"
        "\eM"
        "\010"
        "1"
        "\e[3;5r"
        "\r\n\r\n"
        "X"
        "\eM"
        "\010"
        "5"
        "\eM"
        "\010"
        "4"
        "\eM"
        "\010"
        "3"
        "\e[H"
        "\eM"
        "This is the last line of the screen."
        "\e[r1"
        "\e[8;1H"
        "The screen should show 1..6 from the upper left corner and down.\r\n"
        "The last line should have a text about it. This is the only X.\r\n");
    break;
  case 11:
    simple_write(fd, "This should show a single tile:\r\n"
                     "\e[2;3z");
    int i;
    for (i = 0; i < 80; i++) {
      char buff[80];
      snprintf(buff, 79,
               "\e[0;%uz"
               "X"
               "\e[1z",
               i);
      simple_write(fd, buff);
    }
    simple_write(fd, "\e[3z"
                     "\r\nThis is the only X.\r\n");
    break;
  default:
    simple_write(
        fd, "VT100/102 & xterm tests:\r\n"
            "testcc 1  - clears the screen, absolute cursor movement tests.\r\n"
            "testcc 2  - clears the screen, relative cursor movement tests.\r\n"
            "testcc 3  - erase tests.\r\n"
            "testcc 4  - \"DEC\" graphics.\r\n"
            "testcc 5  - storing/restoring the cursor.\r\n"
            "testcc 6  - text insertion tests.\r\n"
            "testcc 7  - xterm icon & window title tests.\r\n"
            "testcc 8  - scroll region tests.\r\n"
            "testcc 9  - reset the terminal.\r\n"
            "testcc 10 - test Reverse Index.\r\n"
            "testcc 11 - NetHack's vt_tileset patch's output.\r\n");
  }
}


x86 assembly (clang, -O0):
<test_cc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x78(%rbp)
sub    $0xa,%eax
ja     12ae <test_cc+0x17e>
mov    -0x78(%rbp),%rax
lea    0xe98(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4(%rbp),%edi
lea    0xeb1(%rip),%rsi
call   1030 <simple_write@plt>
jmp    12bd <test_cc+0x18d>
mov    -0x4(%rbp),%edi
lea    0xfb7(%rip),%rsi
call   1030 <simple_write@plt>
jmp    12bd <test_cc+0x18d>
mov    -0x4(%rbp),%edi
lea    0x10a4(%rip),%rsi
call   1030 <simple_write@plt>
jmp    12bd <test_cc+0x18d>
mov    -0x4(%rbp),%edi
lea    0x1223(%rip),%rsi
call   1030 <simple_write@plt>
jmp    12bd <test_cc+0x18d>
mov    -0x4(%rbp),%edi
lea    0x12e4(%rip),%rsi
call   1030 <simple_write@plt>
jmp    12bd <test_cc+0x18d>
mov    -0x4(%rbp),%edi
lea    0x146b(%rip),%rsi
call   1030 <simple_write@plt>
jmp    12bd <test_cc+0x18d>
mov    -0x4(%rbp),%edi
lea    0x1572(%rip),%rsi
call   1030 <simple_write@plt>
jmp    12bd <test_cc+0x18d>
mov    -0x4(%rbp),%edi
lea    0x15ef(%rip),%rsi
call   1030 <simple_write@plt>
mov    -0x4(%rbp),%edi
lea    0x1679(%rip),%rsi
call   1030 <simple_write@plt>
jmp    12bd <test_cc+0x18d>
mov    -0x4(%rbp),%edi
lea    0x166b(%rip),%rsi
call   1030 <simple_write@plt>
jmp    12bd <test_cc+0x18d>
mov    -0x4(%rbp),%edi
lea    0x165c(%rip),%rsi
call   1030 <simple_write@plt>
jmp    12bd <test_cc+0x18d>
mov    -0x4(%rbp),%edi
lea    0x172b(%rip),%rsi
call   1030 <simple_write@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x50,-0x14(%rbp)
jge    129a <test_cc+0x16a>
lea    -0x70(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    $0x4f,%esi
lea    0x172a(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x70(%rbp),%rsi
call   1030 <simple_write@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    125e <test_cc+0x12e>
mov    -0x4(%rbp),%edi
lea    0x170e(%rip),%rsi
call   1030 <simple_write@plt>
jmp    12bd <test_cc+0x18d>
mov    -0x4(%rbp),%edi
lea    0x1716(%rip),%rsi
call   1030 <simple_write@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_cc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    %edi,%r15d
mov    %rsi,%rdi
call   1050 <atoi@plt>
add    $0xffffffff,%eax
cmp    $0xa,%eax
ja     1166 <test_cc+0x36>
lea    0xeac(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xec8(%rip),%rsi
jmp    11cd <test_cc+0x9d>
lea    0x1861(%rip),%rsi
jmp    11cd <test_cc+0x9d>
lea    0xfd0(%rip),%rsi
jmp    11cd <test_cc+0x9d>
lea    0x10c8(%rip),%rsi
jmp    11cd <test_cc+0x9d>
lea    0x1252(%rip),%rsi
jmp    11cd <test_cc+0x9d>
lea    0x131e(%rip),%rsi
jmp    11cd <test_cc+0x9d>
lea    0x14b0(%rip),%rsi
jmp    11cd <test_cc+0x9d>
lea    0x15c2(%rip),%rsi
jmp    11cd <test_cc+0x9d>
lea    0x164a(%rip),%rsi
mov    %r15d,%edi
call   1030 <simple_write@plt>
lea    0x16d4(%rip),%rsi
jmp    11cd <test_cc+0x9d>
lea    0x16d1(%rip),%rsi
jmp    11cd <test_cc+0x9d>
lea    0x16cd(%rip),%rsi
mov    %r15d,%edi
add    $0x58,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <simple_write@plt>
lea    0x1797(%rip),%rsi
mov    %r15d,%edi
call   1030 <simple_write@plt>
xor    %ebp,%ebp
lea    0x17ae(%rip),%r14
mov    %rsp,%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x4f,%esi
mov    %r14,%rdx
mov    %ebp,%ecx
call   1040 <snprintf@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
call   1030 <simple_write@plt>
add    $0x1,%ebp
cmp    $0x50,%ebp
jne    1200 <test_cc+0xd0>
lea    0x1786(%rip),%rsi
mov    %r15d,%edi
call   1030 <simple_write@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [282 x i8] c"\1B[3H\1B[2J>\1B[HX\1B[;5HV\1B[1;1H \0D\0A\1B[3;5H* - should be pointed to by V and > (line 3, column 5)\0D\0A\0D\0AThe screen should only contain this text, the message above, \22V\22, \22>\22\0D\0Aand \22* -\22 plus the new prompt. The V should be on the first line,\0D\0Athe > in the first column and this is the only X.\0D\0A\00"
@.str.1 = [257 x i8] c"\1B[H\1B[2J123456789>\0D\0A2 YY\0D\0A3 YabY\0D\0A4 YcdY\0D\0A5 YY\0D\0AV\0D\0A\1B[H\1B[B\1B[2B\1B[C\1B[4CDX\1B[2A\1B[3D \1B[D\1B[2D\1B[B AX \1B[E\1B[3C C\1B[F\1B[2F\1B[5C\1B[2BB\1B[6G\1B[2B \1B[5G \1B[4;7H \0D\0A\0D\0A\0D\0A\0D\0AThe screen should now show \22AB\22 and below it \22CD\22.\0D\0AA should be shown in the third row, fifth column.\0D\0A\00"
@.str.2 = [403 x i8] c"\1B[H\1B[2JXXXXXXXXXXXXXXXXXXXX\0D\0AXXXXXXXXX#XXXXXXXXXX\0D\0AXXXXXXX#####XXXXXXXX\0D\0AXXXXXXXXXXXXXXXXXXXX\0D\0AXXXXXXXXX#XXXXXXXXXX\0D\0AXXXXXXXXXXXXXXXXXXXX\0D\0A\1B[2;9H\1B[1J\1B[11G\1B[K\1B[3;7H\1B[1K\1B[13G\1B[0K\1B[5;11H\1B[J\1B[2D\1B[1K\1B[A\1B[2K\0D\0A\0D\0A\0D\0A\0D\0AThis is the only \22X\22 that should be visible. Line one, four and six should\0D\0Abe empty. If line four were to be removed, a 3x5 character\0D\0Alarge plus-sign would be visible, made of 7 characters.\0D\0A\00"
@.str.3 = [213 x i8] c"\0D\0A\1B(0lqwqk \0D\0AxAxBx \0D\0Atqnqu \0D\0AxCxDx \0D\0Amqvqj \0D\0Ay z a ` f g\1B(B\0D\0A\0D\0AA, B, C and D should be nicely framed with lines, then a line of symbols;\0D\0A<=, >=, checkers, a diamond, a degree-sign and finally +-\0D\0A\00"
@.str.4 = [411 x i8] c"\0D\0A\1B[2J\1B[H\0D\0A\1B[33;41;1mStoring the cursor here.\1B7XXXXXX\0D\0A\1B[0;32;40mChanging cursor colour.\0D\0A\1B8XXXXXXXXXXXXX\0D\0A\1B8 After restoration of cursor.\1B[m\0D\0A\0D\0A\0D\0AThe first row is empty, the second row should read:\0D\0AStoring the cursor here. After restoration of cursor.\0D\0AThe colour of the second row is bright yellow on a red background,\0D\0Athe third row is written in dark green above a black background.\0D\0AThis is the only X.\0D\0A\00"
@.str.5 = [283 x i8] c"\1B[2J\1B[H1\0D\0AX\0D\0AX\0D\0AX\0D\0A5\0D\0A\1B[;3HXXXACF\1B[3G\1B[P\1B[2P\1B[4G\1B[@\1B[2C\1B[2@\1B[4GB\1B[6GDE\1B[2H\1B[M\1B[2M\1B[L\1B[2L\1B[2H2\0D\0A3\0D\0A4\1B[5;3Ha\1B[2bb\1B[bc\1B[1b\1B[bd\0D\0A\0D\0A\0D\0AThe first row should be: \221 ABCDEF\22.\0D\0AThere should be a column with 1..5 and this is the only X.\0D\0AThe fifth row should be \225 aaabbccd\22 or \225 aaabbcccd\22\0D\0A\00"
@.str.6 = [145 x i8] c"\1B]0;Window and icon name\07\1B]1;Icon name\07\1B]2;Window title\07The window title should now be \22Window title\22\0D\0AThe icon name should now be \22Icon name\22\0D\0A\00"
@.str.7 = [153 x i8] c"\1B[2J\1B[6;0H6\1B[;4rX\0D\0AX\0D\0AX\0D\0AX\0D\0A2\0D\0AX\0D\0AX\1B[3;5rX\0D\0A\0D\0AX\0D\0AX\0D\0A3\0D\0A4\0D\0A\1B[r1\1B[5;1H5\0D\0A\0D\0A\0D\0AA column with 1..6 is shown, starting at the first row. This is the only X.\0D\0A\00"
@.str.8 = [6 x i8] c"\1B[10H\00"
@.str.9 = [5 x i8] c"\1Bc\0D\0A\00"
@.str.10 = [227 x i8] c"\1B[2J\1B[5;1H6\1B[1;1H2\1BM\081\1B[3;5r\0D\0A\0D\0AX\1BM\085\1BM\084\1BM\083\1B[H\1BMThis is the last line of the screen.\1B[r1\1B[8;1HThe screen should show 1..6 from the upper left corner and down.\0D\0AThe last line should have a text about it. This is the only X.\0D\0A\00"
@.str.11 = [40 x i8] c"This should show a single tile:\0D\0A\1B[2;3z\00"
@.str.12 = [13 x i8] c"\1B[0;%uzX\1B[1z\00"
@.str.13 = [28 x i8] c"\1B[3z\0D\0AThis is the only X.\0D\0A\00"
@.str.14 = [484 x i8] c"VT100/102 & xterm tests:\0D\0Atestcc 1 - clears the screen, absolute cursor movement tests.\0D\0Atestcc 2 - clears the screen, relative cursor movement tests.\0D\0Atestcc 3 - erase tests.\0D\0Atestcc 4 - \22DEC\22 graphics.\0D\0Atestcc 5 - storing/restoring the cursor.\0D\0Atestcc 6 - text insertion tests.\0D\0Atestcc 7 - xterm icon & window title tests.\0D\0Atestcc 8 - scroll region tests.\0D\0Atestcc 9 - reset the terminal.\0D\0Atestcc 10 - test Reverse Index.\0D\0Atestcc 11 - NetHack's vt_tileset patch's output.\0D\0A\00"
define void @test_cc(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [80 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i32 @atoi(i8* %7)
switch i32 %8, label %60 [
i32 1, label %9
i32 2, label %12
i32 3, label %15
i32 4, label %18
i32 5, label %21
i32 6, label %24
i32 7, label %27
i32 8, label %30
i32 9, label %35
i32 10, label %38
i32 11, label %41
]
9: ; preds = %2
%10 = load i32, i32* %3
%11 = call i32 @simple_write(i32 %10, i8* getelementptr inbounds ([282 x i8], [282 x i8]* @.str, i64 0, i64 0))
br label %63
12: ; preds = %2
%13 = load i32, i32* %3
%14 = call i32 @simple_write(i32 %13, i8* getelementptr inbounds ([257 x i8], [257 x i8]* @.str.1, i64 0, i64 0))
br label %63
15: ; preds = %2
%16 = load i32, i32* %3
%17 = call i32 @simple_write(i32 %16, i8* getelementptr inbounds ([403 x i8], [403 x i8]* @.str.2, i64 0, i64 0))
br label %63
18: ; preds = %2
%19 = load i32, i32* %3
%20 = call i32 @simple_write(i32 %19, i8* getelementptr inbounds ([213 x i8], [213 x i8]* @.str.3, i64 0, i64 0))
br label %63
21: ; preds = %2
%22 = load i32, i32* %3
%23 = call i32 @simple_write(i32 %22, i8* getelementptr inbounds ([411 x i8], [411 x i8]* @.str.4, i64 0, i64 0))
br label %63
24: ; preds = %2
%25 = load i32, i32* %3
%26 = call i32 @simple_write(i32 %25, i8* getelementptr inbounds ([283 x i8], [283 x i8]* @.str.5, i64 0, i64 0))
br label %63
27: ; preds = %2
%28 = load i32, i32* %3
%29 = call i32 @simple_write(i32 %28, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.6, i64 0, i64 0))
br label %63
30: ; preds = %2
%31 = load i32, i32* %3
%32 = call i32 @simple_write(i32 %31, i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.7, i64 0, i64 0))
%33 = load i32, i32* %3
%34 = call i32 @simple_write(i32 %33, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
br label %63
35: ; preds = %2
%36 = load i32, i32* %3
%37 = call i32 @simple_write(i32 %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %63
38: ; preds = %2
%39 = load i32, i32* %3
%40 = call i32 @simple_write(i32 %39, i8* getelementptr inbounds ([227 x i8], [227 x i8]* @.str.10, i64 0, i64 0))
br label %63
41: ; preds = %2
%42 = load i32, i32* %3
%43 = call i32 @simple_write(i32 %42, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %5
br label %44
44: ; preds = %54, %41
%45 = load i32, i32* %5
%46 = icmp slt i32 %45, 80
br i1 %46, label %47, label %57
47: ; preds = %44
%48 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%49 = load i32, i32* %5
%50 = call i32 @snprintf(i8* %48, i32 79, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), i32 %49)
%51 = load i32, i32* %3
%52 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%53 = call i32 @simple_write(i32 %51, i8* %52)
br label %54
54: ; preds = %47
%55 = load i32, i32* %5
%56 = add nsw i32 %55, 1
store i32 %56, i32* %5
br label %44
57: ; preds = %44
%58 = load i32, i32* %3
%59 = call i32 @simple_write(i32 %58, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
br label %63
60: ; preds = %2
%61 = load i32, i32* %3
%62 = call i32 @simple_write(i32 %61, i8* getelementptr inbounds ([484 x i8], [484 x i8]* @.str.14, i64 0, i64 0))
br label %63
63: ; preds = %60, %57, %38, %35, %30, %27, %24, %21, %18, %15, %12, %9
ret void
}

LLVM IR (-O2):
@.str = [282 x i8] c"\1B[3H\1B[2J>\1B[HX\1B[;5HV\1B[1;1H \0D\0A\1B[3;5H* - should be pointed to by V and > (line 3, column 5)\0D\0A\0D\0AThe screen should only contain this text, the message above, \22V\22, \22>\22\0D\0Aand \22* -\22 plus the new prompt. The V should be on the first line,\0D\0Athe > in the first column and this is the only X.\0D\0A\00"
@.str.1 = [257 x i8] c"\1B[H\1B[2J123456789>\0D\0A2 YY\0D\0A3 YabY\0D\0A4 YcdY\0D\0A5 YY\0D\0AV\0D\0A\1B[H\1B[B\1B[2B\1B[C\1B[4CDX\1B[2A\1B[3D \1B[D\1B[2D\1B[B AX \1B[E\1B[3C C\1B[F\1B[2F\1B[5C\1B[2BB\1B[6G\1B[2B \1B[5G \1B[4;7H \0D\0A\0D\0A\0D\0A\0D\0AThe screen should now show \22AB\22 and below it \22CD\22.\0D\0AA should be shown in the third row, fifth column.\0D\0A\00"
@.str.2 = [403 x i8] c"\1B[H\1B[2JXXXXXXXXXXXXXXXXXXXX\0D\0AXXXXXXXXX#XXXXXXXXXX\0D\0AXXXXXXX#####XXXXXXXX\0D\0AXXXXXXXXXXXXXXXXXXXX\0D\0AXXXXXXXXX#XXXXXXXXXX\0D\0AXXXXXXXXXXXXXXXXXXXX\0D\0A\1B[2;9H\1B[1J\1B[11G\1B[K\1B[3;7H\1B[1K\1B[13G\1B[0K\1B[5;11H\1B[J\1B[2D\1B[1K\1B[A\1B[2K\0D\0A\0D\0A\0D\0A\0D\0AThis is the only \22X\22 that should be visible. Line one, four and six should\0D\0Abe empty. If line four were to be removed, a 3x5 character\0D\0Alarge plus-sign would be visible, made of 7 characters.\0D\0A\00"
@.str.3 = [213 x i8] c"\0D\0A\1B(0lqwqk \0D\0AxAxBx \0D\0Atqnqu \0D\0AxCxDx \0D\0Amqvqj \0D\0Ay z a ` f g\1B(B\0D\0A\0D\0AA, B, C and D should be nicely framed with lines, then a line of symbols;\0D\0A<=, >=, checkers, a diamond, a degree-sign and finally +-\0D\0A\00"
@.str.4 = [411 x i8] c"\0D\0A\1B[2J\1B[H\0D\0A\1B[33;41;1mStoring the cursor here.\1B7XXXXXX\0D\0A\1B[0;32;40mChanging cursor colour.\0D\0A\1B8XXXXXXXXXXXXX\0D\0A\1B8 After restoration of cursor.\1B[m\0D\0A\0D\0A\0D\0AThe first row is empty, the second row should read:\0D\0AStoring the cursor here. After restoration of cursor.\0D\0AThe colour of the second row is bright yellow on a red background,\0D\0Athe third row is written in dark green above a black background.\0D\0AThis is the only X.\0D\0A\00"
@.str.5 = [283 x i8] c"\1B[2J\1B[H1\0D\0AX\0D\0AX\0D\0AX\0D\0A5\0D\0A\1B[;3HXXXACF\1B[3G\1B[P\1B[2P\1B[4G\1B[@\1B[2C\1B[2@\1B[4GB\1B[6GDE\1B[2H\1B[M\1B[2M\1B[L\1B[2L\1B[2H2\0D\0A3\0D\0A4\1B[5;3Ha\1B[2bb\1B[bc\1B[1b\1B[bd\0D\0A\0D\0A\0D\0AThe first row should be: \221 ABCDEF\22.\0D\0AThere should be a column with 1..5 and this is the only X.\0D\0AThe fifth row should be \225 aaabbccd\22 or \225 aaabbcccd\22\0D\0A\00"
@.str.6 = [145 x i8] c"\1B]0;Window and icon name\07\1B]1;Icon name\07\1B]2;Window title\07The window title should now be \22Window title\22\0D\0AThe icon name should now be \22Icon name\22\0D\0A\00"
@.str.7 = [153 x i8] c"\1B[2J\1B[6;0H6\1B[;4rX\0D\0AX\0D\0AX\0D\0AX\0D\0A2\0D\0AX\0D\0AX\1B[3;5rX\0D\0A\0D\0AX\0D\0AX\0D\0A3\0D\0A4\0D\0A\1B[r1\1B[5;1H5\0D\0A\0D\0A\0D\0AA column with 1..6 is shown, starting at the first row. This is the only X.\0D\0A\00"
@.str.8 = [6 x i8] c"\1B[10H\00"
@.str.9 = [5 x i8] c"\1Bc\0D\0A\00"
@.str.10 = [227 x i8] c"\1B[2J\1B[5;1H6\1B[1;1H2\1BM\081\1B[3;5r\0D\0A\0D\0AX\1BM\085\1BM\084\1BM\083\1B[H\1BMThis is the last line of the screen.\1B[r1\1B[8;1HThe screen should show 1..6 from the upper left corner and down.\0D\0AThe last line should have a text about it. This is the only X.\0D\0A\00"
@.str.11 = [40 x i8] c"This should show a single tile:\0D\0A\1B[2;3z\00"
@.str.12 = [13 x i8] c"\1B[0;%uzX\1B[1z\00"
@.str.13 = [28 x i8] c"\1B[3z\0D\0AThis is the only X.\0D\0A\00"
@.str.14 = [484 x i8] c"VT100/102 & xterm tests:\0D\0Atestcc 1 - clears the screen, absolute cursor movement tests.\0D\0Atestcc 2 - clears the screen, relative cursor movement tests.\0D\0Atestcc 3 - erase tests.\0D\0Atestcc 4 - \22DEC\22 graphics.\0D\0Atestcc 5 - storing/restoring the cursor.\0D\0Atestcc 6 - text insertion tests.\0D\0Atestcc 7 - xterm icon & window title tests.\0D\0Atestcc 8 - scroll region tests.\0D\0Atestcc 9 - reset the terminal.\0D\0Atestcc 10 - test Reverse Index.\0D\0Atestcc 11 - NetHack's vt_tileset patch's output.\0D\0A\00"
define void @test_cc(i32 %0, i8* nocapture %1) {
%3 = alloca [80 x i8]
%4 = tail call i32 @atoi(i8* %1)
switch i32 %4, label %37 [
i32 1, label %5
i32 2, label %7
i32 3, label %9
i32 4, label %11
i32 5, label %13
i32 6, label %15
i32 7, label %17
i32 8, label %19
i32 9, label %22
i32 10, label %24
i32 11, label %26
]
5: ; preds = %2
%6 = tail call i32 @simple_write(i32 %0, i8* getelementptr inbounds ([282 x i8], [282 x i8]* @.str, i64 0, i64 0))
br label %39
7: ; preds = %2
%8 = tail call i32 @simple_write(i32 %0, i8* getelementptr inbounds ([257 x i8], [257 x i8]* @.str.1, i64 0, i64 0))
br label %39
9: ; preds = %2
%10 = tail call i32 @simple_write(i32 %0, i8* getelementptr inbounds ([403 x i8], [403 x i8]* @.str.2, i64 0, i64 0))
br label %39
11: ; preds = %2
%12 = tail call i32 @simple_write(i32 %0, i8* getelementptr inbounds ([213 x i8], [213 x i8]* @.str.3, i64 0, i64 0))
br label %39
13: ; preds = %2
%14 = tail call i32 @simple_write(i32 %0, i8* getelementptr inbounds ([411 x i8], [411 x i8]* @.str.4, i64 0, i64 0))
br label %39
15: ; preds = %2
%16 = tail call i32 @simple_write(i32 %0, i8* getelementptr inbounds ([283 x i8], [283 x i8]* @.str.5, i64 0, i64 0))
br label %39
17: ; preds = %2
%18 = tail call i32 @simple_write(i32 %0, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.6, i64 0, i64 0))
br label %39
19: ; preds = %2
%20 = tail call i32 @simple_write(i32 %0, i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.7, i64 0, i64 0))
%21 = tail call i32 @simple_write(i32 %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
br label %39
22: ; preds = %2
%23 = tail call i32 @simple_write(i32 %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %39
24: ; preds = %2
%25 = tail call i32 @simple_write(i32 %0, i8* getelementptr inbounds ([227 x i8], [227 x i8]* @.str.10, i64 0, i64 0))
br label %39
26: ; preds = %2
%27 = tail call i32 @simple_write(i32 %0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0))
%28 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
br label %29
29: ; preds = %26, %29
%30 = phi i32 [ 0, %26 ], [ %33, %29 ]
%31 = call i32 @snprintf(i8* %28, i32 79, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), i32 %30)
%32 = call i32 @simple_write(i32 %0, i8* %28)
%33 = add nuw nsw i32 %30, 1
%34 = icmp eq i32 %33, 80
br i1 %34, label %35, label %29
35: ; preds = %29
%36 = call i32 @simple_write(i32 %0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
br label %39
37: ; preds = %2
%38 = tail call i32 @simple_write(i32 %0, i8* getelementptr inbounds ([484 x i8], [484 x i8]* @.str.14, i64 0, i64 0))
br label %39
39: ; preds = %37, %35, %24, %22, %19, %17, %15, %13, %11, %9, %7, %5
ret void
}