#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*/ lineck(char *);
int qdrtck(char *matrix) {
  char *ptr = matrix, line[10] = {0};
  int c, it = 0;
  while (it < 9) {
    c = 0;
    while (c < 9) {
      line[c++] = *ptr;
      ptr += (c && !(c % 3)) ? 8 : 1;
    }
    it++;
    ptr = matrix += (it && !(it % 3) ? 24 : 3);
    if (!lineck(line))
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<qdrtck>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x22(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x9,-0x2c(%rbp)
jge    123e <qdrtck+0x11e>
movl   $0x0,-0x28(%rbp)
cmpl   $0x9,-0x28(%rbp)
jge    11c8 <qdrtck+0xa8>
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x28(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x28(%rbp)
cltq
mov    %cl,-0x22(%rbp,%rax,1)
xor    %eax,%eax
cmpl   $0x0,-0x28(%rbp)
mov    %al,-0x2d(%rbp)
je     11a2 <qdrtck+0x82>
mov    -0x28(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
setne  %al
xor    $0xff,%al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%dl
mov    $0x1,%ecx
mov    $0x8,%eax
test   $0x1,%dl
cmovne %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
jmp    115c <qdrtck+0x3c>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x2c(%rbp)
mov    %al,-0x2e(%rbp)
je     11f6 <qdrtck+0xd6>
mov    -0x2c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
setne  %al
xor    $0xff,%al
mov    %al,-0x2e(%rbp)
mov    -0x2e(%rbp),%dl
mov    $0x3,%ecx
mov    $0x18,%eax
test   $0x1,%dl
cmovne %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    %rax,-0x18(%rbp)
lea    -0x22(%rbp),%rdi
call   1030 <lineck@plt>
cmp    $0x0,%eax
jne    1239 <qdrtck+0x119>
movl   $0x0,-0x4(%rbp)
jmp    1245 <qdrtck+0x125>
jmp    114b <qdrtck+0x2b>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qdrtck>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
movb   $0x0,0x17(%rsp)
xor    %ebp,%ebp
mov    $0x1,%r14d
mov    $0xaaaaaaab,%r12d
lea    0xe(%rsp),%r15
mov    $0x1,%r13d
nop
cmp    $0xfffffff7,%ebp
je     11cd <qdrtck+0xbd>
mov    %r13d,%eax
imul   %r12,%rax
shr    $0x21,%rax
lea    (%rax,%rax,2),%eax
mov    $0x1,%ecx
sub    %eax,%ecx
movzbl (%rbx),%eax
mov    %al,0xe(%rsp)
movzbl 0x1(%rbx),%eax
mov    %al,0xf(%rsp)
movzbl 0x2(%rbx),%eax
mov    %al,0x10(%rsp)
movzbl 0xa(%rbx),%eax
mov    %al,0x11(%rsp)
movzbl 0xb(%rbx),%eax
mov    %al,0x12(%rsp)
movzbl 0xc(%rbx),%eax
mov    %al,0x13(%rsp)
movzbl 0x14(%rbx),%eax
mov    %al,0x14(%rsp)
movzbl 0x15(%rbx),%eax
mov    %al,0x15(%rsp)
movzbl 0x16(%rbx),%eax
mov    %al,0x16(%rsp)
lea    0x3(%rbx),%rax
add    $0x18,%rbx
cmp    %ebp,%ecx
cmovne %rax,%rbx
mov    %r15,%rdi
call   1030 <lineck@plt>
add    $0xffffffff,%ebp
add    $0x1,%r13d
test   %eax,%eax
jne    1140 <qdrtck+0x30>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @qdrtck(i8* nocapture %0) {
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 9
store i8 0, i8* %4
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 1
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 2
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 3
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 4
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 5
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 6
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 7
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 8
br label %13
13: ; preds = %17, %1
%14 = phi i8* [ %0, %1 ], [ %39, %17 ]
%15 = phi i32 [ 0, %1 ], [ %35, %17 ]
%16 = icmp eq i32 %15, 9
br i1 %16, label %42, label %17
17: ; preds = %13
%18 = load i8, i8* %14
store i8 %18, i8* %3
%19 = getelementptr inbounds i8, i8* %14, i64 1
%20 = load i8, i8* %19
store i8 %20, i8* %5
%21 = getelementptr inbounds i8, i8* %14, i64 2
%22 = load i8, i8* %21
store i8 %22, i8* %6
%23 = getelementptr inbounds i8, i8* %14, i64 10
%24 = load i8, i8* %23
store i8 %24, i8* %7
%25 = getelementptr inbounds i8, i8* %14, i64 11
%26 = load i8, i8* %25
store i8 %26, i8* %8
%27 = getelementptr inbounds i8, i8* %14, i64 12
%28 = load i8, i8* %27
store i8 %28, i8* %9
%29 = getelementptr inbounds i8, i8* %14, i64 20
%30 = load i8, i8* %29
store i8 %30, i8* %10
%31 = getelementptr inbounds i8, i8* %14, i64 21
%32 = load i8, i8* %31
store i8 %32, i8* %11
%33 = getelementptr inbounds i8, i8* %14, i64 22
%34 = load i8, i8* %33
store i8 %34, i8* %12
%35 = add nuw nsw i32 %15, 1
%36 = urem i32 %35, 3
%37 = icmp eq i32 %36, 0
%38 = select i1 %37, i64 24, i64 3
%39 = getelementptr inbounds i8, i8* %14, i64 %38
%40 = call i32 @lineck(i8* %3)
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %13
42: ; preds = %13, %17
%43 = phi i32 [ 0, %17 ], [ 1, %13 ]
ret i32 %43
}