#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);
int sum2d(int **, int);
int /*<<< orphan*/ sum_cols(int **, int);
int /*<<< orphan*/ sum_rows(int **, int);
int main(int argc, char const *argv[]) {
  int junk[3][4] = {{2, 4, 6, 8}, {3, 5, 7, 9}, {12, 10, 8, 6}};
  sum_rows(junk, 3);
  sum_cols(junk, 3);
  printf("Sum of all elements = %d\n", sum2d(junk, 3));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x30,%edx
call   1050 <memcpy@plt>
lea    -0x40(%rbp),%rdi
mov    $0x3,%esi
call   1070 <sum_rows@plt>
lea    -0x40(%rbp),%rdi
mov    $0x3,%esi
call   1060 <sum_cols@plt>
lea    -0x40(%rbp),%rdi
mov    $0x3,%esi
call   1030 <sum2d@plt>
mov    %eax,%esi
lea    0xe82(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
movaps 0xed4(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe9c(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1060 <sum_rows@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1050 <sum_cols@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <sum2d@plt>
lea    0xe97(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.junk = [3 x [4 x i32]] [[4 x i32] [i32 2, i32 4, i32 6, i32 8], [4 x i32] [i32 3, i32 5, i32 7, i32 9], [4 x i32] [i32 12, i32 10, i32 8, i32 6]]
@.str = [26 x i8] c"Sum of all elements = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [3 x [4 x i32]]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = bitcast [3 x [4 x i32]]* %6 to i8*
%8 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %6, i64 0, i64 0
%9 = bitcast [4 x i32]* %8 to i32**
%10 = call i32 @sum_rows(i32** %9, i32 3)
%11 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %6, i64 0, i64 0
%12 = bitcast [4 x i32]* %11 to i32**
%13 = call i32 @sum_cols(i32** %12, i32 3)
%14 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %6, i64 0, i64 0
%15 = bitcast [4 x i32]* %14 to i32**
%16 = call i32 @sum2d(i32** %15, i32 3)
%17 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %16)
ret i32 0
}

LLVM IR (-O2):
@__const.main.junk = [3 x [4 x i32]] [[4 x i32] [i32 2, i32 4, i32 6, i32 8], [4 x i32] [i32 3, i32 5, i32 7, i32 9], [4 x i32] [i32 12, i32 10, i32 8, i32 6]]
@.str = [26 x i8] c"Sum of all elements = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [3 x [4 x i32]]
%4 = bitcast [3 x [4 x i32]]* %3 to i8*
%5 = bitcast [3 x [4 x i32]]* %3 to i32**
%6 = call i32 @sum_rows(i32** %5, i32 3)
%7 = call i32 @sum_cols(i32** %5, i32 3)
%8 = call i32 @sum2d(i32** %5, i32 3)
%9 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %8)
ret i32 0
}