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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
movslq -0x1c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xe63(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
movslq -0x20(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1050 <valid@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    11fd <main+0xad>
lea    0xe1c(%rip),%rdi
call   1040 <printf@plt>
jmp    1209 <main+0xb9>
lea    0xe07(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xea0(%rip),%r14
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0xc(%rsp),%edi
call   1060 <malloc@plt>
mov    %rax,%r15
lea    0xe82(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x8(%rsp),%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe5a(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x8(%rsp),%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <valid@plt>
cmp    0x8(%rsp),%eax
lea    0xe3d(%rip),%rax
lea    0xe32(%rip),%rdi
cmove  %rax,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [6 x i8] c"Valid\00"
@.str.4 = [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 ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i8*
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i8*
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = load i32, i32* %2
%16 = call i32 @valid(i8* %8, i8* %13, i32 %15)
%17 = load i32, i32* %2
%18 = icmp eq i32 %16, %17
%19 = select i1 %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0)
%20 = call i32 @printf(i8* dereferenceable(1) %19)
%21 = call i32 @free(i8* %8)
%22 = call i32 @free(i8* %13)
ret i32 0
}