#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 main() {
  while (1) {
    int row, col, temp;
    printf("Enter the upper limit of row:- ");
    scanf("%d", &row);
    printf("Enter the upper limit of col:- ");
    scanf("%d", &col);
    int ARR[row][col];
    int rowpos, colpos;
    printf("Enter the row number and column number respectively :- ");
    scanf("%d %d", &rowpos, &colpos);
    unsigned int val1;
    printf("Enter base address : ");
    scanf("%d", &val1);
    int row_add, col_add;
    row_add = val1 + (col * rowpos + colpos) * sizeof(int);
    printf("%u\n", row_add);
    printf("\n");
    printf("Address of your desird position in column order = ");
    col_add = val1 + (row * colpos + rowpos) * sizeof(int);
    printf("%u\n\n", col_add);
    printf("\tTo know more address enter :-1 \n \tPress 0 to exit ");
    scanf("%d", &temp);
    if (temp == 0) {
      return 0;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf37(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf17(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
mov    %rsp,%rdx
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %rax,-0x28(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
lea    -0x2c(%rbp),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebc(%rip),%rdi
lea    -0x34(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x34(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0x2c(%rbp),%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%esi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
mov    -0x8(%rbp),%ecx
imul   -0x30(%rbp),%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%esi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe2a(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x0,-0x10(%rbp)
jne    1279 <main+0x159>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x40(%rbp)
jmp    1280 <main+0x160>
movl   $0x0,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x40(%rbp),%eax
test   %eax,%eax
je     129c <main+0x17c>
jmp    1297 <main+0x177>
jmp    12a1 <main+0x181>
jmp    112f <main+0xf>
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xf36(%rip),%rbx
lea    0xf4c(%rip),%r15
lea    0xf78(%rip),%r12
lea    0xf76(%rip),%r13
lea    0xc(%rsp),%rbp
nop
lea    0xe99(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %rsp,%r14
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec6(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x8(%rsp),%esi
imul   0x10(%rsp),%esi
add    0x4(%rsp),%esi
shl    $0x2,%esi
add    (%rsp),%esi
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
imul   0x14(%rsp),%esi
add    0x8(%rsp),%esi
shl    $0x2,%esi
add    (%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
mov    %r14,%rsp
jne    1160 <main+0x30>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Enter the upper limit of row:- \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"Enter the upper limit of col:- \00"
@.str.3 = [56 x i8] c"Enter the row number and column number respectively :- \00"
@.str.4 = [6 x i8] c"%d %d\00"
@.str.5 = [22 x i8] c"Enter base address : \00"
@.str.6 = [4 x i8] c"%u\0A\00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [51 x i8] c"Address of your desird position in column order = \00"
@.str.9 = [5 x i8] c"%u\0A\0A\00"
@.str.10 = [52 x i8] c"\09To know more address enter :-1 \0A \09Press 0 to exit \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %1
br label %14
14: ; preds = %0, %67
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%19 = load i32, i32* %2
%20 = zext i32 %19 to i64
%21 = load i32, i32* %3
%22 = zext i32 %21 to i64
%23 = call i8* @llvm.stacksave()
store i8* %23, i8** %5
%24 = mul nuw i64 %20, %22
%25 = alloca i32, i64 %24
store i64 %20, i64* %6
store i64 %22, i64* %7
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %8, i32* %9)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%30 = load i32, i32* %10
%31 = zext i32 %30 to i64
%32 = load i32, i32* %3
%33 = load i32, i32* %8
%34 = mul nsw i32 %32, %33
%35 = load i32, i32* %9
%36 = add nsw i32 %34, %35
%37 = sext i32 %36 to i64
%38 = mul i64 %37, 4
%39 = add i64 %31, %38
%40 = trunc i64 %39 to i32
store i32 %40, i32* %11
%41 = load i32, i32* %11
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %41)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.8, i64 0, i64 0))
%45 = load i32, i32* %10
%46 = zext i32 %45 to i64
%47 = load i32, i32* %2
%48 = load i32, i32* %9
%49 = mul nsw i32 %47, %48
%50 = load i32, i32* %8
%51 = add nsw i32 %49, %50
%52 = sext i32 %51 to i64
%53 = mul i64 %52, 4
%54 = add i64 %46, %53
%55 = trunc i64 %54 to i32
store i32 %55, i32* %12
%56 = load i32, i32* %12
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 %56)
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.10, i64 0, i64 0))
%59 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%60 = load i32, i32* %4
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %63
62: ; preds = %14
store i32 0, i32* %1
store i32 1, i32* %13
br label %64
63: ; preds = %14
store i32 0, i32* %13
br label %64
64: ; preds = %63, %62
%65 = load i8*, i8** %5
%66 = load i32, i32* %13
switch i32 %66, label %70 [
i32 0, label %67
i32 1, label %68
]
67: ; preds = %64
br label %14
68: ; preds = %64
%69 = load i32, i32* %1
ret i32 %69
70: ; preds = %64
unreachable
}

LLVM IR (-O2):
@.str = [32 x i8] c"Enter the upper limit of row:- \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"Enter the upper limit of col:- \00"
@.str.3 = [56 x i8] c"Enter the row number and column number respectively :- \00"
@.str.4 = [6 x i8] c"%d %d\00"
@.str.5 = [22 x i8] c"Enter base address : \00"
@.str.6 = [4 x i8] c"%u\0A\00"
@.str.8 = [51 x i8] c"Address of your desird position in column order = \00"
@.str.9 = [5 x i8] c"%u\0A\0A\00"
@.str.10 = [52 x i8] c"\09To know more address enter :-1 \0A \09Press 0 to exit \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %1 to i8*
%8 = bitcast i32* %2 to i8*
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = bitcast i32* %6 to i8*
br label %13
13: ; preds = %13, %0
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%18 = call i8* @llvm.stacksave()
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %4, i32* %5)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%23 = load i32, i32* %6
%24 = load i32, i32* %2
%25 = load i32, i32* %4
%26 = mul nsw i32 %25, %24
%27 = load i32, i32* %5
%28 = add nsw i32 %26, %27
%29 = shl i32 %28, 2
%30 = add i32 %29, %23
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %30)
%32 = call i32 @putchar(i32 10)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.8, i64 0, i64 0))
%34 = load i32, i32* %6
%35 = load i32, i32* %1
%36 = load i32, i32* %5
%37 = mul nsw i32 %36, %35
%38 = load i32, i32* %4
%39 = add nsw i32 %37, %38
%40 = shl i32 %39, 2
%41 = add i32 %40, %34
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 %41)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.10, i64 0, i64 0))
%44 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%45 = load i32, i32* %3
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %13
47: ; preds = %13
ret i32 0
}