#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*/ dropBigger(char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ getchar();
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char, char, char);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  int i, lines;
  char a, b, c, *p, *start;
  scanf("%d", &lines);
  getchar();
  p = start = (char *)malloc(lines * 3 + 1);
  for (i = 0; i < lines; i++) {
    scanf("%c%c%c", &a, &b, &c);
    getchar();
    dropBigger(&a, &b);
    dropBigger(&b, &c);
    dropBigger(&a, &b);
    *(p++) = a;
    *(p++) = b;
    *(p++) = c;
  }
  *p = '\0';
  p = start;
  for (i = 0; i < lines; i++) {
    printf("%c %c %c\n", *p, *(p + 1), *(p + 2));
    p += 3;
  }
  free(start);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
imul   $0x3,-0xc(%rbp),%edi
add    $0x1,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1241 <main+0xe1>
lea    0xe4d(%rip),%rdi
lea    -0xd(%rbp),%rsi
lea    -0xe(%rbp),%rdx
lea    -0xf(%rbp),%rcx
mov    $0x0,%al
call   1080 <scanf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
lea    -0xd(%rbp),%rdi
lea    -0xe(%rbp),%rsi
call   1050 <dropBigger@plt>
lea    -0xe(%rbp),%rdi
lea    -0xf(%rbp),%rsi
call   1050 <dropBigger@plt>
lea    -0xd(%rbp),%rdi
lea    -0xe(%rbp),%rsi
call   1050 <dropBigger@plt>
mov    -0xd(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0xe(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0xf(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a3 <main+0x43>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12a4 <main+0x144>
mov    -0x18(%rbp),%rax
mov    (%rax),%dl
mov    -0x18(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x18(%rbp),%rax
lea    0xd8f(%rip),%rdi
movsbl %dl,%esi
movsbl %cl,%edx
movsbl 0x2(%rax),%ecx
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1257 <main+0xf7>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe8b(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0xc(%rsp),%eax
lea    (%rax,%rax,2),%edi
add    $0x1,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
cmpl   $0x0,0xc(%rsp)
jle    1239 <main+0xd9>
mov    %r15,%rbp
lea    0xe54(%rip),%r15
lea    0xb(%rsp),%r12
lea    0xa(%rsp),%rbx
lea    0x9(%rsp),%r13
mov    %rbp,0x10(%rsp)
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1080 <scanf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <dropBigger@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <dropBigger@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <dropBigger@plt>
movzbl 0xb(%rsp),%eax
mov    %al,0x0(%rbp)
movzbl 0xa(%rsp),%eax
mov    %al,0x1(%rbp)
movzbl 0x9(%rsp),%eax
mov    %al,0x2(%rbp)
add    $0x3,%rbp
add    $0x1,%r14d
cmp    0xc(%rsp),%r14d
jl     11d0 <main+0x70>
mov    0x10(%rsp),%r15
jmp    123c <main+0xdc>
mov    %r15,%rbp
movb   $0x0,0x0(%rbp)
cmpl   $0x0,0xc(%rsp)
jle    1280 <main+0x120>
xor    %ebp,%ebp
lea    0xdba(%rip),%r14
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%rbx),%esi
movsbl 0x1(%rbx),%edx
movsbl 0x2(%rbx),%ecx
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0x1,%ebp
add    $0x3,%rbx
cmp    0xc(%rsp),%ebp
jl     1260 <main+0x100>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [7 x i8] c"%c%c%c\00"
@.str.2 = [10 x i8] c"%c %c %c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8*
%8 = alloca i8*
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%10 = call i32 (...) @getchar()
%11 = load i32, i32* %3
%12 = mul nsw i32 %11, 3
%13 = add nsw i32 %12, 1
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %8
store i8* %15, i8** %7
store i32 0, i32* %2
br label %16
16: ; preds = %35, %0
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %38
20: ; preds = %16
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %4, i8* %5, i8* %6)
%22 = call i32 (...) @getchar()
%23 = call i32 @dropBigger(i8* %4, i8* %5)
%24 = call i32 @dropBigger(i8* %5, i8* %6)
%25 = call i32 @dropBigger(i8* %4, i8* %5)
%26 = load i8, i8* %4
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %7
store i8 %26, i8* %27
%29 = load i8, i8* %5
%30 = load i8*, i8** %7
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %7
store i8 %29, i8* %30
%32 = load i8, i8* %6
%33 = load i8*, i8** %7
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %7
store i8 %32, i8* %33
br label %35
35: ; preds = %20
%36 = load i32, i32* %2
%37 = add nsw i32 %36, 1
store i32 %37, i32* %2
br label %16
38: ; preds = %16
%39 = load i8*, i8** %7
store i8 0, i8* %39
%40 = load i8*, i8** %8
store i8* %40, i8** %7
store i32 0, i32* %2
br label %41
41: ; preds = %57, %38
%42 = load i32, i32* %2
%43 = load i32, i32* %3
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %60
45: ; preds = %41
%46 = load i8*, i8** %7
%47 = load i8, i8* %46
%48 = load i8*, i8** %7
%49 = getelementptr inbounds i8, i8* %48, i64 1
%50 = load i8, i8* %49
%51 = load i8*, i8** %7
%52 = getelementptr inbounds i8, i8* %51, i64 2
%53 = load i8, i8* %52
%54 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8 signext %47, i8 signext %50, i8 signext %53)
%55 = load i8*, i8** %7
%56 = getelementptr inbounds i8, i8* %55, i64 3
store i8* %56, i8** %7
br label %57
57: ; preds = %45
%58 = load i32, i32* %2
%59 = add nsw i32 %58, 1
store i32 %59, i32* %2
br label %41
60: ; preds = %41
%61 = load i8*, i8** %8
%62 = call i32 @free(i8* %61)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [7 x i8] c"%c%c%c\00"
@.str.2 = [10 x i8] c"%c %c %c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
%5 = bitcast i32* %1 to i8*
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%7 = call i32 (...) @getchar()
%8 = load i32, i32* %1
%9 = mul nsw i32 %8, 3
%10 = add nsw i32 %9, 1
%11 = call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i8*
%13 = load i32, i32* %1
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %32
15: ; preds = %0, %15
%16 = phi i8* [ %28, %15 ], [ %12, %0 ]
%17 = phi i32 [ %29, %15 ], [ 0, %0 ]
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %3, i8* %4)
%19 = call i32 (...) @getchar()
%20 = call i32 @dropBigger(i8* %2, i8* %3)
%21 = call i32 @dropBigger(i8* %3, i8* %4)
%22 = call i32 @dropBigger(i8* %2, i8* %3)
%23 = load i8, i8* %2
%24 = getelementptr inbounds i8, i8* %16, i64 1
store i8 %23, i8* %16
%25 = load i8, i8* %3
%26 = getelementptr inbounds i8, i8* %16, i64 2
store i8 %25, i8* %24
%27 = load i8, i8* %4
%28 = getelementptr inbounds i8, i8* %16, i64 3
store i8 %27, i8* %26
%29 = add nuw nsw i32 %17, 1
%30 = load i32, i32* %1
%31 = icmp slt i32 %29, %30
br i1 %31, label %15, label %32
32: ; preds = %15, %0
%33 = phi i8* [ %12, %0 ], [ %28, %15 ]
store i8 0, i8* %33
%34 = load i32, i32* %1
%35 = icmp sgt i32 %34, 0
br i1 %35, label %36, label %49
36: ; preds = %32, %36
%37 = phi i8* [ %45, %36 ], [ %12, %32 ]
%38 = phi i32 [ %46, %36 ], [ 0, %32 ]
%39 = load i8, i8* %37
%40 = getelementptr inbounds i8, i8* %37, i64 1
%41 = load i8, i8* %40
%42 = getelementptr inbounds i8, i8* %37, i64 2
%43 = load i8, i8* %42
%44 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8 signext %39, i8 signext %41, i8 signext %43)
%45 = getelementptr inbounds i8, i8* %37, i64 3
%46 = add nuw nsw i32 %38, 1
%47 = load i32, i32* %1
%48 = icmp slt i32 %46, %47
br i1 %48, label %36, label %49
49: ; preds = %36, %32
%50 = call i32 @free(i8* %12)
ret i32 0
}