#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);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int array[4][4], position[2] = {0};
  int i, j;
  puts("Input the array");
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++)
      scanf("%d", array[j] + i);
  }
  puts("Elements of the main diagonal:");
  for (i = 0; i < 4; i++)
    printf("%d ", array[i][i]);
  printf("\nElements of the upward-pointing triangle:\n");
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      if (i <= j)
        printf("%d ", array[j][i]);
      else
        printf("  ");
    }
    putchar('\n');
  }
  printf("\n%d %d %d %d\n", array[1][1], array[1][3], array[3][1], array[3][3]);
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++)
      if (array[i][j] > array[position[0]][position[1]]) {
        position[0] = i;
        position[1] = j;
      }
  }
  printf("Max element: %d, position:%d %d\n", array[position[0]][position[1]],
         position[0], position[1]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x58(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1060 <memset@plt>
lea    0xe8a(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x4,-0x5c(%rbp)
jge    11e4 <main+0x94>
movl   $0x0,-0x60(%rbp)
cmpl   $0x4,-0x60(%rbp)
jge    11d1 <main+0x81>
movslq -0x60(%rbp),%rax
lea    -0x50(%rbp),%rsi
shl    $0x4,%rax
add    %rax,%rsi
movslq -0x5c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe52(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    1193 <main+0x43>
jmp    11d6 <main+0x86>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1182 <main+0x32>
lea    0xe28(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x4,-0x5c(%rbp)
jge    1233 <main+0xe3>
movslq -0x5c(%rbp),%rcx
lea    -0x50(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11f7 <main+0xa7>
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x4,-0x5c(%rbp)
jge    12d1 <main+0x181>
movl   $0x0,-0x60(%rbp)
cmpl   $0x4,-0x60(%rbp)
jge    12b9 <main+0x169>
mov    -0x5c(%rbp),%eax
cmp    -0x60(%rbp),%eax
jg     1298 <main+0x148>
movslq -0x60(%rbp),%rcx
lea    -0x50(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12a6 <main+0x156>
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12ab <main+0x15b>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    1259 <main+0x109>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1248 <main+0xf8>
mov    -0x3c(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x4,-0x5c(%rbp)
jge    1372 <main+0x222>
movl   $0x0,-0x60(%rbp)
cmpl   $0x4,-0x60(%rbp)
jge    135f <main+0x20f>
movslq -0x5c(%rbp),%rcx
lea    -0x50(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x60(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
movslq -0x58(%rbp),%rdx
lea    -0x50(%rbp),%rcx
shl    $0x4,%rdx
add    %rdx,%rcx
movslq -0x54(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jle    134c <main+0x1fc>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x60(%rbp),%eax
mov    %eax,-0x54(%rbp)
jmp    1351 <main+0x201>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    1304 <main+0x1b4>
jmp    1364 <main+0x214>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    12f3 <main+0x1a3>
movslq -0x58(%rbp),%rcx
lea    -0x50(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x58(%rbp),%edx
mov    -0x54(%rbp),%ecx
lea    0xcde(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
lea    0xeaf(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb3(%rip),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0x30(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0x24(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0x34(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0x28(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0x38(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0x2c(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0x3c(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xde1(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%esi
lea    0xdf1(%rip),%rbx
xor    %r15d,%r15d
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x28(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x3c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xde9(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x30(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xd6a(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x34(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x28(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x38(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x3c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x14(%rsp),%esi
mov    0x1c(%rsp),%edx
mov    0x34(%rsp),%ecx
mov    0x3c(%rsp),%r8d
lea    0xca7(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%eax
xor    %ecx,%ecx
cmp    (%rsp),%eax
mov    0x8(%rsp),%eax
setg   %cl
cmp    (%rsp,%rcx,4),%eax
mov    $0x2,%esi
cmovg  %esi,%ecx
mov    0xc(%rsp),%eax
cmp    (%rsp,%rcx,4),%eax
mov    $0x3,%eax
cmovg  %eax,%ecx
mov    0x10(%rsp),%edx
xor    %ebp,%ebp
cmp    (%rsp,%rcx,4),%edx
setg   %bpl
cmovg  %r15d,%ecx
mov    0x14(%rsp),%edx
lea    0x0(,%rcx,4),%rdi
mov    %rbp,%rbx
shl    $0x4,%rbx
add    %rsp,%rbx
or     %rdi,%rbx
cmp    (%rbx),%edx
setg   %dl
mov    $0x1,%edi
cmovg  %edi,%ecx
or     %dl,%bpl
mov    0x18(%rsp),%edx
movzbl %bpl,%ebx
mov    %rbx,%rbp
shl    $0x4,%rbp
add    %rsp,%rbp
cmp    0x0(%rbp,%rcx,4),%edx
cmovg  %esi,%ecx
setg   %dl
or     %dl,%bl
mov    0x1c(%rsp),%edx
movzbl %bl,%ebx
mov    %rbx,%rbp
shl    $0x4,%rbp
add    %rsp,%rbp
cmp    0x0(%rbp,%rcx,4),%edx
setg   %dl
cmovg  %eax,%ecx
or     %dl,%bl
movzbl %bl,%edx
mov    0x20(%rsp),%ebp
mov    %rdx,%rbx
shl    $0x4,%rbx
add    %rsp,%rbx
cmp    (%rbx,%rcx,4),%ebp
cmovg  %esi,%edx
cmovg  %r15d,%ecx
mov    0x24(%rsp),%ebp
mov    %rdx,%rbx
shl    $0x4,%rbx
add    %rsp,%rbx
cmp    (%rbx,%rcx,4),%ebp
cmovg  %esi,%edx
cmovg  %edi,%ecx
mov    0x28(%rsp),%ebp
mov    %rdx,%rbx
shl    $0x4,%rbx
add    %rsp,%rbx
cmp    (%rbx,%rcx,4),%ebp
cmovg  %esi,%edx
cmovg  %esi,%ecx
mov    0x2c(%rsp),%ebp
mov    %rdx,%rbx
shl    $0x4,%rbx
add    %rsp,%rbx
cmp    (%rbx,%rcx,4),%ebp
cmovg  %esi,%edx
cmovg  %eax,%ecx
mov    0x30(%rsp),%ebp
mov    %rdx,%rbx
shl    $0x4,%rbx
add    %rsp,%rbx
cmp    (%rbx,%rcx,4),%ebp
cmovg  %eax,%edx
cmovg  %r15d,%ecx
mov    0x34(%rsp),%ebp
mov    %rdx,%rbx
shl    $0x4,%rbx
add    %rsp,%rbx
cmp    (%rbx,%rcx,4),%ebp
cmovg  %eax,%edx
cmovg  %edi,%ecx
mov    0x38(%rsp),%edi
mov    %rdx,%rbp
shl    $0x4,%rbp
add    %rsp,%rbp
cmp    0x0(%rbp,%rcx,4),%edi
cmovg  %eax,%edx
cmovg  %esi,%ecx
mov    0x3c(%rsp),%esi
mov    %rdx,%rdi
shl    $0x4,%rdi
add    %rsp,%rdi
cmp    (%rdi,%rcx,4),%esi
cmovg  %eax,%edx
cmovg  %eax,%ecx
mov    %rdx,%rax
shl    $0x4,%rax
add    %rsp,%rax
mov    (%rax,%rcx,4),%esi
lea    0xb3d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [16 x i8] c"Input the array\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [31 x i8] c"Elements of the main diagonal:\00"
@.str.3 = [4 x i8] c"%d \00"
@.str.5 = [3 x i8] c" \00"
@.str.6 = [14 x i8] c"\0A%d %d %d %d\0A\00"
@.str.7 = [33 x i8] c"Max element: %d, position:%d %d\0A\00"
@str = [43 x i8] c"\0AElements of the upward-pointing triangle:\00"
define i32 @main() {
%1 = alloca [4 x [4 x i32]]
%2 = bitcast [4 x [4 x i32]]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%6 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 1, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%8 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 2, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%10 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 3, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%12 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 0, i64 1
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %12)
%14 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 1, i64 1
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 2, i64 1
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
%18 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 3, i64 1
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %18)
%20 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 0, i64 2
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %20)
%22 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 1, i64 2
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %22)
%24 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 2, i64 2
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %24)
%26 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 3, i64 2
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %26)
%28 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 0, i64 3
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %28)
%30 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 1, i64 3
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %30)
%32 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 2, i64 3
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %32)
%34 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 3, i64 3
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %34)
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%37 = load i32, i32* %4
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %14
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %24
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %34
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %43)
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%46 = load i32, i32* %4
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %46)
%48 = load i32, i32* %6
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %8
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %50)
%52 = load i32, i32* %10
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %52)
%54 = call i32 @putchar(i8 signext 10)
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%56 = load i32, i32* %14
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %56)
%58 = load i32, i32* %16
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %58)
%60 = load i32, i32* %18
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %60)
%62 = call i32 @putchar(i8 signext 10)
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%65 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 2, i64 2
%66 = load i32, i32* %65
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %66)
%68 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 3, i64 2
%69 = load i32, i32* %68
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %69)
%71 = call i32 @putchar(i8 signext 10)
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%75 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 3, i64 3
%76 = load i32, i32* %75
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %76)
%78 = call i32 @putchar(i8 signext 10)
%79 = load i32, i32* %14
%80 = load i32, i32* %30
%81 = load i32, i32* %18
%82 = load i32, i32* %34
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %79, i32 %80, i32 %81, i32 %82)
%84 = load i32, i32* %12
%85 = load i32, i32* %4
%86 = icmp sgt i32 %84, %85
%87 = zext i1 %86 to i32
%88 = load i32, i32* %20
%89 = zext i1 %86 to i64
%90 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 0, i64 %89
%91 = load i32, i32* %90
%92 = icmp sgt i32 %88, %91
%93 = select i1 %92, i32 2, i32 %87
%94 = load i32, i32* %28
%95 = zext i32 %93 to i64
%96 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 0, i64 %95
%97 = load i32, i32* %96
%98 = icmp sgt i32 %94, %97
%99 = select i1 %98, i32 3, i32 %93
%100 = load i32, i32* %6
%101 = zext i32 %99 to i64
%102 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 0, i64 %101
%103 = load i32, i32* %102
%104 = icmp sgt i32 %100, %103
%105 = select i1 %104, i32 0, i32 %99
%106 = load i32, i32* %14
%107 = zext i1 %104 to i64
%108 = zext i32 %105 to i64
%109 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 %107, i64 %108
%110 = load i32, i32* %109
%111 = icmp sgt i32 %106, %110
%112 = select i1 %111, i1 true, i1 %104
%113 = select i1 %111, i32 1, i32 %105
%114 = load i32, i32* %22
%115 = zext i1 %112 to i64
%116 = zext i32 %113 to i64
%117 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 %115, i64 %116
%118 = load i32, i32* %117
%119 = icmp sgt i32 %114, %118
%120 = select i1 %119, i1 true, i1 %112
%121 = select i1 %119, i32 2, i32 %113
%122 = load i32, i32* %30
%123 = zext i1 %120 to i64
%124 = zext i32 %121 to i64
%125 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 %123, i64 %124
%126 = load i32, i32* %125
%127 = icmp sgt i32 %122, %126
%128 = select i1 %127, i1 true, i1 %120
%129 = zext i1 %128 to i32
%130 = select i1 %127, i32 3, i32 %121
%131 = load i32, i32* %8
%132 = zext i1 %128 to i64
%133 = zext i32 %130 to i64
%134 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 %132, i64 %133
%135 = load i32, i32* %134
%136 = icmp sgt i32 %131, %135
%137 = select i1 %136, i32 2, i32 %129
%138 = select i1 %136, i32 0, i32 %130
%139 = load i32, i32* %16
%140 = zext i32 %137 to i64
%141 = zext i32 %138 to i64
%142 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 %140, i64 %141
%143 = load i32, i32* %142
%144 = icmp sgt i32 %139, %143
%145 = select i1 %144, i32 2, i32 %137
%146 = select i1 %144, i32 1, i32 %138
%147 = load i32, i32* %24
%148 = zext i32 %145 to i64
%149 = zext i32 %146 to i64
%150 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 %148, i64 %149
%151 = load i32, i32* %150
%152 = icmp sgt i32 %147, %151
%153 = select i1 %152, i32 2, i32 %145
%154 = select i1 %152, i32 2, i32 %146
%155 = load i32, i32* %32
%156 = zext i32 %153 to i64
%157 = zext i32 %154 to i64
%158 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 %156, i64 %157
%159 = load i32, i32* %158
%160 = icmp sgt i32 %155, %159
%161 = select i1 %160, i32 2, i32 %153
%162 = select i1 %160, i32 3, i32 %154
%163 = load i32, i32* %10
%164 = zext i32 %161 to i64
%165 = zext i32 %162 to i64
%166 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 %164, i64 %165
%167 = load i32, i32* %166
%168 = icmp sgt i32 %163, %167
%169 = select i1 %168, i32 3, i32 %161
%170 = select i1 %168, i32 0, i32 %162
%171 = load i32, i32* %18
%172 = zext i32 %169 to i64
%173 = zext i32 %170 to i64
%174 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 %172, i64 %173
%175 = load i32, i32* %174
%176 = icmp sgt i32 %171, %175
%177 = select i1 %176, i32 3, i32 %169
%178 = select i1 %176, i32 1, i32 %170
%179 = load i32, i32* %26
%180 = zext i32 %177 to i64
%181 = zext i32 %178 to i64
%182 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 %180, i64 %181
%183 = load i32, i32* %182
%184 = icmp sgt i32 %179, %183
%185 = select i1 %184, i32 3, i32 %177
%186 = select i1 %184, i32 2, i32 %178
%187 = load i32, i32* %34
%188 = zext i32 %185 to i64
%189 = zext i32 %186 to i64
%190 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 %188, i64 %189
%191 = load i32, i32* %190
%192 = icmp sgt i32 %187, %191
%193 = select i1 %192, i32 3, i32 %185
%194 = select i1 %192, i32 3, i32 %186
%195 = zext i32 %193 to i64
%196 = zext i32 %194 to i64
%197 = getelementptr inbounds [4 x [4 x i32]], [4 x [4 x i32]]* %1, i64 0, i64 %195, i64 %196
%198 = load i32, i32* %197
%199 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 %198, i32 %193, i32 %194)
ret i32 0
}