#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__ isValidLuhnAlgo(char **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  int T, i;
  char creditStr[4][4 + 1];
  scanf("%d", &T);
  while (T) {
    for (i = 0; i < 4; i++)
      scanf("%s", creditStr[i]);
    if (isValidLuhnAlgo(creditStr))
      printf("Valid\n");
    else
      printf("Invalid\n");
    T--;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
je     11d5 <main+0xa5>
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    1197 <main+0x67>
movslq -0xc(%rbp),%rax
lea    -0x20(%rbp),%rsi
imul   $0x5,%rax,%rax
add    %rax,%rsi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1162 <main+0x32>
lea    -0x20(%rbp),%rdi
call   1040 <isValidLuhnAlgo@plt>
cmp    $0x0,%rax
je     11bb <main+0x8b>
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
jmp    11c7 <main+0x97>
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1151 <main+0x21>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xebb(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
je     11d4 <main+0xa4>
lea    0x1a(%rsp),%r15
lea    0x1f(%rsp),%r12
lea    0xe9a(%rip),%rbx
lea    0x10(%rsp),%r13
lea    0xe91(%rip),%rbp
lea    0xe92(%rip),%r14
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %rbx,%rdi
lea    0x15(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r13,%rdi
call   1040 <isValidLuhnAlgo@plt>
test   %rax,%rax
mov    %r14,%rdi
cmove  %rbp,%rdi
call   1030 <puts@plt>
addl   $0xffffffff,0xc(%rsp)
jne    1180 <main+0x50>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [7 x i8] c"Valid\0A\00"
@.str.3 = [9 x i8] c"Invalid\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [4 x [5 x i8]]
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %6
6: ; preds = %31, %0
%7 = load i32, i32* %2
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %34
9: ; preds = %6
store i32 0, i32* %3
br label %10
10: ; preds = %19, %9
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 4
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [4 x [5 x i8]], [4 x [5 x i8]]* %4, i64 0, i64 %15
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %16, i64 0, i64 0
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %13
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %10
22: ; preds = %10
%23 = getelementptr inbounds [4 x [5 x i8]], [4 x [5 x i8]]* %4, i64 0, i64 0
%24 = bitcast [5 x i8]* %23 to i8**
%25 = call i64 @isValidLuhnAlgo(i8** %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %31
29: ; preds = %22
%30 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %31
31: ; preds = %29, %27
%32 = load i32, i32* %2
%33 = add nsw i32 %32, -1
store i32 %33, i32* %2
br label %6
34: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
@str = [8 x i8] c"Invalid\00"
@str.4 = [6 x i8] c"Valid\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x [5 x i8]]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [4 x [5 x i8]], [4 x [5 x i8]]* %2, i64 0, i64 0, i64 0
%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 = icmp eq i32 %6, 0
br i1 %7, label %25, label %8
8: ; preds = %0
%9 = bitcast [4 x [5 x i8]]* %2 to i8**
%10 = getelementptr inbounds [4 x [5 x i8]], [4 x [5 x i8]]* %2, i64 0, i64 1, i64 0
%11 = getelementptr inbounds [4 x [5 x i8]], [4 x [5 x i8]]* %2, i64 0, i64 2, i64 0
%12 = getelementptr inbounds [4 x [5 x i8]], [4 x [5 x i8]]* %2, i64 0, i64 3, i64 0
br label %13
13: ; preds = %8, %13
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%18 = call i64 @isValidLuhnAlgo(i8** %9)
%19 = icmp eq i64 %18, 0
%20 = select i1 %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str.4, i64 0, i64 0)
%21 = call i32 @puts(i8* dereferenceable(1) %20)
%22 = load i32, i32* %1
%23 = add nsw i32 %22, -1
store i32 %23, i32* %1
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %13
25: ; preds = %13, %0
ret i32 0
}