#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));
  if (a == NULL) {
  }
  scanf("%s", a);
  scanf("%d", &m);
  if (n != m) {
    printf("Not Valid");
    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)
cmpq   $0x0,-0x18(%rbp)
jne    1198 <main+0x48>
jmp    1198 <main+0x48>
mov    -0x18(%rbp),%rsi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xe4f(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     11e0 <main+0x90>
lea    0xe37(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1259 <main+0x109>
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    0xe01(%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     1234 <main+0xe4>
lea    0xde0(%rip),%rdi
call   1040 <printf@plt>
jmp    1240 <main+0xf0>
lea    0xdcb(%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    11f5 <main+0xa5>
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>
jmp    1201 <main+0xb1>
lea    0xe0a(%rip),%rdi
call   1040 <printf@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 = [10 x i8] c"Not Valid\00"
@.str.3 = [6 x i8] c"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 = icmp eq i8* %14, null
br i1 %15, label %16, label %17
16: ; preds = %0
br label %17
17: ; preds = %16, %0
%18 = load i8*, i8** %4
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = icmp ne i32 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %17
%25 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %50
26: ; preds = %17
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = mul i64 %29, 1
%31 = trunc i64 %30 to i32
%32 = call i64 @malloc(i32 %31)
%33 = inttoptr i64 %32 to i8*
store i8* %33, i8** %5
%34 = load i8*, i8** %5
%35 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %34)
%36 = load i8*, i8** %4
%37 = load i8*, i8** %5
%38 = load i32, i32* %2
%39 = call i64 @valid(i8* %36, i8* %37, i32 %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %26
%42 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %45
43: ; preds = %26
%44 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %45
45: ; preds = %43, %41
%46 = load i8*, i8** %4
%47 = call i32 @free(i8* %46)
%48 = load i8*, i8** %5
%49 = call i32 @free(i8* %48)
store i32 0, i32* %1
br label %50
50: ; preds = %45, %24
%51 = load i32, i32* %1
ret i32 %51
}

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