#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*/ scanf(char *, int *);
int /*<<< orphan*/ suma_po_dijagonalama(int **, int);
int /*<<< orphan*/ suma_po_kolonama_i_redovima(int **, int);
int /*<<< orphan*/ suma_po_svakom_drugom(int **, int);
int matrica(int niz[][10], int vel) {
  int i, j, choice;
  for (i = 0; i < vel; i++) {
    for (j = 0; j < vel; j++) {
      do {
        scanf("%d", &niz[i][j]);
      } while (niz[i][j] < 1 || niz[i][j] > 9);
    }
    printf("\n");
  }
  printf("Make your choice: 1, 2 or 3\n");
  scanf("%d", &choice);
  switch (choice) {
  case 1:
    suma_po_kolonama_i_redovima(niz, vel);
    break;
  case 2:
    suma_po_dijagonalama(niz, vel);
    break;
  case 3:
    suma_po_svakom_drugom(niz, vel);
    break;
  default:
    printf("Wrong choice!");
  }
}


x86 assembly (clang, -O0):
<matrica>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1227 <matrica+0xd7>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    120d <matrica+0xbd>
jmp    118a <matrica+0x3a>
mov    -0x10(%rbp),%rsi
movslq -0x18(%rbp),%rax
imul   $0x28,%rax,%rax
add    %rax,%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe55(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x10(%rbp),%rcx
movslq -0x18(%rbp),%rax
imul   $0x28,%rax,%rax
add    %rax,%rcx
movslq -0x1c(%rbp),%rdx
mov    $0x1,%al
cmpl   $0x1,(%rcx,%rdx,4)
mov    %al,-0x21(%rbp)
jl     11ef <matrica+0x9f>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
cmpl   $0x9,(%rax,%rcx,4)
setg   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    118a <matrica+0x3a>
jmp    11ff <matrica+0xaf>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1179 <matrica+0x29>
lea    0xe0a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1166 <matrica+0x16>
lea    0xdd5(%rip),%rdi
call   1030 <printf@plt>
lea    0xdc6(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x1,%eax
je     1279 <matrica+0x129>
jmp    1257 <matrica+0x107>
mov    -0x28(%rbp),%eax
sub    $0x2,%eax
je     128a <matrica+0x13a>
jmp    1268 <matrica+0x118>
mov    -0x28(%rbp),%eax
sub    $0x3,%eax
je     129b <matrica+0x14b>
jmp    12ac <matrica+0x15c>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <suma_po_kolonama_i_redovima@plt>
jmp    12b8 <matrica+0x168>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <suma_po_dijagonalama@plt>
jmp    12b8 <matrica+0x168>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <suma_po_svakom_drugom@plt>
jmp    12b8 <matrica+0x168>
lea    0xd6d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrica>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
mov    %esi,(%rsp)
test   %esi,%esi
jle    1201 <matrica+0x91>
mov    (%rsp),%r12d
xor    %r13d,%r13d
lea    0xe6d(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x0(,%r13,4),%rax
add    %r13,%rax
lea    (%r15,%rax,8),%rax
lea    (%rax,%r14,4),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
mov    (%rbx),%eax
add    $0xfffffff6,%eax
cmp    $0xfffffff7,%eax
jb     11d0 <matrica+0x60>
add    $0x1,%r14
cmp    %r12,%r14
jne    11b0 <matrica+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r13
cmp    %r12,%r13
jne    11a0 <matrica+0x30>
lea    0xe09(%rip),%rdi
call   1040 <puts@plt>
lea    0xdec(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x3,%eax
je     123e <matrica+0xce>
cmp    $0x2,%eax
je     124b <matrica+0xdb>
cmp    $0x1,%eax
jne    1258 <matrica+0xe8>
mov    %r15,%rdi
mov    (%rsp),%esi
call   1090 <suma_po_kolonama_i_redovima@plt>
jmp    1264 <matrica+0xf4>
mov    %r15,%rdi
mov    (%rsp),%esi
call   1060 <suma_po_svakom_drugom@plt>
jmp    1264 <matrica+0xf4>
mov    %r15,%rdi
mov    (%rsp),%esi
call   1070 <suma_po_dijagonalama@plt>
jmp    1264 <matrica+0xf4>
lea    0xda4(%rip),%rdi
call   1050 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [29 x i8] c"Make your choice: 1, 2 or 3\0A\00"
@.str.3 = [14 x i8] c"Wrong choice!\00"
define i32 @matrica([10 x i32]* %0, i32 %1) {
%3 = alloca i32
%4 = alloca [10 x i32]*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store [10 x i32]* %0, [10 x i32]** %4
store i32 %1, i32* %5
store i32 0, i32* %6
br label %9
9: ; preds = %56, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %5
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %59
13: ; preds = %9
store i32 0, i32* %7
br label %14
14: ; preds = %51, %13
%15 = load i32, i32* %7
%16 = load i32, i32* %5
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %54
18: ; preds = %14
br label %19
19: ; preds = %48, %18
%20 = load [10 x i32]*, [10 x i32]** %4
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %20, i64 %22
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %23, i64 0, i64 %25
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %26)
br label %28
28: ; preds = %19
%29 = load [10 x i32]*, [10 x i32]** %4
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %29, i64 %31
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [10 x i32], [10 x i32]* %32, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = icmp slt i32 %36, 1
br i1 %37, label %48, label %38
38: ; preds = %28
%39 = load [10 x i32]*, [10 x i32]** %4
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [10 x i32], [10 x i32]* %39, i64 %41
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [10 x i32], [10 x i32]* %42, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = icmp sgt i32 %46, 9
br label %48
48: ; preds = %38, %28
%49 = phi i1 [ true, %28 ], [ %47, %38 ]
br i1 %49, label %19, label %50
50: ; preds = %48
br label %51
51: ; preds = %50
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
store i32 %53, i32* %7
br label %14
54: ; preds = %14
%55 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %56
56: ; preds = %54
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
store i32 %58, i32* %6
br label %9
59: ; preds = %9
%60 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%61 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%62 = load i32, i32* %8
switch i32 %62, label %78 [
i32 1, label %63
i32 2, label %68
i32 3, label %73
]
63: ; preds = %59
%64 = load [10 x i32]*, [10 x i32]** %4
%65 = bitcast [10 x i32]* %64 to i32**
%66 = load i32, i32* %5
%67 = call i32 @suma_po_kolonama_i_redovima(i32** %65, i32 %66)
br label %80
68: ; preds = %59
%69 = load [10 x i32]*, [10 x i32]** %4
%70 = bitcast [10 x i32]* %69 to i32**
%71 = load i32, i32* %5
%72 = call i32 @suma_po_dijagonalama(i32** %70, i32 %71)
br label %80
73: ; preds = %59
%74 = load [10 x i32]*, [10 x i32]** %4
%75 = bitcast [10 x i32]* %74 to i32**
%76 = load i32, i32* %5
%77 = call i32 @suma_po_svakom_drugom(i32** %75, i32 %76)
br label %80
78: ; preds = %59
%79 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %80
80: ; preds = %78, %73, %68, %63
%81 = load i32, i32* %3
ret i32 %81
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.3 = [14 x i8] c"Wrong choice!\00"
@str = [28 x i8] c"Make your choice: 1, 2 or 3\00"
define i32 @matrica([10 x i32]* %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %25
6: ; preds = %2
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %21, %6
%9 = phi i64 [ 0, %6 ], [ %23, %21 ]
br label %10
10: ; preds = %8, %18
%11 = phi i64 [ 0, %8 ], [ %19, %18 ]
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %0, i64 %9, i64 %11
br label %13
13: ; preds = %10, %13
%14 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %12)
%15 = load i32, i32* %12
%16 = add i32 %15, -10
%17 = icmp ult i32 %16, -9
br i1 %17, label %13, label %18
18: ; preds = %13
%19 = add nuw nsw i64 %11, 1
%20 = icmp eq i64 %19, %7
br i1 %20, label %21, label %10
21: ; preds = %18
%22 = tail call i32 @putchar(i32 10)
%23 = add nuw nsw i64 %9, 1
%24 = icmp eq i64 %23, %7
br i1 %24, label %25, label %8
25: ; preds = %21, %2
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%28 = load i32, i32* %3
switch i32 %28, label %38 [
i32 1, label %29
i32 2, label %32
i32 3, label %35
]
29: ; preds = %25
%30 = bitcast [10 x i32]* %0 to i32**
%31 = call i32 @suma_po_kolonama_i_redovima(i32** %30, i32 %1)
br label %40
32: ; preds = %25
%33 = bitcast [10 x i32]* %0 to i32**
%34 = call i32 @suma_po_dijagonalama(i32** %33, i32 %1)
br label %40
35: ; preds = %25
%36 = bitcast [10 x i32]* %0 to i32**
%37 = call i32 @suma_po_svakom_drugom(i32** %36, i32 %1)
br label %40
38: ; preds = %25
%39 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %40
40: ; preds = %38, %35, %32, %29
ret i32 undef
}