void main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("Usage xt_control c c nn c ...\nwhere c is a char and nn is the "
           "ASCII code for a char\nFor instance:\nxt_control 27 [ 2 J\n\n");
    return;
  }
  int i;
  char input[20];
  for (i = 1; i < argc; ++i) {
    if (strlen(argv[i]) == 1)
      printf("%c", argv[i][0]);
    else
      printf("%c", atoi(argv[i]));
  }
  printf("%c[6n", 27);
  for (i = 0; (input[i] = getchar()) != 'R'; ++i)
    ;
  input[i++] = 'R';
  input[i] = '\0';
  printf("reported: |%s|\n", input);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x4(%rbp)
jge    116c <main+0x2c>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1267 <main+0x127>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11f2 <main+0xb2>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%rax
jne    11bc <main+0x7c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%esi
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11df <main+0x9f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x0,%al
call   1060 <atoi@plt>
mov    %eax,%esi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e4 <main+0xa4>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1173 <main+0x33>
lea    0xe82(%rip),%rdi
mov    $0x1b,%esi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
movslq -0x14(%rbp),%rcx
mov    %al,-0x30(%rbp,%rcx,1)
movsbl %al,%eax
cmp    $0x52,%eax
je     123a <main+0xfa>
jmp    122c <main+0xec>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    120c <main+0xcc>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
cltq
movb   $0x52,-0x30(%rbp,%rax,1)
movslq -0x14(%rbp),%rax
movb   $0x0,-0x30(%rbp,%rax,1)
lea    -0x30(%rbp),%rsi
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
cmp    $0x1,%edi
jg     1171 <main+0x11>
lea    0xeaa(%rip),%rdi
jmp    1040 <puts@plt>
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %edi,%r15d
mov    $0x1,%ebx
jmp    11aa <main+0x4a>
nopl   0x0(%rax)
mov    %r12,%rdi
xor    %eax,%eax
call   1080 <atoi@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
je     11c3 <main+0x63>
mov    (%r14,%rbx,8),%r12
mov    %r12,%rdi
call   1050 <strlen@plt>
cmp    $0x1,%rax
jne    1190 <main+0x30>
movsbl (%r12),%edi
jmp    119c <main+0x3c>
lea    0xe36(%rip),%rdi
mov    $0x1b,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <getchar@plt>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x52,%al
jne    11e0 <main+0x80>
lea    -0x1(%rbx),%eax
movb   $0x52,(%rsp,%rax,1)
mov    %ebx,%eax
movb   $0x0,(%rsp,%rax,1)
lea    0xe00(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [120 x i8] c"Usage xt_control c c nn c ...\0Awhere c is a char and nn is the ASCII code for a char\0AFor instance:\0Axt_control 27 [ 2 J\0A\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [6 x i8] c"%c[6n\00"
@.str.3 = [16 x i8] c"reported: |%s|\0A\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca [20 x i8]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([120 x i8], [120 x i8]* @.str, i64 0, i64 0))
br label %70
11: ; preds = %2
store i32 1, i32* %5
br label %12
12: ; preds = %43, %11
%13 = load i32, i32* %5
%14 = load i32, i32* %3
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %46
16: ; preds = %12
%17 = load i8**, i8*** %4
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = call i64 @strlen(i8* %21)
%23 = icmp eq i64 %22, 1
br i1 %23, label %24, label %34
24: ; preds = %16
%25 = load i8**, i8*** %4
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = getelementptr inbounds i8, i8* %29, i64 0
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %32)
br label %42
34: ; preds = %16
%35 = load i8**, i8*** %4
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
%39 = load i8*, i8** %38
%40 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %34, %24
br label %43
43: ; preds = %42
%44 = load i32, i32* %5
%45 = add nsw i32 %44, 1
store i32 %45, i32* %5
br label %12
46: ; preds = %12
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 27)
store i32 0, i32* %5
br label %48
48: ; preds = %57, %46
%49 = call i32 (...) @getchar()
%50 = trunc i32 %49 to i8
%51 = load i32, i32* %5
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 %52
store i8 %50, i8* %53
%54 = sext i8 %50 to i32
%55 = icmp ne i32 %54, 82
br i1 %55, label %56, label %60
56: ; preds = %48
br label %57
57: ; preds = %56
%58 = load i32, i32* %5
%59 = add nsw i32 %58, 1
store i32 %59, i32* %5
br label %48
60: ; preds = %48
%61 = load i32, i32* %5
%62 = add nsw i32 %61, 1
store i32 %62, i32* %5
%63 = sext i32 %61 to i64
%64 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 %63
store i8 82, i8* %64
%65 = load i32, i32* %5
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 %66
store i8 0, i8* %67
%68 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %68)
br label %70
70: ; preds = %60, %9
ret void
}

LLVM IR (-O2):
@.str.2 = [6 x i8] c"%c[6n\00"
@.str.3 = [16 x i8] c"reported: |%s|\0A\00"
@str = [119 x i8] c"Usage xt_control c c nn c ...\0Awhere c is a char and nn is the ASCII code for a char\0AFor instance:\0Axt_control 27 [ 2 J\0A\00"
define void @main(i32 %0, i8** nocapture %1) {
%3 = alloca [20 x i8]
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([119 x i8], [119 x i8]* @str, i64 0, i64 0))
br label %43
7: ; preds = %2
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%9 = zext i32 %0 to i64
br label %10
10: ; preds = %7, %21
%11 = phi i64 [ 1, %7 ], [ %24, %21 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 %11
%13 = load i8*, i8** %12
%14 = tail call i64 @strlen(i8* dereferenceable(1) %13)
%15 = icmp eq i64 %14, 1
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = load i8, i8* %13
%18 = sext i8 %17 to i32
br label %21
19: ; preds = %10
%20 = tail call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %13)
br label %21
21: ; preds = %16, %19
%22 = phi i32 [ %18, %16 ], [ %20, %19 ]
%23 = tail call i32 @putchar(i32 %22)
%24 = add nuw nsw i64 %11, 1
%25 = icmp eq i64 %24, %9
br i1 %25, label %26, label %10
26: ; preds = %21
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 27)
br label %28
28: ; preds = %28, %26
%29 = phi i64 [ %35, %28 ], [ 0, %26 ]
%30 = tail call i32 (...) @getchar()
%31 = trunc i32 %30 to i8
%32 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 %29
store i8 %31, i8* %32
%33 = and i32 %30, 255
%34 = icmp eq i32 %33, 82
%35 = add nuw i64 %29, 1
br i1 %34, label %36, label %28
36: ; preds = %28
%37 = and i64 %29, 4294967295
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 %37
%39 = add i64 %29, 1
store i8 82, i8* %38
%40 = and i64 %39, 4294967295
%41 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 %40
store i8 0, i8* %41
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %8)
br label %43
43: ; preds = %36, %5
ret void
}