#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*/ scanf(char *, ...);
int valid(char *, char *, int);
int main() {
  int n, m;
  char *s1, *s2;
  scanf("%d", &n);
  s1 = (char *)malloc((n + 1) * sizeof(char));
  scanf("%s", s1);
  scanf("%d", &m);
  s2 = (char *)malloc((m + 1) * sizeof(char));
  scanf("%s", s2);
  if ((n == m) && (valid(s1, s2, n) == 1)) {
    printf("Valid");
  } else {
    printf("Not Valid");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    0xe6f(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11fb <main+0xbb>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1040 <valid@plt>
cmp    $0x1,%eax
jne    11fb <main+0xbb>
lea    0xe19(%rip),%rdi
call   1030 <printf@plt>
jmp    1207 <main+0xc7>
lea    0xe04(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb0(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0xc(%rsp),%edi
add    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
lea    0xe8e(%rip),%r15
mov    %r15,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x8(%rsp),%edi
add    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0xc(%rsp),%edx
cmp    0x8(%rsp),%edx
jne    11d0 <main+0x90>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <valid@plt>
cmp    $0x1,%eax
jne    11d0 <main+0x90>
lea    0xe3c(%rip),%rdi
jmp    11d7 <main+0x97>
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [6 x i8] c"Valid\00"
@.str.3 = [10 x i8] c"Not Valid\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = add nsw i32 %6, 1
%8 = call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to i8*
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%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 = add nsw i32 %12, 1
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i8*
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %23
20: ; preds = %0
%21 = call i32 @valid(i8* %9, i8* %15, i32 %17)
%22 = icmp eq i32 %21, 1
br i1 %22, label %24, label %23
23: ; preds = %20, %0
br label %24
24: ; preds = %20, %23
%25 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %23 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %20 ]
%26 = call i32 @printf(i8* dereferenceable(1) %25)
ret i32 0
}