#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int n1, i, count = 0;
  scanf("%d", &n1);
  char str1[n1];
  scanf("%s", str1);
  int n2;
  scanf("%d", &n2);
  char str2[n2];
  scanf("%s", str2);
  for (i = 0; i < n2; i++) {
    if (str1[0] != str2[0])
      printf("");
    if (str2[i] == str1[i % n1])
      count++;
  }
  if (count == n2)
    printf("%s", str1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xec3(%rip),%rdi
mov    %rdi,-0x48(%rbp)
xor    %eax,%eax
mov    %al,-0x39(%rbp)
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x39(%rbp),%al
mov    -0x8(%rbp),%ecx
mov    %rsp,%rdx
mov    %rdx,-0x18(%rbp)
mov    %rcx,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rsi
sub    %rdx,%rsi
mov    %rsi,-0x50(%rbp)
mov    %rsi,%rsp
mov    %rcx,-0x20(%rbp)
lea    0xe84(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x48(%rbp),%rdi
mov    -0x39(%rbp),%al
lea    -0x24(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x24(%rbp),%eax
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x38(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x30(%rbp)
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1240 <main+0x120>
mov    -0x38(%rbp),%rcx
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11f8 <main+0xd8>
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x50(%rbp),%rcx
mov    -0x38(%rbp),%rax
movslq -0xc(%rbp),%rdx
movsbl (%rax,%rdx,1),%eax
mov    %eax,-0x54(%rbp)
mov    -0xc(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    -0x54(%rbp),%eax
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    122d <main+0x10d>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1232 <main+0x112>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c8 <main+0xa8>
mov    -0x10(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    125e <main+0x13e>
mov    -0x50(%rbp),%rsi
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xecb(%rip),%r13
xor    %ebx,%ebx
lea    -0x30(%rbp),%rsi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %rsp,%r12
mov    -0x30(%rbp),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
lea    0xea0(%rip),%r15
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    -0x2c(%rbp),%rsi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    -0x2c(%rbp),%eax
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    %r15,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    -0x2c(%rbp),%r8d
test   %r8d,%r8d
jle    1222 <main+0x102>
mov    -0x30(%rbp),%edi
cmp    $0x1,%r8d
jne    11b7 <main+0x97>
xor    %ecx,%ecx
xor    %ebx,%ebx
jmp    1207 <main+0xe7>
mov    %r8d,%r10d
and    $0xfffffffe,%r10d
xor    %ecx,%ecx
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ecx,%eax
cltd
idiv   %edi
movzbl 0x0(%r13,%rcx,1),%eax
movzbl 0x1(%r13,%rcx,1),%r9d
xor    %esi,%esi
cmp    (%r14,%rdx,1),%al
sete   %sil
add    %ebx,%esi
lea    0x1(%rcx),%eax
cltd
idiv   %edi
xor    %ebx,%ebx
cmp    (%r14,%rdx,1),%r9b
sete   %bl
add    %esi,%ebx
add    $0x2,%rcx
cmp    %r10,%rcx
jne    11d0 <main+0xb0>
test   $0x1,%r8b
je     1222 <main+0x102>
mov    0x0(%r13,%rcx,1),%sil
mov    %ecx,%eax
cltd
idiv   %edi
xor    %eax,%eax
cmp    (%r14,%rdx,1),%sil
sete   %al
add    %eax,%ebx
cmp    %r8d,%ebx
jne    1238 <main+0x118>
lea    0xdd5(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%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 = [3 x i8] c"%s\00"
@.str.2 = [1 x i8] zeroinitializer
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %4
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %5
%13 = alloca i8, i64 %11
store i64 %11, i64* %6
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%16 = load i32, i32* %7
%17 = zext i32 %16 to i64
%18 = alloca i8, i64 %17
store i64 %17, i64* %8
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %18)
store i32 0, i32* %3
br label %20
20: ; preds = %52, %0
%21 = load i32, i32* %3
%22 = load i32, i32* %7
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %55
24: ; preds = %20
%25 = getelementptr inbounds i8, i8* %13, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = getelementptr inbounds i8, i8* %18, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %27, %30
br i1 %31, label %32, label %34
32: ; preds = %24
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %34
34: ; preds = %32, %24
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %18, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = load i32, i32* %3
%41 = load i32, i32* %2
%42 = srem i32 %40, %41
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %13, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %39, %46
br i1 %47, label %48, label %51
48: ; preds = %34
%49 = load i32, i32* %4
%50 = add nsw i32 %49, 1
store i32 %50, i32* %4
br label %51
51: ; preds = %48, %34
br label %52
52: ; preds = %51
%53 = load i32, i32* %3
%54 = add nsw i32 %53, 1
store i32 %54, i32* %3
br label %20
55: ; preds = %20
%56 = load i32, i32* %4
%57 = load i32, i32* %7
%58 = icmp eq i32 %56, %57
br i1 %58, label %59, label %61
59: ; preds = %55
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %61
61: ; preds = %59, %55
store i32 0, i32* %1
%62 = load i8*, i8** %5
%63 = load i32, i32* %1
ret i32 %63
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
%8 = alloca i8, i64 %6
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = bitcast i32* %2 to i8*
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
%13 = zext i32 %12 to i64
%14 = alloca i8, i64 %13
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i32, i32* %2
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %69
18: ; preds = %0
%19 = load i32, i32* %1
%20 = zext i32 %16 to i64
%21 = and i64 %20, 1
%22 = icmp eq i32 %16, 1
br i1 %22, label %53, label %23
23: ; preds = %18
%24 = and i64 %20, 4294967294
br label %25
25: ; preds = %25, %23
%26 = phi i64 [ 0, %23 ], [ %50, %25 ]
%27 = phi i32 [ 0, %23 ], [ %49, %25 ]
%28 = phi i64 [ 0, %23 ], [ %51, %25 ]
%29 = getelementptr inbounds i8, i8* %14, i64 %26
%30 = load i8, i8* %29
%31 = trunc i64 %26 to i32
%32 = srem i32 %31, %19
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %8, i64 %33
%35 = load i8, i8* %34
%36 = icmp eq i8 %30, %35
%37 = zext i1 %36 to i32
%38 = add nuw nsw i32 %27, %37
%39 = or i64 %26, 1
%40 = getelementptr inbounds i8, i8* %14, i64 %39
%41 = load i8, i8* %40
%42 = trunc i64 %39 to i32
%43 = srem i32 %42, %19
%44 = zext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %8, i64 %44
%46 = load i8, i8* %45
%47 = icmp eq i8 %41, %46
%48 = zext i1 %47 to i32
%49 = add nuw nsw i32 %38, %48
%50 = add nuw nsw i64 %26, 2
%51 = add i64 %28, 2
%52 = icmp eq i64 %51, %24
br i1 %52, label %53, label %25
53: ; preds = %25, %18
%54 = phi i32 [ undef, %18 ], [ %49, %25 ]
%55 = phi i64 [ 0, %18 ], [ %50, %25 ]
%56 = phi i32 [ 0, %18 ], [ %49, %25 ]
%57 = icmp eq i64 %21, 0
br i1 %57, label %69, label %58
58: ; preds = %53
%59 = getelementptr inbounds i8, i8* %14, i64 %55
%60 = load i8, i8* %59
%61 = trunc i64 %55 to i32
%62 = srem i32 %61, %19
%63 = zext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %8, i64 %63
%65 = load i8, i8* %64
%66 = icmp eq i8 %60, %65
%67 = zext i1 %66 to i32
%68 = add nuw nsw i32 %56, %67
br label %69
69: ; preds = %58, %53, %0
%70 = phi i32 [ 0, %0 ], [ %54, %53 ], [ %68, %58 ]
%71 = icmp eq i32 %70, %16
br i1 %71, label %72, label %74
72: ; preds = %69
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
br label %74
74: ; preds = %72, %69
ret i32 0
}