#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*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int a[4][3];
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  int col = -1;
  for (int i = 0; i < 3; i++) {
    int valid = 1;
    for (int j = 0; j < 4; j++) {
      if (a[j][i] % 3 != 0) {
        valid = 0;
      }
    }
    if (valid)
      col = i;
  }
  printf("%d", col);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x4,-0x44(%rbp)
jge    1198 <main+0x78>
movl   $0x0,-0x48(%rbp)
cmpl   $0x3,-0x48(%rbp)
jge    1185 <main+0x65>
movslq -0x44(%rbp),%rax
lea    -0x40(%rbp),%rsi
imul   $0xc,%rax,%rax
add    %rax,%rsi
movslq -0x48(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe8e(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1147 <main+0x27>
jmp    118a <main+0x6a>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1136 <main+0x16>
movl   $0xffffffff,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
cmpl   $0x3,-0x50(%rbp)
jge    122c <main+0x10c>
movl   $0x1,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
cmpl   $0x4,-0x58(%rbp)
jge    1209 <main+0xe9>
movslq -0x58(%rbp),%rcx
lea    -0x40(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x50(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11f6 <main+0xd6>
movl   $0x0,-0x54(%rbp)
jmp    11fb <main+0xdb>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    11be <main+0x9e>
cmpl   $0x0,-0x54(%rbp)
je     1219 <main+0xf9>
mov    -0x50(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    121e <main+0xfe>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    11a6 <main+0x86>
mov    -0x4c(%rbp),%esi
lea    0xdca(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0xed2(%rip),%r14
mov    %rsp,%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0x14(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0x18(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0x1c(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0x20(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0x24(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0x28(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0x2c(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
movslq (%rsp),%rcx
imul   $0x55555556,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rax
add    %edx,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%ecx
movslq 0xc(%rsp),%rax
imul   $0x55555556,%rax,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
shr    $0x20,%rdx
add    %esi,%edx
lea    (%rdx,%rdx,2),%edx
sub    %edx,%eax
movslq 0x18(%rsp),%rdx
imul   $0x55555556,%rdx,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
shr    $0x20,%rsi
add    %edi,%esi
lea    (%rsi,%rsi,2),%esi
sub    %esi,%edx
movslq 0x24(%rsp),%rsi
imul   $0x55555556,%rsi,%rdi
mov    %rdi,%rbx
shr    $0x3f,%rbx
shr    $0x20,%rdi
add    %ebx,%edi
lea    (%rdi,%rdi,2),%edi
sub    %edi,%esi
or     %edx,%esi
or     %eax,%esi
xor    %eax,%eax
or     %ecx,%esi
setne  %al
neg    %eax
movslq 0x4(%rsp),%rdx
imul   $0x55555556,%rdx,%rcx
mov    %rcx,%rsi
shr    $0x3f,%rsi
shr    $0x20,%rcx
add    %esi,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%edx
movslq 0x10(%rsp),%rcx
imul   $0x55555556,%rcx,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
shr    $0x20,%rsi
add    %edi,%esi
lea    (%rsi,%rsi,2),%esi
sub    %esi,%ecx
or     %edx,%ecx
movslq 0x1c(%rsp),%rdx
imul   $0x55555556,%rdx,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
shr    $0x20,%rsi
add    %edi,%esi
lea    (%rsi,%rsi,2),%esi
sub    %esi,%edx
movslq 0x28(%rsp),%rsi
imul   $0x55555556,%rsi,%rdi
mov    %rdi,%rbx
shr    $0x3f,%rbx
shr    $0x20,%rdi
add    %ebx,%edi
lea    (%rdi,%rdi,2),%edi
sub    %edi,%esi
or     %edx,%esi
or     %ecx,%esi
mov    $0x1,%ecx
cmovne %eax,%ecx
movslq 0x8(%rsp),%rdx
imul   $0x55555556,%rdx,%rax
mov    %rax,%rsi
shr    $0x3f,%rsi
shr    $0x20,%rax
add    %esi,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%edx
movslq 0x14(%rsp),%rax
imul   $0x55555556,%rax,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
shr    $0x20,%rsi
add    %edi,%esi
lea    (%rsi,%rsi,2),%esi
sub    %esi,%eax
or     %edx,%eax
movslq 0x20(%rsp),%rdx
imul   $0x55555556,%rdx,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
shr    $0x20,%rsi
add    %edi,%esi
lea    (%rsi,%rsi,2),%esi
sub    %esi,%edx
movslq 0x2c(%rsp),%rsi
imul   $0x55555556,%rsi,%rdi
mov    %rdi,%rbx
shr    $0x3f,%rbx
shr    $0x20,%rdi
add    %ebx,%edi
lea    (%rdi,%rdi,2),%edi
sub    %edi,%esi
or     %edx,%esi
or     %eax,%esi
mov    $0x2,%esi
cmovne %ecx,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x [3 x i32]]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %9
9: ; preds = %28, %0
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %31
12: ; preds = %9
store i32 0, i32* %4
br label %13
13: ; preds = %24, %12
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 3
br i1 %15, label %16, label %27
16: ; preds = %13
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* %2, i64 0, i64 %18
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %19, i64 0, i64 %21
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %22)
br label %24
24: ; preds = %16
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %13
27: ; preds = %13
br label %28
28: ; preds = %27
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %9
31: ; preds = %9
store i32 -1, i32* %5
store i32 0, i32* %6
br label %32
32: ; preds = %60, %31
%33 = load i32, i32* %6
%34 = icmp slt i32 %33, 3
br i1 %34, label %35, label %63
35: ; preds = %32
store i32 1, i32* %7
store i32 0, i32* %8
br label %36
36: ; preds = %51, %35
%37 = load i32, i32* %8
%38 = icmp slt i32 %37, 4
br i1 %38, label %39, label %54
39: ; preds = %36
%40 = load i32, i32* %8
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* %2, i64 0, i64 %41
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [3 x i32], [3 x i32]* %42, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = srem i32 %46, 3
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %39
store i32 0, i32* %7
br label %50
50: ; preds = %49, %39
br label %51
51: ; preds = %50
%52 = load i32, i32* %8
%53 = add nsw i32 %52, 1
store i32 %53, i32* %8
br label %36
54: ; preds = %36
%55 = load i32, i32* %7
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = load i32, i32* %6
store i32 %58, i32* %5
br label %59
59: ; preds = %57, %54
br label %60
60: ; preds = %59
%61 = load i32, i32* %6
%62 = add nsw i32 %61, 1
store i32 %62, i32* %6
br label %32
63: ; preds = %32
%64 = load i32, i32* %5
%65 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %64)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca [4 x [3 x i32]]
%2 = bitcast [4 x [3 x i32]]* %1 to i8*
%3 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* %1, i64 0, i64 0, i64 0
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%5 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* %1, i64 0, i64 0, i64 1
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%7 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* %1, i64 0, i64 0, i64 2
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%9 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* %1, i64 0, i64 1, i64 0
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
%11 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* %1, i64 0, i64 1, i64 1
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %11)
%13 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* %1, i64 0, i64 1, i64 2
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %13)
%15 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* %1, i64 0, i64 2, i64 0
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %15)
%17 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* %1, i64 0, i64 2, i64 1
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %17)
%19 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* %1, i64 0, i64 2, i64 2
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %19)
%21 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* %1, i64 0, i64 3, i64 0
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %21)
%23 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* %1, i64 0, i64 3, i64 1
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %23)
%25 = getelementptr inbounds [4 x [3 x i32]], [4 x [3 x i32]]* %1, i64 0, i64 3, i64 2
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %25)
%27 = load i32, i32* %3
%28 = srem i32 %27, 3
%29 = icmp ne i32 %28, 0
%30 = load i32, i32* %9
%31 = srem i32 %30, 3
%32 = icmp ne i32 %31, 0
%33 = load i32, i32* %15
%34 = srem i32 %33, 3
%35 = icmp ne i32 %34, 0
%36 = load i32, i32* %21
%37 = srem i32 %36, 3
%38 = icmp ne i32 %37, 0
%39 = select i1 %38, i1 true, i1 %35
%40 = select i1 %39, i1 true, i1 %32
%41 = select i1 %40, i1 true, i1 %29
%42 = sext i1 %41 to i32
%43 = load i32, i32* %5
%44 = srem i32 %43, 3
%45 = icmp ne i32 %44, 0
%46 = load i32, i32* %11
%47 = srem i32 %46, 3
%48 = icmp ne i32 %47, 0
%49 = load i32, i32* %17
%50 = srem i32 %49, 3
%51 = icmp ne i32 %50, 0
%52 = load i32, i32* %23
%53 = srem i32 %52, 3
%54 = icmp ne i32 %53, 0
%55 = select i1 %54, i1 true, i1 %51
%56 = select i1 %55, i1 true, i1 %48
%57 = select i1 %56, i1 true, i1 %45
%58 = select i1 %57, i32 %42, i32 1
%59 = load i32, i32* %7
%60 = srem i32 %59, 3
%61 = icmp ne i32 %60, 0
%62 = load i32, i32* %13
%63 = srem i32 %62, 3
%64 = icmp ne i32 %63, 0
%65 = load i32, i32* %19
%66 = srem i32 %65, 3
%67 = icmp ne i32 %66, 0
%68 = load i32, i32* %25
%69 = srem i32 %68, 3
%70 = icmp ne i32 %69, 0
%71 = select i1 %70, i1 true, i1 %67
%72 = select i1 %71, i1 true, i1 %64
%73 = select i1 %72, i1 true, i1 %61
%74 = select i1 %73, i32 %58, i32 2
%75 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %74)
ret i32 0
}