#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*/ make_wave(int, int, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  char buf[4096];
  int num_cases;
  int amp, freq;
  int i, isFirst;
  scanf("%d\n", &num_cases);
  isFirst = 1;
  while (num_cases-- > 0) {
    if (isFirst) {
      isFirst = 0;
    } else {
      printf("\n");
    }
    scanf("%d\n", &amp);
    scanf("%d\n", &freq);
    make_wave(amp, freq, buf);
    for (i = 0; i < freq - 1; i++) {
      printf("%s\n", buf);
    }
    printf("%s", buf);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x1014(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x1,-0x1024(%rbp)
mov    -0x1014(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1014(%rbp)
cmp    $0x0,%eax
jle    1245 <main+0x115>
cmpl   $0x0,-0x1024(%rbp)
je     1195 <main+0x65>
movl   $0x0,-0x1024(%rbp)
jmp    11a3 <main+0x73>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe56(%rip),%rdi
lea    -0x1018(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe43(%rip),%rdi
lea    -0x101c(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x1018(%rbp),%edi
mov    -0x101c(%rbp),%esi
lea    -0x1010(%rbp),%rdx
call   1030 <make_wave@plt>
movl   $0x0,-0x1020(%rbp)
mov    -0x1020(%rbp),%eax
mov    -0x101c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    122b <main+0xfb>
lea    -0x1010(%rbp),%rsi
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1020(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1020(%rbp)
jmp    11eb <main+0xbb>
lea    -0x1010(%rbp),%rsi
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    115f <main+0x2f>
xor    %eax,%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
lea    0xe98(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x4(%rsp)
test   %eax,%eax
jle    121e <main+0xce>
lea    0xe74(%rip),%r12
lea    0xc(%rsp),%r14
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%rbx
lea    0xe62(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %r14,%rsi
call   1070 <scanf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
mov    %rbx,%rdx
call   1030 <make_wave@plt>
cmpl   $0x2,0x8(%rsp)
jl     11f6 <main+0xa6>
xor    %ebp,%ebp
nop
mov    %rbx,%rdi
call   1050 <puts@plt>
add    $0x1,%ebp
mov    0x8(%rsp),%eax
add    $0xffffffff,%eax
cmp    %eax,%ebp
jl     11e0 <main+0x90>
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x4(%rsp)
test   %eax,%eax
jle    121e <main+0xce>
mov    $0xa,%edi
call   1040 <putchar@plt>
jmp    11b0 <main+0x60>
xor    %eax,%eax
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4096 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
store i32 1, i32* %7
br label %9
9: ; preds = %37, %0
%10 = load i32, i32* %3
%11 = add nsw i32 %10, -1
store i32 %11, i32* %3
%12 = icmp sgt i32 %10, 0
br i1 %12, label %13, label %40
13: ; preds = %9
%14 = load i32, i32* %7
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %13
store i32 0, i32* %7
br label %19
17: ; preds = %13
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %16
%20 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %4)
%21 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %5)
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%25 = call i32 @make_wave(i32 %22, i32 %23, i8* %24)
store i32 0, i32* %6
br label %26
26: ; preds = %34, %19
%27 = load i32, i32* %6
%28 = load i32, i32* %5
%29 = sub nsw i32 %28, 1
%30 = icmp slt i32 %27, %29
br i1 %30, label %31, label %37
31: ; preds = %26
%32 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %31
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %26
37: ; preds = %26
%38 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %38)
br label %9
40: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [4096 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = add nsw i32 %10, -1
store i32 %11, i32* %2
%12 = icmp sgt i32 %10, 0
br i1 %12, label %15, label %35
13: ; preds = %30
%14 = call i32 @putchar(i32 10)
br label %15
15: ; preds = %0, %13
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%17 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %4)
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = call i32 @make_wave(i32 %18, i32 %19, i8* %5)
%21 = load i32, i32* %4
%22 = icmp sgt i32 %21, 1
br i1 %22, label %23, label %30
23: ; preds = %15, %23
%24 = phi i32 [ %26, %23 ], [ 0, %15 ]
%25 = call i32 @puts(i8* %5)
%26 = add nuw nsw i32 %24, 1
%27 = load i32, i32* %4
%28 = add nsw i32 %27, -1
%29 = icmp slt i32 %26, %28
br i1 %29, label %23, label %30
30: ; preds = %23, %15
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%32 = load i32, i32* %2
%33 = add nsw i32 %32, -1
store i32 %33, i32* %2
%34 = icmp sgt i32 %32, 0
br i1 %34, label %13, label %35
35: ; preds = %30, %0
ret i32 0
}