#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 filter(int **, int, int);
int main() {
  int A[10][10];
  int B[10][10];
  int S;
  int i, j;
  S = 0;
  for (i = 0; i < 10; i++) {
    for (j = 0; j < 10; j++) {
      B[i][j] = filter(A, i, j);
      S = S + A[i][j];
      ;
    };
  }
  S = S + 10;
  return 0;
  ;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x340,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x334(%rbp)
movl   $0x0,-0x338(%rbp)
cmpl   $0xa,-0x338(%rbp)
jge    11eb <main+0xdb>
movl   $0x0,-0x33c(%rbp)
cmpl   $0xa,-0x33c(%rbp)
jge    11d2 <main+0xc2>
lea    -0x1a0(%rbp),%rdi
mov    -0x338(%rbp),%esi
mov    -0x33c(%rbp),%edx
call   1030 <filter@plt>
mov    %eax,%edx
movslq -0x338(%rbp),%rcx
lea    -0x330(%rbp),%rax
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
movslq -0x33c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x334(%rbp),%eax
movslq -0x338(%rbp),%rdx
lea    -0x1a0(%rbp),%rcx
imul   $0x28,%rdx,%rdx
add    %rdx,%rcx
movslq -0x33c(%rbp),%rdx
add    (%rcx,%rdx,4),%eax
mov    %eax,-0x334(%rbp)
mov    -0x33c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x33c(%rbp)
jmp    114d <main+0x3d>
jmp    11d7 <main+0xc7>
mov    -0x338(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x338(%rbp)
jmp    1136 <main+0x26>
mov    -0x334(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x334(%rbp)
xor    %eax,%eax
add    $0x340,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x198,%rsp
xor    %ebx,%ebx
mov    %rsp,%r14
nop
mov    %r14,%rdi
mov    %ebx,%esi
xor    %edx,%edx
call   1030 <filter@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
call   1030 <filter@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x2,%edx
call   1030 <filter@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x3,%edx
call   1030 <filter@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x4,%edx
call   1030 <filter@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x5,%edx
call   1030 <filter@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x6,%edx
call   1030 <filter@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x7,%edx
call   1030 <filter@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x8,%edx
call   1030 <filter@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x9,%edx
call   1030 <filter@plt>
add    $0x1,%rbx
cmp    $0xa,%rbx
jne    1120 <main+0x10>
xor    %eax,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [10 x [10 x i32]]
%2 = bitcast [10 x [10 x i32]]* %1 to i8*
%3 = bitcast [10 x [10 x i32]]* %1 to i32**
br label %4
4: ; preds = %0, %4
%5 = phi i64 [ 0, %0 ], [ %17, %4 ]
%6 = trunc i64 %5 to i32
%7 = call i32 @filter(i32** %3, i32 %6, i32 0)
%8 = call i32 @filter(i32** %3, i32 %6, i32 1)
%9 = call i32 @filter(i32** %3, i32 %6, i32 2)
%10 = call i32 @filter(i32** %3, i32 %6, i32 3)
%11 = call i32 @filter(i32** %3, i32 %6, i32 4)
%12 = call i32 @filter(i32** %3, i32 %6, i32 5)
%13 = call i32 @filter(i32** %3, i32 %6, i32 6)
%14 = call i32 @filter(i32** %3, i32 %6, i32 7)
%15 = call i32 @filter(i32** %3, i32 %6, i32 8)
%16 = call i32 @filter(i32** %3, i32 %6, i32 9)
%17 = add nuw nsw i64 %5, 1
%18 = icmp eq i64 %17, 10
br i1 %18, label %19, label %4
19: ; preds = %4
ret i32 0
}