#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 */
char getchar();
int /*<<< orphan*/ mycpy(char *, char *, unsigned int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, unsigned int *);
void main(void) {
  unsigned N;
  scanf("%u", &N);
  getchar();
  unsigned n;
  char src[999] = {'\0'};
  char tgt[999] = {'\0'};
  for (; N != 0; --N) {
    for (n = 0; src[n] = getchar(), src[n] != '\n'; ++n)
      ;
    scanf("%u", &n);
    getchar();
    mycpy(tgt, src, n);
    printf("%s\n", tgt);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7e0,%rsp
lea    0xe9e(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1070 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
lea    -0x3f0(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e7,%edx
call   1040 <memset@plt>
lea    -0x7e0(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e7,%edx
call   1040 <memset@plt>
cmpl   $0x0,-0x4(%rbp)
je     1231 <main+0xe1>
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,%cl
mov    -0x8(%rbp),%eax
mov    %cl,-0x3f0(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
movsbl -0x3f0(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
je     11e3 <main+0x93>
jmp    11d5 <main+0x85>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a9 <main+0x59>
lea    0xe16(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
lea    -0x7e0(%rbp),%rdi
lea    -0x3f0(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1060 <mycpy@plt>
lea    -0x7e0(%rbp),%rsi
lea    0xde5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1198 <main+0x48>
add    $0x7e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7e8,%rsp
lea    0xe98(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
lea    0x10(%rsp),%rdi
mov    $0x3e7,%edx
xor    %esi,%esi
call   1040 <memset@plt>
lea    0x400(%rsp),%rdi
mov    $0x3e7,%edx
xor    %esi,%esi
call   1040 <memset@plt>
cmpl   $0x0,0xc(%rsp)
je     121f <main+0xcf>
lea    0xe54(%rip),%r14
lea    0x8(%rsp),%r15
lea    0x400(%rsp),%rbx
lea    0x10(%rsp),%r12
lea    0xe3e(%rip),%r13
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %ebp,0x8(%rsp)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x8(%rsp),%ecx
mov    %al,0x10(%rsp,%rcx,1)
lea    0x1(%rcx),%ebp
cmp    $0xa,%al
jne    11d0 <main+0x80>
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <mycpy@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
addl   $0xffffffff,0xc(%rsp)
jne    11d0 <main+0x80>
add    $0x7e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%u\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [999 x i8]
%4 = alloca [999 x i8]
%5 = bitcast i32* %1 to i8*
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%7 = call signext i8 (...) @getchar()
%8 = bitcast i32* %2 to i8*
%9 = getelementptr inbounds [999 x i8], [999 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [999 x i8], [999 x i8]* %4, i64 0, i64 0
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 0
br i1 %12, label %32, label %13
13: ; preds = %0, %21
%14 = phi i32 [ %22, %21 ], [ 0, %0 ]
store i32 %14, i32* %2
%15 = call signext i8 (...) @getchar()
%16 = load i32, i32* %2
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds [999 x i8], [999 x i8]* %3, i64 0, i64 %17
store i8 %15, i8* %18
%19 = icmp eq i8 %15, 10
%20 = add i32 %16, 1
br i1 %19, label %23, label %21
21: ; preds = %13, %23
%22 = phi i32 [ %20, %13 ], [ 0, %23 ]
br label %13
23: ; preds = %13
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%25 = call signext i8 (...) @getchar()
%26 = load i32, i32* %2
%27 = call i32 @mycpy(i8* %10, i8* %9, i32 %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%29 = load i32, i32* %1
%30 = add i32 %29, -1
store i32 %30, i32* %1
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %21
32: ; preds = %23, %0
ret void
}