int main(void) {
  int total1, total2, total3;
  int *pt1;
  int(*pt2)[4];
  pt1 = (int[2]){10, 20};
  pt2 = (int[2][4]){{1, 2, 3, -9}, {4, 5, 6, -8}};
  total1 = sum(pt1, 2);
  total2 = sum2d(pt2, 2);
  total3 = sum((int[]){4, 4, 4, 5, 5, 5}, 6);
  printf("tatal1 = %d\n", total1);
  printf("tatal2 = %d\n", total2);
  printf("tatal3 = %d\n", total3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x28(%rbp)
movl   $0x14,-0x24(%rbp)
lea    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2edc(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0x2ed9(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2ed6(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0x2ed3(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0x48(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1050 <sum@plt>
mov    %eax,-0x8(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1030 <sum2d@plt>
mov    %eax,-0xc(%rbp)
mov    0x2ea2(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0x2e9f(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0x2e9c(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    -0x60(%rbp),%rdi
mov    $0x6,%esi
mov    $0x0,%al
call   1050 <sum@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
movabs $0x140000000a,%rax
mov    %rax,0x8(%rsp)
movups 0xeb2(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movups 0xeb6(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
lea    0x8(%rsp),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <sum@plt>
mov    %eax,%r14d
lea    0x30(%rsp),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <sum2d@plt>
mov    %eax,%ebp
movups 0xe93(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    0xe97(%rip),%rax
mov    %rax,0x20(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1050 <sum@plt>
mov    %eax,%ebx
lea    0xe80(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe7c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe79(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@constinit = private global [2 x [4 x i32]] [[4 x i32] [i32 1, i32 2, i32 3, i32 -9], [4 x i32] [i32 4, i32 5, i32 6, i32 -8]]
@constinit.1 = private global [6 x i32] [i32 4, i32 4, i32 4, i32 5, i32 5, i32 5]
@.str = [13 x i8] c"tatal1 = %d\0A\00"
@.str.2 = [13 x i8] c"tatal2 = %d\0A\00"
@.str.3 = [13 x i8] c"tatal3 = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca [4 x i32]*
%7 = alloca [2 x i32]
%8 = alloca [2 x [4 x i32]]
%9 = alloca [6 x i32]
store i32 0, i32* %1
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
store i32 10, i32* %10
%11 = getelementptr inbounds i32, i32* %10, i64 1
store i32 20, i32* %11
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
store i32* %12, i32** %5
%13 = getelementptr inbounds [2 x [4 x i32]], [2 x [4 x i32]]* %8, i64 0, i64 0
%14 = bitcast [2 x [4 x i32]]* %8 to i8*
%15 = getelementptr inbounds [2 x [4 x i32]], [2 x [4 x i32]]* %8, i64 0, i64 0
store [4 x i32]* %15, [4 x i32]** %6
%16 = load i32*, i32** %5
%17 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @sum to i32 (i32*, i32, ...)*)(i32* %16, i32 2)
store i32 %17, i32* %2
%18 = load [4 x i32]*, [4 x i32]** %6
%19 = call i32 ([4 x i32]*, i32, ...) bitcast (i32 (...)* @sum2d to i32 ([4 x i32]*, i32, ...)*)([4 x i32]* %18, i32 2)
store i32 %19, i32* %3
%20 = getelementptr inbounds [6 x i32], [6 x i32]* %9, i64 0, i64 0
%21 = bitcast [6 x i32]* %9 to i8*
%22 = getelementptr inbounds [6 x i32], [6 x i32]* %9, i64 0, i64 0
%23 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @sum to i32 (i32*, i32, ...)*)(i32* %22, i32 6)
store i32 %23, i32* %4
%24 = load i32, i32* %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %3
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %4
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %28)
ret i32 0
}

LLVM IR (-O2):
@constinit = [2 x [4 x i32]] [[4 x i32] [i32 1, i32 2, i32 3, i32 -9], [4 x i32] [i32 4, i32 5, i32 6, i32 -8]]
@constinit.1 = [6 x i32] [i32 4, i32 4, i32 4, i32 5, i32 5, i32 5]
@.str = [13 x i8] c"tatal1 = %d\0A\00"
@.str.2 = [13 x i8] c"tatal2 = %d\0A\00"
@.str.3 = [13 x i8] c"tatal3 = %d\0A\00"
define i32 @main() {
%1 = alloca [2 x i32]
%2 = alloca [2 x [4 x i32]]
%3 = alloca [6 x i32]
%4 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
store i32 10, i32* %4
%5 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
store i32 20, i32* %5
%6 = bitcast [2 x [4 x i32]]* %2 to i8*
%7 = getelementptr inbounds [2 x [4 x i32]], [2 x [4 x i32]]* %2, i64 0, i64 0
%8 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @sum to i32 (i32*, i32, ...)*)(i32* %4, i32 2)
%9 = call i32 ([4 x i32]*, i32, ...) bitcast (i32 (...)* @sum2d to i32 ([4 x i32]*, i32, ...)*)([4 x i32]* %7, i32 2)
%10 = bitcast [6 x i32]* %3 to i8*
%11 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%12 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @sum to i32 (i32*, i32, ...)*)(i32* %11, i32 6)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %8)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %12)
ret i32 0
}