#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*/ fill(int *, int);
int /*<<< orphan*/ show(int *, int);
int /*<<< orphan*/ show2d(int **, int, int);
main() {
  int A[10 * 10], B[10][10], i, j, k = 0;
  fill(A, 10 * 10);
  show(A, 10 * 10);
  for (i = 0; i < 10; i++) {
    for (j = 0; j < 10; j++) {
      B[i][j] = A[k];
      k++;
    }
  }
  show2d(B, 10, 10);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x340,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x33c(%rbp)
lea    -0x1a0(%rbp),%rdi
mov    $0x64,%esi
call   1050 <fill@plt>
lea    -0x1a0(%rbp),%rdi
mov    $0x64,%esi
call   1040 <show@plt>
movl   $0x0,-0x334(%rbp)
cmpl   $0xa,-0x334(%rbp)
jge    1205 <main+0xd5>
movl   $0x0,-0x338(%rbp)
cmpl   $0xa,-0x338(%rbp)
jge    11ec <main+0xbc>
movslq -0x33c(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%edx
movslq -0x334(%rbp),%rcx
lea    -0x330(%rbp),%rax
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
movslq -0x338(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x33c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x33c(%rbp)
mov    -0x338(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x338(%rbp)
jmp    118f <main+0x5f>
jmp    11f1 <main+0xc1>
mov    -0x334(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x334(%rbp)
jmp    1178 <main+0x48>
lea    -0x330(%rbp),%rdi
mov    $0xa,%edx
mov    %edx,%esi
call   1030 <show2d@plt>
mov    -0x4(%rbp),%eax
add    $0x340,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x328,%rsp
lea    0x190(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1050 <fill@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1040 <show@plt>
mov    %rsp,%r14
mov    $0x190,%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <memcpy@plt>
mov    %r14,%rdi
mov    $0xa,%esi
mov    $0xa,%edx
call   1030 <show2d@plt>
xor    %eax,%eax
add    $0x328,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca [10 x [10 x i32]]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
%7 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%8 = call i32 @fill(i32* %7, i32 100)
%9 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%10 = call i32 @show(i32* %9, i32 100)
store i32 0, i32* %4
br label %11
11: ; preds = %35, %0
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 10
br i1 %13, label %14, label %38
14: ; preds = %11
store i32 0, i32* %5
br label %15
15: ; preds = %31, %14
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 10
br i1 %17, label %18, label %34
18: ; preds = %15
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %3, i64 0, i64 %24
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %25, i64 0, i64 %27
store i32 %22, i32* %28
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %31
31: ; preds = %18
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %15
34: ; preds = %15
br label %35
35: ; preds = %34
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
br label %11
38: ; preds = %11
%39 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %3, i64 0, i64 0
%40 = bitcast [10 x i32]* %39 to i32**
%41 = call i32 @show2d(i32** %40, i32 10, i32 10)
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [100 x i32]
%2 = bitcast [100 x i32]* %1 to i8*
%3 = alloca [10 x [10 x i32]]
%4 = bitcast [10 x [10 x i32]]* %3 to i8*
%5 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%6 = call i32 @fill(i32* %5, i32 100)
%7 = call i32 @show(i32* %5, i32 100)
%8 = bitcast [10 x [10 x i32]]* %3 to i32**
%9 = call i32 @show2d(i32** %8, i32 10, i32 10)
ret i32 0
}