#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);
  if (m != n)
    printf("Not Valid");
  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    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
je     11e5 <main+0x95>
lea    0xe2b(%rip),%rdi
call   1040 <printf@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    1215 <main+0xc5>
lea    0xe04(%rip),%rdi
call   1040 <printf@plt>
jmp    1221 <main+0xd1>
lea    0xdef(%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   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x4(%rsp),%edi
call   1060 <malloc@plt>
mov    %rax,%r14
lea    0xe87(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    (%rsp),%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe62(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x4(%rsp),%edx
cmp    (%rsp),%edx
je     11c8 <main+0x78>
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
mov    (%rsp),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <valid@plt>
cmp    (%rsp),%eax
lea    0xe32(%rip),%rax
lea    0xe27(%rip),%rdi
cmove  %rax,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
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 = [10 x i8] c"Not Valid\00"
@.str.4 = [6 x i8] c"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 i32, i32* %4
%26 = load i32, i32* %5
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %0
%29 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %30
30: ; preds = %28, %0
%31 = load i8*, i8** %2
%32 = load i8*, i8** %3
%33 = load i32, i32* %5
%34 = call i32 @valid(i8* %31, i8* %32, i32 %33)
store i32 %34, i32* %6
%35 = load i32, i32* %6
%36 = load i32, i32* %5
%37 = icmp eq i32 %35, %36
br i1 %37, label %38, label %40
38: ; preds = %30
%39 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %42
40: ; preds = %30
%41 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %42
42: ; preds = %40, %38
%43 = load i8*, i8** %2
%44 = call i32 @free(i8* %43)
%45 = load i8*, i8** %3
%46 = call i32 @free(i8* %45)
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 = [10 x i8] c"Not Valid\00"
@.str.4 = [6 x i8] c"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* %1
%16 = load i32, i32* %2
%17 = icmp eq i32 %15, %16
br i1 %17, label %21, label %18
18: ; preds = %0
%19 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%20 = load i32, i32* %2
br label %21
21: ; preds = %18, %0
%22 = phi i32 [ %20, %18 ], [ %15, %0 ]
%23 = call i32 @valid(i8* %8, i8* %13, i32 %22)
%24 = load i32, i32* %2
%25 = icmp eq i32 %23, %24
%26 = select i1 %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0)
%27 = call i32 @printf(i8* dereferenceable(1) %26)
%28 = call i32 @free(i8* %8)
%29 = call i32 @free(i8* %13)
ret i32 0
}