#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 size1, size2, res;
  char *s1, *s2;
  char ch;
  scanf("%d", &size1);
  s1 = (char *)malloc((size1 + 1) * sizeof(char));
  scanf("%s", s1);
  scanf("%d", &size2);
  scanf("%c", &ch);
  s2 = (char *)malloc((size2 + 1) * sizeof(char));
  scanf("%s", s2);
  if (size1 != size2) {
    res = 0;
  } else {
    res = valid(*s1, *s2, size1);
  }
  if (res == 1) {
    printf("Valid");
  }
  if (res == 0) {
    printf("Not Valid");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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>
lea    0xe63(%rip),%rdi
lea    -0x21(%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    0xe33(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     11ef <main+0xaf>
movl   $0x0,-0x10(%rbp)
jmp    120c <main+0xcc>
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    -0x8(%rbp),%edx
movsbl %cl,%edi
movsbl %al,%esi
call   1040 <valid@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    1222 <main+0xe2>
lea    0xdf0(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
jne    1238 <main+0xf8>
lea    0xdd6(%rip),%rdi
call   1030 <printf@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    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>
lea    0xe6e(%rip),%rdi
lea    0x7(%rsp),%rsi
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    11df <main+0x9f>
movsbl (%r14),%edi
movsbl (%rbx),%esi
call   1040 <valid@plt>
cmp    $0x1,%eax
je     11e8 <main+0xa8>
test   %eax,%eax
jne    11f4 <main+0xb4>
lea    0xe23(%rip),%rdi
jmp    11ef <main+0xaf>
lea    0xe1e(%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 = [3 x i8] c"%c\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 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = add nsw i32 %9, 1
%11 = sext i32 %10 to i64
%12 = mul i64 %11, 1
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %5
%16 = load i8*, i8** %5
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = mul i64 %22, 1
%24 = trunc i64 %23 to i32
%25 = call i64 @malloc(i32 %24)
%26 = inttoptr i64 %25 to i8*
store i8* %26, i8** %6
%27 = load i8*, i8** %6
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = load i32, i32* %2
%30 = load i32, i32* %3
%31 = icmp ne i32 %29, %30
br i1 %31, label %32, label %33
32: ; preds = %0
store i32 0, i32* %4
br label %40
33: ; preds = %0
%34 = load i8*, i8** %5
%35 = load i8, i8* %34
%36 = load i8*, i8** %6
%37 = load i8, i8* %36
%38 = load i32, i32* %2
%39 = call i32 @valid(i8 signext %35, i8 signext %37, i32 %38)
store i32 %39, i32* %4
br label %40
40: ; preds = %33, %32
%41 = load i32, i32* %4
%42 = icmp eq i32 %41, 1
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %45
45: ; preds = %43, %40
%46 = load i32, i32* %4
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %45
%49 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %50
50: ; preds = %48, %45
ret i32 0
}

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