#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  char c, **string;
  short N, i, casenum;
  scanf("%hd", &N);
  string = (char **)malloc(1000 * sizeof(char *));
  for (i = 0; i < 1000; i += 1) {
    string[i] = (char *)malloc(1001);
  }
  casenum = 1;
  while (N--) {
    i = 0;
    do {
      scanf("%s", string[i]);
      scanf("%c", &c);
      i += 1;
    } while (c != '\n');
    printf("Case #%d: ", casenum);
    while (i--) {
      printf("%s", string[i]);
      if (i != 0) {
        putchar(' ');
      }
    }
    putchar('\n');
    casenum += 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x12(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    $0x1f40,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movw   $0x0,-0x14(%rbp)
movswl -0x14(%rbp),%eax
cmp    $0x3e8,%eax
jge    11ae <main+0x6e>
mov    $0x3e9,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movswq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movswl -0x14(%rbp),%eax
add    $0x1,%eax
mov    %ax,-0x14(%rbp)
jmp    1175 <main+0x35>
movw   $0x1,-0x16(%rbp)
mov    -0x12(%rbp),%ax
mov    %ax,%cx
add    $0xffff,%cx
mov    %cx,-0x12(%rbp)
cmp    $0x0,%ax
je     1294 <main+0x154>
movw   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movswq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    0xe12(%rip),%rdi
lea    -0x5(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movswl -0x14(%rbp),%eax
add    $0x1,%eax
mov    %ax,-0x14(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
jne    11d3 <main+0x93>
movswl -0x16(%rbp),%esi
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%ax
mov    %ax,%cx
add    $0xffff,%cx
mov    %cx,-0x14(%rbp)
cmp    $0x0,%ax
je     127a <main+0x13a>
mov    -0x10(%rbp),%rax
movswq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdad(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movswl -0x14(%rbp),%eax
cmp    $0x0,%eax
je     1275 <main+0x135>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    122a <main+0xea>
mov    $0xa,%edi
call   1030 <putchar@plt>
movswl -0x16(%rbp),%eax
add    $0x1,%eax
mov    %ax,-0x16(%rbp)
jmp    11b4 <main+0x74>
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
push   %rax
lea    0xeae(%rip),%rdi
xor    %ebp,%ebp
lea    0x2(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    $0x1f40,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
nopl   (%rax)
mov    $0x3e9,%edi
call   1050 <malloc@plt>
mov    %rax,(%rbx,%rbp,8)
add    $0x1,%rbp
cmp    $0x3e8,%rbp
jne    1170 <main+0x30>
subw   $0x1,0x2(%rsp)
jae    11a4 <main+0x64>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%eax
lea    0xe54(%rip),%rbp
lea    0xe50(%rip),%r15
lea    0x1(%rsp),%r12
jmp    11d9 <main+0x99>
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
add    $0x1,%eax
subw   $0x1,0x2(%rsp)
jb     1193 <main+0x53>
mov    %eax,0x4(%rsp)
mov    $0xffff,%ax
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,%r13d
movswq %r14w,%rax
mov    (%rbx,%rax,8),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
add    $0x1,%r14d
lea    0x1(%r13),%eax
cmpb   $0xa,0x1(%rsp)
jne    11f0 <main+0xb0>
mov    0x4(%rsp),%esi
movswl %si,%esi
lea    0xddb(%rip),%rdi
mov    %esi,0x4(%rsp)
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%eax
sub    $0x1,%ax
jb     11c0 <main+0x80>
movswq %ax,%rax
mov    (%rbx,%rax,8),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%r14w
je     11c0 <main+0x80>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x20,%edi
call   1030 <putchar@plt>
movswq %r13w,%r13
mov    (%rbx,%r13,8),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffff,%r13w
jb     1270 <main+0x130>
jmp    11c0 <main+0x80>

LLVM IR (-O0):
@.str = [4 x i8] c"%hd\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [11 x i8] c"Case #%d: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8**
%4 = alloca i16
%5 = alloca i16
%6 = alloca i16
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i16* %4)
%8 = call i64 @malloc(i32 8000)
%9 = inttoptr i64 %8 to i8**
store i8** %9, i8*** %3
store i16 0, i16* %5
br label %10
10: ; preds = %21, %0
%11 = load i16, i16* %5
%12 = sext i16 %11 to i32
%13 = icmp slt i32 %12, 1000
br i1 %13, label %14, label %26
14: ; preds = %10
%15 = call i64 @malloc(i32 1001)
%16 = inttoptr i64 %15 to i8*
%17 = load i8**, i8*** %3
%18 = load i16, i16* %5
%19 = sext i16 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
store i8* %16, i8** %20
br label %21
21: ; preds = %14
%22 = load i16, i16* %5
%23 = sext i16 %22 to i32
%24 = add nsw i32 %23, 1
%25 = trunc i32 %24 to i16
store i16 %25, i16* %5
br label %10
26: ; preds = %10
store i16 1, i16* %6
br label %27
27: ; preds = %69, %26
%28 = load i16, i16* %4
%29 = add i16 %28, -1
store i16 %29, i16* %4
%30 = icmp ne i16 %28, 0
br i1 %30, label %31, label %75
31: ; preds = %27
store i16 0, i16* %5
br label %32
32: ; preds = %44, %31
%33 = load i8**, i8*** %3
%34 = load i16, i16* %5
%35 = sext i16 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
%38 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %37)
%39 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%40 = load i16, i16* %5
%41 = sext i16 %40 to i32
%42 = add nsw i32 %41, 1
%43 = trunc i32 %42 to i16
store i16 %43, i16* %5
br label %44
44: ; preds = %32
%45 = load i8, i8* %2
%46 = sext i8 %45 to i32
%47 = icmp ne i32 %46, 10
br i1 %47, label %32, label %48
48: ; preds = %44
%49 = load i16, i16* %6
%50 = sext i16 %49 to i32
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %50)
br label %52
52: ; preds = %68, %48
%53 = load i16, i16* %5
%54 = add i16 %53, -1
store i16 %54, i16* %5
%55 = icmp ne i16 %53, 0
br i1 %55, label %56, label %69
56: ; preds = %52
%57 = load i8**, i8*** %3
%58 = load i16, i16* %5
%59 = sext i16 %58 to i64
%60 = getelementptr inbounds i8*, i8** %57, i64 %59
%61 = load i8*, i8** %60
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %61)
%63 = load i16, i16* %5
%64 = sext i16 %63 to i32
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %56
%67 = call i32 @putchar(i8 signext 32)
br label %68
68: ; preds = %66, %56
br label %52
69: ; preds = %52
%70 = call i32 @putchar(i8 signext 10)
%71 = load i16, i16* %6
%72 = sext i16 %71 to i32
%73 = add nsw i32 %72, 1
%74 = trunc i32 %73 to i16
store i16 %74, i16* %6
br label %27
75: ; preds = %27
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%hd\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [11 x i8] c"Case #%d: \00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i16
%3 = bitcast i16* %2 to i8*
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i16* %2)
%5 = call i64 @malloc(i32 8000)
%6 = inttoptr i64 %5 to i8**
br label %11
7: ; preds = %11
%8 = load i16, i16* %2
%9 = add i16 %8, -1
store i16 %9, i16* %2
%10 = icmp eq i16 %8, 0
br i1 %10, label %56, label %18
11: ; preds = %0, %11
%12 = phi i64 [ 0, %0 ], [ %16, %11 ]
%13 = call i64 @malloc(i32 1001)
%14 = inttoptr i64 %13 to i8*
%15 = getelementptr inbounds i8*, i8** %6, i64 %12
store i8* %14, i8** %15
%16 = add nuw nsw i64 %12, 1
%17 = icmp eq i64 %16, 1000
br i1 %17, label %7, label %11
18: ; preds = %7, %50
%19 = phi i32 [ %52, %50 ], [ 1, %7 ]
br label %20
20: ; preds = %18, %20
%21 = phi i16 [ %27, %20 ], [ 0, %18 ]
%22 = sext i16 %21 to i64
%23 = getelementptr inbounds i8*, i8** %6, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%27 = add i16 %21, 1
%28 = load i8, i8* %1
%29 = icmp eq i8 %28, 10
br i1 %29, label %30, label %20
30: ; preds = %20
%31 = shl i32 %19, 16
%32 = ashr exact i32 %31, 16
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%34 = icmp eq i16 %27, 0
br i1 %34, label %50, label %35
35: ; preds = %30
%36 = sext i16 %21 to i64
%37 = getelementptr inbounds i8*, i8** %6, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %38)
%40 = icmp eq i16 %21, 0
br i1 %40, label %50, label %41
41: ; preds = %35, %41
%42 = phi i16 [ %44, %41 ], [ %21, %35 ]
%43 = call i32 @putchar(i8 signext 32)
%44 = add i16 %42, -1
%45 = sext i16 %44 to i64
%46 = getelementptr inbounds i8*, i8** %6, i64 %45
%47 = load i8*, i8** %46
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %47)
%49 = icmp eq i16 %44, 0
br i1 %49, label %50, label %41
50: ; preds = %41, %35, %30
%51 = call i32 @putchar(i8 signext 10)
%52 = add nsw i32 %32, 1
%53 = load i16, i16* %2
%54 = add i16 %53, -1
store i16 %54, i16* %2
%55 = icmp eq i16 %53, 0
br i1 %55, label %56, label %18
56: ; preds = %50, %7
ret i32 0
}