#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 *, ...);
void TaskD(int **PixelStorage) {
  printf("\nZadanie 6.4\n");
  printf("----------------------------------------------------\n");
  int PixelIndex = 0;
  int CurrentIndex = 0;
  int CurrentPixel = -1;
  int PreviousPixel = -1;
  int CurrentOccurrence = 1;
  int MaximumOccurrence = 1;
  while (PixelIndex < 320) {
    while (CurrentIndex < 200) {
      CurrentPixel = PixelStorage[CurrentIndex][PixelIndex];
      if (CurrentPixel == PreviousPixel) {
        CurrentOccurrence++;
      } else {
        if (CurrentOccurrence > MaximumOccurrence) {
          MaximumOccurrence = CurrentOccurrence;
        }
        CurrentOccurrence = 1;
      }
      PreviousPixel = CurrentPixel;
      CurrentIndex++;
    }
    CurrentIndex = 0;
    PixelIndex++;
  }
  printf("Dlugosc najdluzszej kolumny: %d\n", MaximumOccurrence);
}


x86 assembly (clang, -O0):
<TaskD>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
cmpl   $0x140,-0xc(%rbp)
jge    11f3 <TaskD+0xe3>
jmp    1174 <TaskD+0x64>
cmpl   $0xc8,-0x10(%rbp)
jge    11de <TaskD+0xce>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    11b1 <TaskD+0xa1>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ca <TaskD+0xba>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    11c3 <TaskD+0xb3>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1174 <TaskD+0x64>
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1162 <TaskD+0x52>
mov    -0x20(%rbp),%esi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TaskD>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%r11d
mov    $0x1,%r8d
xor    %r9d,%r9d
mov    $0x1,%esi
mov    $0x1,%edx
nopl   0x0(%rax,%rax,1)
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
nop
mov    -0x8(%r14,%rax,8),%rbx
mov    (%r14,%rax,8),%r10
mov    (%rbx,%r9,4),%ebx
lea    0x1(%rdx),%ecx
cmp    %esi,%edx
cmovle %esi,%edx
cmp    %r11d,%ebx
cmovne %r8d,%ecx
mov    %edx,%edi
cmove  %esi,%edi
lea    0x1(%rcx),%edx
cmp    %edi,%ecx
cmovle %edi,%ecx
mov    (%r10,%r9,4),%r11d
cmp    %ebx,%r11d
cmovne %r8d,%edx
mov    %ecx,%esi
cmove  %edi,%esi
add    $0x2,%rax
cmp    $0xc9,%rax
jne    1170 <TaskD+0x50>
add    $0x1,%r9
cmp    $0x140,%r9
jne    1160 <TaskD+0x40>
lea    0xe37(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"\0AZadanie 6.4\0A\00"
@.str.1 = [54 x i8] c"----------------------------------------------------\0A\00"
@.str.2 = [33 x i8] c"Dlugosc najdluzszej kolumny: %d\0A\00"
define void @TaskD(i32** %0) {
%2 = alloca i32**
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32** %0, i32*** %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
store i32 0, i32* %4
store i32 -1, i32* %5
store i32 -1, i32* %6
store i32 1, i32* %7
store i32 1, i32* %8
br label %11
11: ; preds = %45, %1
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 320
br i1 %13, label %14, label %48
14: ; preds = %11
br label %15
15: ; preds = %41, %14
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 200
br i1 %17, label %18, label %45
18: ; preds = %15
%19 = load i32**, i32*** %2
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32*, i32** %19, i64 %21
%23 = load i32*, i32** %22
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
%27 = load i32, i32* %26
store i32 %27, i32* %5
%28 = load i32, i32* %5
%29 = load i32, i32* %6
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %34
31: ; preds = %18
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %41
34: ; preds = %18
%35 = load i32, i32* %7
%36 = load i32, i32* %8
%37 = icmp sgt i32 %35, %36
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = load i32, i32* %7
store i32 %39, i32* %8
br label %40
40: ; preds = %38, %34
store i32 1, i32* %7
br label %41
41: ; preds = %40, %31
%42 = load i32, i32* %5
store i32 %42, i32* %6
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
store i32 %44, i32* %4
br label %15
45: ; preds = %15
store i32 0, i32* %4
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 1
store i32 %47, i32* %3
br label %11
48: ; preds = %11
%49 = load i32, i32* %8
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %49)
ret void
}

LLVM IR (-O2):
@.str.2 = [33 x i8] c"Dlugosc najdluzszej kolumny: %d\0A\00"
@str = [13 x i8] c"\0AZadanie 6.4\00"
@str.3 = [53 x i8] c"----------------------------------------------------\00"
define void @TaskD(i32** nocapture %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.3, i64 0, i64 0))
br label %4
4: ; preds = %1, %37
%5 = phi i64 [ 0, %1 ], [ %38, %37 ]
%6 = phi i32 [ 1, %1 ], [ %34, %37 ]
%7 = phi i32 [ 1, %1 ], [ %33, %37 ]
%8 = phi i32 [ -1, %1 ], [ %28, %37 ]
br label %9
9: ; preds = %9, %4
%10 = phi i64 [ 0, %4 ], [ %35, %9 ]
%11 = phi i32 [ %6, %4 ], [ %34, %9 ]
%12 = phi i32 [ %7, %4 ], [ %33, %9 ]
%13 = phi i32 [ %8, %4 ], [ %28, %9 ]
%14 = getelementptr inbounds i32*, i32** %0, i64 %10
%15 = load i32*, i32** %14
%16 = getelementptr inbounds i32, i32* %15, i64 %5
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, %13
%19 = add nsw i32 %12, 1
%20 = icmp sgt i32 %12, %11
%21 = select i1 %20, i32 %12, i32 %11
%22 = select i1 %18, i32 %19, i32 1
%23 = select i1 %18, i32 %11, i32 %21
%24 = or i64 %10, 1
%25 = getelementptr inbounds i32*, i32** %0, i64 %24
%26 = load i32*, i32** %25
%27 = getelementptr inbounds i32, i32* %26, i64 %5
%28 = load i32, i32* %27
%29 = icmp eq i32 %28, %17
%30 = add nsw i32 %22, 1
%31 = icmp sgt i32 %22, %23
%32 = select i1 %31, i32 %22, i32 %23
%33 = select i1 %29, i32 %30, i32 1
%34 = select i1 %29, i32 %23, i32 %32
%35 = add nuw nsw i64 %10, 2
%36 = icmp eq i64 %35, 200
br i1 %36, label %37, label %9
37: ; preds = %9
%38 = add nuw nsw i64 %5, 1
%39 = icmp eq i64 %38, 320
br i1 %39, label %40, label %4
40: ; preds = %37
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %34)
ret void
}