#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 /*<<< orphan*/ putchar(char);
void print_lattice(const int *lattice, int rows, int columns,
                   char with_borders) {
  int i, j;
  for (i = 0; i < rows; i++) {
    if (with_borders) {
      for (j = 0; j < columns; j++) {
        printf("------");
      }
      printf("-\n");
    }
    for (j = 0; j < columns; j++) {
      if (with_borders) {
        putchar('|');
        putchar(' ');
      }
      if (lattice[i * columns + j] == 1) {
        printf(" x ");
      } else if (lattice[i * columns + j] > 1) {
        printf("%03d", lattice[i * columns + j]);
      } else {
        if (with_borders) {
          putchar(' ');
          putchar(' ');
          putchar(' ');
        } else {
          printf(" o ");
        }
      }
      if (with_borders) {
        putchar(' ');
        if (j == columns - 1) {
          putchar('|');
        }
      } else {
        if (j < columns - 1) {
          putchar(' ');
        }
      }
    }
    putchar('\n');
  }
  if (with_borders) {
    for (j = 0; j < columns; j++) {
      printf("------");
    }
    printf("-\n");
  } else {
    putchar('\n');
  }
}


x86 assembly (clang, -O0):
<print_lattice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12f6 <print_lattice+0x1d6>
cmpb   $0x0,-0x11(%rbp)
je     1191 <print_lattice+0x71>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1183 <print_lattice+0x63>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115b <print_lattice+0x3b>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    12de <print_lattice+0x1be>
cmpb   $0x0,-0x11(%rbp)
je     11c2 <print_lattice+0xa2>
mov    $0x7c,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    11f0 <print_lattice+0xd0>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1277 <print_lattice+0x157>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
cmpl   $0x1,(%rax,%rcx,4)
jle    1232 <print_lattice+0x112>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1272 <print_lattice+0x152>
cmpb   $0x0,-0x11(%rbp)
je     125f <print_lattice+0x13f>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    126d <print_lattice+0x14d>
lea    0xdad(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1272 <print_lattice+0x152>
jmp    1277 <print_lattice+0x157>
cmpb   $0x0,-0x11(%rbp)
je     12ab <print_lattice+0x18b>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    12a6 <print_lattice+0x186>
mov    $0x7c,%edi
call   1030 <putchar@plt>
jmp    12cb <print_lattice+0x1ab>
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12c6 <print_lattice+0x1a6>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    12cb <print_lattice+0x1ab>
jmp    12d0 <print_lattice+0x1b0>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1198 <print_lattice+0x78>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113e <print_lattice+0x1e>
cmpb   $0x0,-0x11(%rbp)
je     1342 <print_lattice+0x222>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    132f <print_lattice+0x20f>
lea    0xce6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1307 <print_lattice+0x1e7>
lea    0xcd1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    134c <print_lattice+0x22c>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_lattice>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %ecx,%ebp
mov    %edx,%r14d
test   %esi,%esi
jle    12cf <print_lattice+0x19f>
mov    %rdi,%r13
lea    -0x1(%r14),%eax
mov    %rax,0x20(%rsp)
cltq
mov    %rax,0x18(%rsp)
movslq %r14d,%rax
mov    %esi,%ecx
mov    %rcx,0x8(%rsp)
mov    %eax,%r15d
shl    $0x2,%rax
mov    %rax,0x10(%rsp)
lea    0xe85(%rip),%r12
xor    %eax,%eax
mov    %rax,(%rsp)
jmp    11bc <print_lattice+0x8c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%rsp),%rcx
add    $0x1,%rcx
add    0x10(%rsp),%r13
mov    %rcx,%rax
mov    %rcx,(%rsp)
cmp    0x8(%rsp),%rcx
mov    %rbx,%r14
je     12cf <print_lattice+0x19f>
test   %bpl,%bpl
je     11eb <print_lattice+0xbb>
test   %r14d,%r14d
jle    11df <print_lattice+0xaf>
mov    %r14d,%ebx
nopl   0x0(%rax)
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffff,%ebx
jne    11d0 <print_lattice+0xa0>
lea    0xe1f(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rbx
test   %r14d,%r14d
jle    1190 <print_lattice+0x60>
xor    %r14d,%r14d
jmp    1215 <print_lattice+0xe5>
nopl   0x0(%rax,%rax,1)
movzbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%r14
cmp    %r14,%r15
je     1190 <print_lattice+0x60>
test   %bpl,%bpl
je     122e <print_lattice+0xfe>
mov    $0x7c,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    0x0(%r13,%r14,4),%esi
cmp    $0x1,%esi
jne    1250 <print_lattice+0x120>
lea    0xdc8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1260 <print_lattice+0x130>
nopl   0x0(%rax,%rax,1)
jle    1270 <print_lattice+0x140>
lea    0xdb2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %bpl,%bpl
jne    1293 <print_lattice+0x163>
jmp    12bd <print_lattice+0x18d>
nopw   0x0(%rax,%rax,1)
test   %bpl,%bpl
je     12af <print_lattice+0x17f>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x7c,%al
cmp    %r14,0x20(%rsp)
je     1200 <print_lattice+0xd0>
jmp    1208 <print_lattice+0xd8>
lea    0xd5a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x20,%al
cmp    0x18(%rsp),%r14
jl     1200 <print_lattice+0xd0>
jmp    1208 <print_lattice+0xd8>
test   %bpl,%bpl
je     130a <print_lattice+0x1da>
test   %r14d,%r14d
jle    12f0 <print_lattice+0x1c0>
lea    0xd20(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffff,%r14d
jne    12e0 <print_lattice+0x1b0>
lea    0xd0e(%rip),%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>
mov    $0xa,%edi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"------\00"
@.str.1 = [3 x i8] c"-\0A\00"
@.str.2 = [4 x i8] c" x \00"
@.str.3 = [5 x i8] c"%03d\00"
@.str.4 = [4 x i8] c" o \00"
define void @print_lattice(i32* %0, i32 %1, i32 %2, i8 signext %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8 %3, i8* %8
store i32 0, i32* %9
br label %11
11: ; preds = %113, %4
%12 = load i32, i32* %9
%13 = load i32, i32* %6
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %116
15: ; preds = %11
%16 = load i8, i8* %8
%17 = icmp ne i8 %16, 0
br i1 %17, label %18, label %30
18: ; preds = %15
store i32 0, i32* %10
br label %19
19: ; preds = %25, %18
%20 = load i32, i32* %10
%21 = load i32, i32* %7
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %25
25: ; preds = %23
%26 = load i32, i32* %10
%27 = add nsw i32 %26, 1
store i32 %27, i32* %10
br label %19
28: ; preds = %19
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %28, %15
store i32 0, i32* %10
br label %31
31: ; preds = %108, %30
%32 = load i32, i32* %10
%33 = load i32, i32* %7
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %111
35: ; preds = %31
%36 = load i8, i8* %8
%37 = icmp ne i8 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = call i32 @putchar(i8 signext 124)
%40 = call i32 @putchar(i8 signext 32)
br label %41
41: ; preds = %38, %35
%42 = load i32*, i32** %5
%43 = load i32, i32* %9
%44 = load i32, i32* %7
%45 = mul nsw i32 %43, %44
%46 = load i32, i32* %10
%47 = add nsw i32 %45, %46
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %42, i64 %48
%50 = load i32, i32* %49
%51 = icmp eq i32 %50, 1
br i1 %51, label %52, label %54
52: ; preds = %41
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %87
54: ; preds = %41
%55 = load i32*, i32** %5
%56 = load i32, i32* %9
%57 = load i32, i32* %7
%58 = mul nsw i32 %56, %57
%59 = load i32, i32* %10
%60 = add nsw i32 %58, %59
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* %55, i64 %61
%63 = load i32, i32* %62
%64 = icmp sgt i32 %63, 1
br i1 %64, label %65, label %76
65: ; preds = %54
%66 = load i32*, i32** %5
%67 = load i32, i32* %9
%68 = load i32, i32* %7
%69 = mul nsw i32 %67, %68
%70 = load i32, i32* %10
%71 = add nsw i32 %69, %70
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i32, i32* %66, i64 %72
%74 = load i32, i32* %73
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %74)
br label %86
76: ; preds = %54
%77 = load i8, i8* %8
%78 = icmp ne i8 %77, 0
br i1 %78, label %79, label %83
79: ; preds = %76
%80 = call i32 @putchar(i8 signext 32)
%81 = call i32 @putchar(i8 signext 32)
%82 = call i32 @putchar(i8 signext 32)
br label %85
83: ; preds = %76
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %85
85: ; preds = %83, %79
br label %86
86: ; preds = %85, %65
br label %87
87: ; preds = %86, %52
%88 = load i8, i8* %8
%89 = icmp ne i8 %88, 0
br i1 %89, label %90, label %99
90: ; preds = %87
%91 = call i32 @putchar(i8 signext 32)
%92 = load i32, i32* %10
%93 = load i32, i32* %7
%94 = sub nsw i32 %93, 1
%95 = icmp eq i32 %92, %94
br i1 %95, label %96, label %98
96: ; preds = %90
%97 = call i32 @putchar(i8 signext 124)
br label %98
98: ; preds = %96, %90
br label %107
99: ; preds = %87
%100 = load i32, i32* %10
%101 = load i32, i32* %7
%102 = sub nsw i32 %101, 1
%103 = icmp slt i32 %100, %102
br i1 %103, label %104, label %106
104: ; preds = %99
%105 = call i32 @putchar(i8 signext 32)
br label %106
106: ; preds = %104, %99
br label %107
107: ; preds = %106, %98
br label %108
108: ; preds = %107
%109 = load i32, i32* %10
%110 = add nsw i32 %109, 1
store i32 %110, i32* %10
br label %31
111: ; preds = %31
%112 = call i32 @putchar(i8 signext 10)
br label %113
113: ; preds = %111
%114 = load i32, i32* %9
%115 = add nsw i32 %114, 1
store i32 %115, i32* %9
br label %11
116: ; preds = %11
%117 = load i8, i8* %8
%118 = icmp ne i8 %117, 0
br i1 %118, label %119, label %131
119: ; preds = %116
store i32 0, i32* %10
br label %120
120: ; preds = %126, %119
%121 = load i32, i32* %10
%122 = load i32, i32* %7
%123 = icmp slt i32 %121, %122
br i1 %123, label %124, label %129
124: ; preds = %120
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %126
126: ; preds = %124
%127 = load i32, i32* %10
%128 = add nsw i32 %127, 1
store i32 %128, i32* %10
br label %120
129: ; preds = %120
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %133
131: ; preds = %116
%132 = call i32 @putchar(i8 signext 10)
br label %133
133: ; preds = %131, %129
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"------\00"
@.str.2 = [4 x i8] c" x \00"
@.str.3 = [5 x i8] c"%03d\00"
@.str.4 = [4 x i8] c" o \00"
@str.5 = [2 x i8] c"-\00"
define void @print_lattice(i32* nocapture %0, i32 %1, i32 %2, i8 signext %3) {
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %67
6: ; preds = %4
%7 = icmp eq i8 %3, 0
%8 = icmp sgt i32 %2, 0
%9 = add nsw i32 %2, -1
%10 = zext i32 %9 to i64
%11 = sext i32 %9 to i64
%12 = sext i32 %2 to i64
%13 = zext i32 %1 to i64
%14 = zext i32 %2 to i64
br label %15
15: ; preds = %6, %63
%16 = phi i64 [ 0, %6 ], [ %65, %63 ]
br i1 %7, label %25, label %17
17: ; preds = %15
br i1 %8, label %18, label %23
18: ; preds = %17, %18
%19 = phi i32 [ %21, %18 ], [ 0, %17 ]
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%21 = add nuw nsw i32 %19, 1
%22 = icmp eq i32 %21, %2
br i1 %22, label %23, label %18
23: ; preds = %18, %17
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.5, i64 0, i64 0))
br label %25
25: ; preds = %23, %15
br i1 %8, label %26, label %63
26: ; preds = %25
%27 = mul nsw i64 %16, %12
br label %28
28: ; preds = %26, %60
%29 = phi i64 [ 0, %26 ], [ %61, %60 ]
br i1 %7, label %33, label %30
30: ; preds = %28
%31 = tail call i32 @putchar(i8 signext 124)
%32 = tail call i32 @putchar(i8 signext 32)
br label %33
33: ; preds = %30, %28
%34 = add nsw i64 %29, %27
%35 = getelementptr inbounds i32, i32* %0, i64 %34
%36 = load i32, i32* %35
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %51
40: ; preds = %33
%41 = icmp sgt i32 %36, 1
br i1 %41, label %42, label %44
42: ; preds = %40
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %36)
br label %51
44: ; preds = %40
br i1 %7, label %49, label %45
45: ; preds = %44
%46 = tail call i32 @putchar(i8 signext 32)
%47 = tail call i32 @putchar(i8 signext 32)
%48 = tail call i32 @putchar(i8 signext 32)
br label %52
49: ; preds = %44
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %55
51: ; preds = %42, %38
br i1 %7, label %55, label %52
52: ; preds = %45, %51
%53 = tail call i32 @putchar(i8 signext 32)
%54 = icmp eq i64 %29, %10
br i1 %54, label %57, label %60
55: ; preds = %49, %51
%56 = icmp slt i64 %29, %11
br i1 %56, label %57, label %60
57: ; preds = %55, %52
%58 = phi i8 [ 124, %52 ], [ 32, %55 ]
%59 = tail call i32 @putchar(i8 signext %58)
br label %60
60: ; preds = %57, %52, %55
%61 = add nuw nsw i64 %29, 1
%62 = icmp eq i64 %61, %14
br i1 %62, label %63, label %28
63: ; preds = %60, %25
%64 = tail call i32 @putchar(i8 signext 10)
%65 = add nuw nsw i64 %16, 1
%66 = icmp eq i64 %65, %13
br i1 %66, label %67, label %15
67: ; preds = %63, %4
%68 = icmp eq i8 %3, 0
br i1 %68, label %78, label %69
69: ; preds = %67
%70 = icmp sgt i32 %2, 0
br i1 %70, label %71, label %76
71: ; preds = %69, %71
%72 = phi i32 [ %74, %71 ], [ 0, %69 ]
%73 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%74 = add nuw nsw i32 %72, 1
%75 = icmp eq i32 %74, %2
br i1 %75, label %76, label %71
76: ; preds = %71, %69
%77 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.5, i64 0, i64 0))
br label %80
78: ; preds = %67
%79 = tail call i32 @putchar(i8 signext 10)
br label %80
80: ; preds = %78, %76
ret void
}