#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 long_com_pat(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int t;
  char a[10002], b[10002];
  printf("How many test cases? - ");
  scanf("%d", &t);
  int m = t;
  while (t--) {
    printf("Test case %d\n", m - t);
    printf("String A:\n");
    scanf("%s", a);
    printf("String 2: \n");
    scanf("%s", b);
    printf("Total match :");
    printf("%d\n", long_com_pat(a, b));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec1(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4e44(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     1212 <main+0xe2>
mov    -0x4e44(%rbp),%esi
sub    -0x8(%rbp),%esi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x2720(%rbp),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x4e40(%rbp),%rsi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x2720(%rbp),%rdi
lea    -0x4e40(%rbp),%rsi
call   1030 <long_com_pat@plt>
mov    %eax,%esi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    116b <main+0x3b>
xor    %eax,%eax
add    $0x4e50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4e48,%rsp
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0xc(%rsp),%r13d
mov    %r13d,%eax
sub    $0x1,%eax
mov    %eax,0xc(%rsp)
jb     1223 <main+0xe3>
lea    0xe9b(%rip),%r12
lea    0x2730(%rsp),%rbx
lea    0x10(%rsp),%rbp
lea    0xe8a(%rip),%r14
lea    0xe7c(%rip),%r15
nopl   0x0(%rax)
mov    %r13d,%esi
sub    %eax,%esi
lea    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe70(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe61(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <long_com_pat@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%eax
sub    $0x1,%eax
mov    %eax,0xc(%rsp)
jae    11b0 <main+0x70>
xor    %eax,%eax
add    $0x4e48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"How many test cases? - \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [14 x i8] c"Test case %d\0A\00"
@.str.3 = [11 x i8] c"String A:\0A\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [12 x i8] c"String 2: \0A\00"
@.str.6 = [14 x i8] c"Total match :\00"
@.str.7 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10002 x i8]
%4 = alloca [10002 x i8]
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
store i32 %8, i32* %5
br label %9
9: ; preds = %13, %0
%10 = load i32, i32* %2
%11 = add nsw i32 %10, -1
store i32 %11, i32* %2
%12 = icmp ne i32 %10, 0
br i1 %12, label %13, label %29
13: ; preds = %9
%14 = load i32, i32* %5
%15 = load i32, i32* %2
%16 = sub nsw i32 %14, %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%19 = getelementptr inbounds [10002 x i8], [10002 x i8]* %3, i64 0, i64 0
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%22 = getelementptr inbounds [10002 x i8], [10002 x i8]* %4, i64 0, i64 0
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%25 = getelementptr inbounds [10002 x i8], [10002 x i8]* %3, i64 0, i64 0
%26 = getelementptr inbounds [10002 x i8], [10002 x i8]* %4, i64 0, i64 0
%27 = call i32 @long_com_pat(i8* %25, i8* %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %27)
br label %9
29: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"How many test cases? - \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [14 x i8] c"Test case %d\0A\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.6 = [14 x i8] c"Total match :\00"
@.str.7 = [4 x i8] c"%d\0A\00"
@str = [10 x i8] c"String A:\00"
@str.8 = [11 x i8] c"String 2: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10002 x i8]
%3 = alloca [10002 x i8]
%4 = bitcast i32* %1 to i8*
%5 = getelementptr inbounds [10002 x i8], [10002 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [10002 x i8], [10002 x i8]* %3, i64 0, i64 0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = add nsw i32 %9, -1
store i32 %10, i32* %1
%11 = icmp eq i32 %9, 0
br i1 %11, label %26, label %12
12: ; preds = %0, %12
%13 = phi i32 [ %24, %12 ], [ %10, %0 ]
%14 = sub nsw i32 %9, %13
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.8, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%21 = call i32 @long_com_pat(i8* %5, i8* %6)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %1
%24 = add nsw i32 %23, -1
store i32 %24, i32* %1
%25 = icmp eq i32 %23, 0
br i1 %25, label %26, label %12
26: ; preds = %12, %0
ret i32 0
}