#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*/ line(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *, ...);
void main() {
  int a, f, i, j, k, l = 1, t;
  scanf("%d", &t);
  for (i = 1; i <= t; i++) {
    scanf("%d %d", &a, &f);
    for (j = 1; j <= f; j++) {
      if (!l)
        printf("\n");
      l = 0;
      for (k = 1; k < a; k++)
        line(k);
      for (k = a; k > 0; k--)
        line(k);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x1,-0x18(%rbp)
lea    0xebd(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     121f <main+0xef>
lea    0xe95(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     120c <main+0xdc>
cmpl   $0x0,-0x18(%rbp)
jne    11a3 <main+0x73>
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11d3 <main+0xa3>
mov    -0x14(%rbp),%edi
call   1050 <line@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b1 <main+0x81>
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11f9 <main+0xc9>
mov    -0x14(%rbp),%edi
call   1050 <line@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11d9 <main+0xa9>
jmp    11fe <main+0xce>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1181 <main+0x51>
jmp    1211 <main+0xe1>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1158 <main+0x28>
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    0xebe(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    1223 <main+0xf3>
mov    $0x1,%ebx
lea    0x14(%rsp),%r15
lea    0x10(%rsp),%r12
mov    $0x1,%r13d
jmp    1192 <main+0x62>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x1(%r13),%eax
cmp    0xc(%rsp),%r13d
mov    %eax,%r13d
jge    1223 <main+0xf3>
lea    0xe67(%rip),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0x10(%rsp)
jle    1180 <main+0x50>
mov    $0x1,%r14d
jmp    11d0 <main+0xa0>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x1(%r14),%eax
xor    %ebx,%ebx
cmp    0x10(%rsp),%r14d
mov    %eax,%r14d
jge    1180 <main+0x50>
test   %ebx,%ebx
jne    11de <main+0xae>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x14(%rsp),%ebx
cmp    $0x2,%ebx
jl     1202 <main+0xd2>
mov    $0x1,%ebp
nopl   0x0(%rax)
mov    %ebp,%edi
call   1050 <line@plt>
add    $0x1,%ebp
mov    0x14(%rsp),%ebx
cmp    %ebx,%ebp
jl     11f0 <main+0xc0>
test   %ebx,%ebx
jle    11c0 <main+0x90>
cs nopw 0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1050 <line@plt>
lea    -0x1(%rbx),%eax
cmp    $0x1,%ebx
mov    %eax,%ebx
ja     1210 <main+0xe0>
jmp    11c0 <main+0x90>
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 = [6 x i8] c"%d %d\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 1, i32* %6
%8 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
store i32 1, i32* %3
br label %9
9: ; preds = %51, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %7
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %54
13: ; preds = %9
%14 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
store i32 1, i32* %4
br label %15
15: ; preds = %47, %13
%16 = load i32, i32* %4
%17 = load i32, i32* %2
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %50
19: ; preds = %15
%20 = load i32, i32* %6
%21 = icmp ne i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %24
24: ; preds = %22, %19
store i32 0, i32* %6
store i32 1, i32* %5
br label %25
25: ; preds = %32, %24
%26 = load i32, i32* %5
%27 = load i32, i32* %1
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %35
29: ; preds = %25
%30 = load i32, i32* %5
%31 = call i32 @line(i32 %30)
br label %32
32: ; preds = %29
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %25
35: ; preds = %25
%36 = load i32, i32* %1
store i32 %36, i32* %5
br label %37
37: ; preds = %43, %35
%38 = load i32, i32* %5
%39 = icmp sgt i32 %38, 0
br i1 %39, label %40, label %46
40: ; preds = %37
%41 = load i32, i32* %5
%42 = call i32 @line(i32 %41)
br label %43
43: ; preds = %40
%44 = load i32, i32* %5
%45 = add nsw i32 %44, -1
store i32 %45, i32* %5
br label %37
46: ; preds = %37
br label %47
47: ; preds = %46
%48 = load i32, i32* %4
%49 = add nsw i32 %48, 1
store i32 %49, i32* %4
br label %15
50: ; preds = %15
br label %51
51: ; preds = %50
%52 = load i32, i32* %3
%53 = add nsw i32 %52, 1
store i32 %53, i32* %3
br label %9
54: ; preds = %9
ret void
}

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