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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xe5f(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     11c4 <main+0x74>
movl   $0x0,-0x4(%rbp)
jmp    123d <main+0xed>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1050 <valid@plt>
cmp    $0x0,%rax
je     1218 <main+0xc8>
lea    0xdfc(%rip),%rdi
call   1040 <printf@plt>
jmp    1224 <main+0xd4>
lea    0xde7(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%r14
mov    %rsp,%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    (%rsp),%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe86(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    (%rsp),%edi
cmp    0x4(%rsp),%edi
jne    11f3 <main+0xa3>
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
lea    0xe52(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    (%rsp),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <valid@plt>
test   %rax,%rax
lea    0xe33(%rip),%rax
lea    0xe30(%rip),%rdi
cmove  %rax,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
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* %2
%18 = load i32, i32* %3
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %0
store i32 0, i32* %1
br label %45
21: ; preds = %0
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = mul i64 %24, 1
%26 = trunc i64 %25 to i32
%27 = call i64 @malloc(i32 %26)
%28 = inttoptr i64 %27 to i8*
store i8* %28, i8** %5
%29 = load i8*, i8** %5
%30 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = load i8*, i8** %4
%32 = load i8*, i8** %5
%33 = load i32, i32* %2
%34 = call i64 @valid(i8* %31, i8* %32, i32 %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %21
%37 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %40
38: ; preds = %21
%39 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %40
40: ; preds = %38, %36
%41 = load i8*, i8** %4
%42 = call i32 @free(i8* %41)
%43 = load i8*, i8** %5
%44 = call i32 @free(i8* %43)
store i32 0, i32* %1
br label %45
45: ; preds = %40, %20
%46 = load i32, i32* %1
ret i32 %46
}

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* %1
%13 = load i32, i32* %2
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %27
15: ; preds = %0
%16 = add nsw i32 %12, 1
%17 = call i64 @malloc(i32 %16)
%18 = inttoptr i64 %17 to i8*
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = load i32, i32* %1
%21 = call i64 @valid(i8* %9, i8* %18, i32 %20)
%22 = icmp eq i64 %21, 0
%23 = select i1 %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%24 = call i32 @printf(i8* dereferenceable(1) %23)
%25 = call i32 @free(i8* %9)
%26 = call i32 @free(i8* %18)
br label %27
27: ; preds = %0, %15
ret i32 0
}