#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 calcZeroVal(int, int);
int /*<<< orphan*/ printf(char *, ...);
void calc_calibration(int calibration[4][2], int adc_result_1[4][5],
                      int adc_result_2[4][5]) {
  int i, j;
  for (i = 0; i < 4; i++)
    for (j = 0; j < 2; j++)
      calibration[i][j] = 0;
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 5; j++) {
      if (i % 2)
        adc_result_1[i][j] =
            calcZeroVal(adc_result_1[i][j], adc_result_1[0][j]);
      else
        adc_result_2[i][j] =
            calcZeroVal(adc_result_2[i][j], adc_result_2[1][j]);
    }
  }
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 5; j++) {
      if (i % 2 == 0) {
        calibration[i][0] = adc_result_2[i][j] + calibration[i][0];
        calibration[i][1] = adc_result_1[i][j] + calibration[i][1];
      } else {
        calibration[i][0] = adc_result_1[i][j] + calibration[i][0];
        calibration[i][1] = adc_result_2[i][j] + calibration[i][1];
      }
    }
  }
  printf("Calculated Calibration values [");
  for (j = 0; j < 2; j++) {
    for (i = 0; i < 4; i++) {
      calibration[i][j] = (calibration[i][j] / 5);
      printf("0x%x", calibration[i][j]);
      if ((i == 4 - 1) && (j == 1))
        printf("]\n");
      else
        printf(", ");
    }
  }
}


x86 assembly (clang, -O0):
<calc_calibration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    1191 <calc_calibration+0x71>
movl   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x20(%rbp)
jge    117e <calc_calibration+0x5e>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114c <calc_calibration+0x2c>
jmp    1183 <calc_calibration+0x63>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113b <calc_calibration+0x1b>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    126f <calc_calibration+0x14f>
movl   $0x0,-0x20(%rbp)
cmpl   $0x5,-0x20(%rbp)
jge    125c <calc_calibration+0x13c>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     120a <calc_calibration+0xea>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1040 <calcZeroVal@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    1249 <calc_calibration+0x129>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    0x14(%rax,%rcx,4),%esi
call   1040 <calcZeroVal@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    124e <calc_calibration+0x12e>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a9 <calc_calibration+0x89>
jmp    1261 <calc_calibration+0x141>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1198 <calc_calibration+0x78>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    1384 <calc_calibration+0x264>
movl   $0x0,-0x20(%rbp)
cmpl   $0x5,-0x20(%rbp)
jge    1371 <calc_calibration+0x251>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1304 <calc_calibration+0x1e4>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    (%rax,%rcx,8),%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    0x4(%rax,%rcx,8),%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,0x4(%rax,%rcx,8)
jmp    135e <calc_calibration+0x23e>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    (%rax,%rcx,8),%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    0x4(%rax,%rcx,8),%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,0x4(%rax,%rcx,8)
jmp    1363 <calc_calibration+0x243>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1287 <calc_calibration+0x167>
jmp    1376 <calc_calibration+0x256>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1276 <calc_calibration+0x156>
lea    0xc75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x20(%rbp)
jge    1469 <calc_calibration+0x349>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    1456 <calc_calibration+0x336>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xc19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x3,-0x1c(%rbp)
jne    1435 <calc_calibration+0x315>
cmpl   $0x1,-0x20(%rbp)
jne    1435 <calc_calibration+0x315>
lea    0xbfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1443 <calc_calibration+0x323>
lea    0xbec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1448 <calc_calibration+0x328>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    13aa <calc_calibration+0x28a>
jmp    145b <calc_calibration+0x33b>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1399 <calc_calibration+0x279>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_calibration>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x10(%rdi)
mov    %rdi,(%rsp)
movups %xmm0,(%rdi)
lea    0x4(%rsi),%rax
mov    %rax,0x48(%rsp)
lea    0x8(%rsi),%rax
mov    %rax,0x40(%rsp)
lea    0xc(%rsi),%rax
mov    %rax,0x38(%rsp)
lea    0x10(%rsi),%rax
mov    %rax,0x30(%rsp)
lea    0x14(%rdx),%rax
mov    %rax,0x28(%rsp)
lea    0x18(%rdx),%rax
mov    %rax,0x20(%rsp)
lea    0x1c(%rdx),%rax
mov    %rax,0x18(%rsp)
lea    0x20(%rdx),%rax
mov    %rax,0x10(%rsp)
lea    0x24(%rdx),%rax
mov    %rax,0x8(%rsp)
mov    $0x10,%r13d
xor    %r12d,%r12d
mov    %rdx,0x58(%rsp)
mov    %rsi,0x50(%rsp)
test   $0x1,%r12b
mov    %rsi,%r15
cmove  %rdx,%r15
cmove  0x28(%rsp),%rsi
mov    0x48(%rsp),%rbx
cmove  0x20(%rsp),%rbx
mov    0x40(%rsp),%r14
cmove  0x18(%rsp),%r14
mov    0x38(%rsp),%rbp
cmove  0x10(%rsp),%rbp
mov    0x30(%rsp),%rcx
cmove  0x8(%rsp),%rcx
mov    %rcx,0x60(%rsp)
mov    -0x10(%r15,%r13,1),%edi
mov    (%rsi),%esi
call   1050 <calcZeroVal@plt>
mov    %eax,-0x10(%r15,%r13,1)
mov    -0xc(%r15,%r13,1),%edi
mov    (%rbx),%esi
call   1050 <calcZeroVal@plt>
mov    %eax,-0xc(%r15,%r13,1)
mov    -0x8(%r15,%r13,1),%edi
mov    (%r14),%esi
call   1050 <calcZeroVal@plt>
mov    %eax,-0x8(%r15,%r13,1)
mov    -0x4(%r15,%r13,1),%edi
mov    0x0(%rbp),%esi
call   1050 <calcZeroVal@plt>
mov    %eax,-0x4(%r15,%r13,1)
mov    (%r15,%r13,1),%edi
mov    0x60(%rsp),%rax
mov    (%rax),%esi
call   1050 <calcZeroVal@plt>
mov    0x50(%rsp),%rsi
mov    0x58(%rsp),%rdx
mov    %eax,(%r15,%r13,1)
add    $0x1,%r12
add    $0x14,%r13
cmp    $0x4,%r12
jne    11b0 <calc_calibration+0x80>
xor    %eax,%eax
xor    %ecx,%ecx
mov    (%rsp),%r12
test   $0x1,%cl
mov    %rsi,%rbx
cmove  %rdx,%rbx
mov    %rdx,%r8
cmove  %rsi,%r8
mov    (%r12,%rcx,8),%edi
add    (%rbx,%rax,1),%edi
mov    0x4(%r12,%rcx,8),%ebp
mov    %edi,(%r12,%rcx,8)
add    (%r8,%rax,1),%ebp
mov    %ebp,0x4(%r12,%rcx,8)
add    0x4(%rbx,%rax,1),%edi
mov    %edi,(%r12,%rcx,8)
add    0x4(%r8,%rax,1),%ebp
mov    %ebp,0x4(%r12,%rcx,8)
add    0x8(%rbx,%rax,1),%edi
mov    %edi,(%r12,%rcx,8)
add    0x8(%r8,%rax,1),%ebp
mov    %ebp,0x4(%r12,%rcx,8)
add    0xc(%rbx,%rax,1),%edi
mov    %edi,(%r12,%rcx,8)
add    0xc(%r8,%rax,1),%ebp
mov    %ebp,0x4(%r12,%rcx,8)
add    0x10(%rbx,%rax,1),%edi
mov    %edi,(%r12,%rcx,8)
add    0x10(%r8,%rax,1),%ebp
mov    %ebp,0x4(%r12,%rcx,8)
add    $0x1,%rcx
add    $0x14,%rax
cmp    $0x50,%rax
jne    1270 <calc_calibration+0x140>
lea    0xd09(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq (%r12),%rax
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x21,%rsi
add    %eax,%esi
mov    %esi,(%r12)
lea    0xcff(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xcf3(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x8(%r12),%rax
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x21,%rsi
add    %eax,%esi
mov    %esi,0x8(%r12)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x10(%r12),%rax
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x21,%rsi
add    %eax,%esi
mov    %esi,0x10(%r12)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x18(%r12),%rax
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x21,%rsi
add    %eax,%esi
mov    %esi,0x18(%r12)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x4(%r12),%rax
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x21,%rsi
add    %eax,%esi
mov    %esi,0x4(%r12)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0xc(%r12),%rax
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x21,%rsi
add    %eax,%esi
mov    %esi,0xc(%r12)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x14(%r12),%rax
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x21,%rsi
add    %eax,%esi
mov    %esi,0x14(%r12)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x1c(%r12),%rax
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x21,%rsi
add    %eax,%esi
mov    %esi,0x1c(%r12)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xb91(%rip),%rdi
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"Calculated Calibration values [\00"
@.str.1 = [5 x i8] c"0x%x\00"
@.str.2 = [3 x i8] c"]\0A\00"
@.str.3 = [3 x i8] c", \00"
define void @calc_calibration([2 x i32]* %0, [5 x i32]* %1, [5 x i32]* %2) {
%4 = alloca [2 x i32]*
%5 = alloca [5 x i32]*
%6 = alloca [5 x i32]*
%7 = alloca i32
%8 = alloca i32
store [2 x i32]* %0, [2 x i32]** %4
store [5 x i32]* %1, [5 x i32]** %5
store [5 x i32]* %2, [5 x i32]** %6
store i32 0, i32* %7
br label %9
9: ; preds = %28, %3
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %31
12: ; preds = %9
store i32 0, i32* %8
br label %13
13: ; preds = %24, %12
%14 = load i32, i32* %8
%15 = icmp slt i32 %14, 2
br i1 %15, label %16, label %27
16: ; preds = %13
%17 = load [2 x i32]*, [2 x i32]** %4
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %17, i64 %19
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [2 x i32], [2 x i32]* %20, i64 0, i64 %22
store i32 0, i32* %23
br label %24
24: ; preds = %16
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
br label %13
27: ; preds = %13
br label %28
28: ; preds = %27
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %9
31: ; preds = %9
store i32 0, i32* %7
br label %32
32: ; preds = %94, %31
%33 = load i32, i32* %7
%34 = icmp slt i32 %33, 4
br i1 %34, label %35, label %97
35: ; preds = %32
store i32 0, i32* %8
br label %36
36: ; preds = %90, %35
%37 = load i32, i32* %8
%38 = icmp slt i32 %37, 5
br i1 %38, label %39, label %93
39: ; preds = %36
%40 = load i32, i32* %7
%41 = srem i32 %40, 2
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %66
43: ; preds = %39
%44 = load [5 x i32]*, [5 x i32]** %5
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [5 x i32], [5 x i32]* %44, i64 %46
%48 = load i32, i32* %8
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [5 x i32], [5 x i32]* %47, i64 0, i64 %49
%51 = load i32, i32* %50
%52 = load [5 x i32]*, [5 x i32]** %5
%53 = getelementptr inbounds [5 x i32], [5 x i32]* %52, i64 0
%54 = load i32, i32* %8
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [5 x i32], [5 x i32]* %53, i64 0, i64 %55
%57 = load i32, i32* %56
%58 = call i32 @calcZeroVal(i32 %51, i32 %57)
%59 = load [5 x i32]*, [5 x i32]** %5
%60 = load i32, i32* %7
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [5 x i32], [5 x i32]* %59, i64 %61
%63 = load i32, i32* %8
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [5 x i32], [5 x i32]* %62, i64 0, i64 %64
store i32 %58, i32* %65
br label %89
66: ; preds = %39
%67 = load [5 x i32]*, [5 x i32]** %6
%68 = load i32, i32* %7
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [5 x i32], [5 x i32]* %67, i64 %69
%71 = load i32, i32* %8
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [5 x i32], [5 x i32]* %70, i64 0, i64 %72
%74 = load i32, i32* %73
%75 = load [5 x i32]*, [5 x i32]** %6
%76 = getelementptr inbounds [5 x i32], [5 x i32]* %75, i64 1
%77 = load i32, i32* %8
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [5 x i32], [5 x i32]* %76, i64 0, i64 %78
%80 = load i32, i32* %79
%81 = call i32 @calcZeroVal(i32 %74, i32 %80)
%82 = load [5 x i32]*, [5 x i32]** %6
%83 = load i32, i32* %7
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [5 x i32], [5 x i32]* %82, i64 %84
%86 = load i32, i32* %8
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [5 x i32], [5 x i32]* %85, i64 0, i64 %87
store i32 %81, i32* %88
br label %89
89: ; preds = %66, %43
br label %90
90: ; preds = %89
%91 = load i32, i32* %8
%92 = add nsw i32 %91, 1
store i32 %92, i32* %8
br label %36
93: ; preds = %36
br label %94
94: ; preds = %93
%95 = load i32, i32* %7
%96 = add nsw i32 %95, 1
store i32 %96, i32* %7
br label %32
97: ; preds = %32
store i32 0, i32* %7
br label %98
98: ; preds = %196, %97
%99 = load i32, i32* %7
%100 = icmp slt i32 %99, 4
br i1 %100, label %101, label %199
101: ; preds = %98
store i32 0, i32* %8
br label %102
102: ; preds = %192, %101
%103 = load i32, i32* %8
%104 = icmp slt i32 %103, 5
br i1 %104, label %105, label %195
105: ; preds = %102
%106 = load i32, i32* %7
%107 = srem i32 %106, 2
%108 = icmp eq i32 %107, 0
br i1 %108, label %109, label %150
109: ; preds = %105
%110 = load [5 x i32]*, [5 x i32]** %6
%111 = load i32, i32* %7
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds [5 x i32], [5 x i32]* %110, i64 %112
%114 = load i32, i32* %8
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds [5 x i32], [5 x i32]* %113, i64 0, i64 %115
%117 = load i32, i32* %116
%118 = load [2 x i32]*, [2 x i32]** %4
%119 = load i32, i32* %7
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds [2 x i32], [2 x i32]* %118, i64 %120
%122 = getelementptr inbounds [2 x i32], [2 x i32]* %121, i64 0, i64 0
%123 = load i32, i32* %122
%124 = add nsw i32 %117, %123
%125 = load [2 x i32]*, [2 x i32]** %4
%126 = load i32, i32* %7
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds [2 x i32], [2 x i32]* %125, i64 %127
%129 = getelementptr inbounds [2 x i32], [2 x i32]* %128, i64 0, i64 0
store i32 %124, i32* %129
%130 = load [5 x i32]*, [5 x i32]** %5
%131 = load i32, i32* %7
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds [5 x i32], [5 x i32]* %130, i64 %132
%134 = load i32, i32* %8
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds [5 x i32], [5 x i32]* %133, i64 0, i64 %135
%137 = load i32, i32* %136
%138 = load [2 x i32]*, [2 x i32]** %4
%139 = load i32, i32* %7
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds [2 x i32], [2 x i32]* %138, i64 %140
%142 = getelementptr inbounds [2 x i32], [2 x i32]* %141, i64 0, i64 1
%143 = load i32, i32* %142
%144 = add nsw i32 %137, %143
%145 = load [2 x i32]*, [2 x i32]** %4
%146 = load i32, i32* %7
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds [2 x i32], [2 x i32]* %145, i64 %147
%149 = getelementptr inbounds [2 x i32], [2 x i32]* %148, i64 0, i64 1
store i32 %144, i32* %149
br label %191
150: ; preds = %105
%151 = load [5 x i32]*, [5 x i32]** %5
%152 = load i32, i32* %7
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds [5 x i32], [5 x i32]* %151, i64 %153
%155 = load i32, i32* %8
%156 = sext i32 %155 to i64
%157 = getelementptr inbounds [5 x i32], [5 x i32]* %154, i64 0, i64 %156
%158 = load i32, i32* %157
%159 = load [2 x i32]*, [2 x i32]** %4
%160 = load i32, i32* %7
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds [2 x i32], [2 x i32]* %159, i64 %161
%163 = getelementptr inbounds [2 x i32], [2 x i32]* %162, i64 0, i64 0
%164 = load i32, i32* %163
%165 = add nsw i32 %158, %164
%166 = load [2 x i32]*, [2 x i32]** %4
%167 = load i32, i32* %7
%168 = sext i32 %167 to i64
%169 = getelementptr inbounds [2 x i32], [2 x i32]* %166, i64 %168
%170 = getelementptr inbounds [2 x i32], [2 x i32]* %169, i64 0, i64 0
store i32 %165, i32* %170
%171 = load [5 x i32]*, [5 x i32]** %6
%172 = load i32, i32* %7
%173 = sext i32 %172 to i64
%174 = getelementptr inbounds [5 x i32], [5 x i32]* %171, i64 %173
%175 = load i32, i32* %8
%176 = sext i32 %175 to i64
%177 = getelementptr inbounds [5 x i32], [5 x i32]* %174, i64 0, i64 %176
%178 = load i32, i32* %177
%179 = load [2 x i32]*, [2 x i32]** %4
%180 = load i32, i32* %7
%181 = sext i32 %180 to i64
%182 = getelementptr inbounds [2 x i32], [2 x i32]* %179, i64 %181
%183 = getelementptr inbounds [2 x i32], [2 x i32]* %182, i64 0, i64 1
%184 = load i32, i32* %183
%185 = add nsw i32 %178, %184
%186 = load [2 x i32]*, [2 x i32]** %4
%187 = load i32, i32* %7
%188 = sext i32 %187 to i64
%189 = getelementptr inbounds [2 x i32], [2 x i32]* %186, i64 %188
%190 = getelementptr inbounds [2 x i32], [2 x i32]* %189, i64 0, i64 1
store i32 %185, i32* %190
br label %191
191: ; preds = %150, %109
br label %192
192: ; preds = %191
%193 = load i32, i32* %8
%194 = add nsw i32 %193, 1
store i32 %194, i32* %8
br label %102
195: ; preds = %102
br label %196
196: ; preds = %195
%197 = load i32, i32* %7
%198 = add nsw i32 %197, 1
store i32 %198, i32* %7
br label %98
199: ; preds = %98
%200 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %8
br label %201
201: ; preds = %248, %199
%202 = load i32, i32* %8
%203 = icmp slt i32 %202, 2
br i1 %203, label %204, label %251
204: ; preds = %201
store i32 0, i32* %7
br label %205
205: ; preds = %244, %204
%206 = load i32, i32* %7
%207 = icmp slt i32 %206, 4
br i1 %207, label %208, label %247
208: ; preds = %205
%209 = load [2 x i32]*, [2 x i32]** %4
%210 = load i32, i32* %7
%211 = sext i32 %210 to i64
%212 = getelementptr inbounds [2 x i32], [2 x i32]* %209, i64 %211
%213 = load i32, i32* %8
%214 = sext i32 %213 to i64
%215 = getelementptr inbounds [2 x i32], [2 x i32]* %212, i64 0, i64 %214
%216 = load i32, i32* %215
%217 = sdiv i32 %216, 5
%218 = load [2 x i32]*, [2 x i32]** %4
%219 = load i32, i32* %7
%220 = sext i32 %219 to i64
%221 = getelementptr inbounds [2 x i32], [2 x i32]* %218, i64 %220
%222 = load i32, i32* %8
%223 = sext i32 %222 to i64
%224 = getelementptr inbounds [2 x i32], [2 x i32]* %221, i64 0, i64 %223
store i32 %217, i32* %224
%225 = load [2 x i32]*, [2 x i32]** %4
%226 = load i32, i32* %7
%227 = sext i32 %226 to i64
%228 = getelementptr inbounds [2 x i32], [2 x i32]* %225, i64 %227
%229 = load i32, i32* %8
%230 = sext i32 %229 to i64
%231 = getelementptr inbounds [2 x i32], [2 x i32]* %228, i64 0, i64 %230
%232 = load i32, i32* %231
%233 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %232)
%234 = load i32, i32* %7
%235 = icmp eq i32 %234, 3
br i1 %235, label %236, label %241
236: ; preds = %208
%237 = load i32, i32* %8
%238 = icmp eq i32 %237, 1
br i1 %238, label %239, label %241
239: ; preds = %236
%240 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %243
241: ; preds = %236, %208
%242 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %243
243: ; preds = %241, %239
br label %244
244: ; preds = %243
%245 = load i32, i32* %7
%246 = add nsw i32 %245, 1
store i32 %246, i32* %7
br label %205
247: ; preds = %205
br label %248
248: ; preds = %247
%249 = load i32, i32* %8
%250 = add nsw i32 %249, 1
store i32 %250, i32* %8
br label %201
251: ; preds = %201
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"Calculated Calibration values [\00"
@.str.1 = [5 x i8] c"0x%x\00"
@.str.3 = [3 x i8] c", \00"
@str = [2 x i8] c"]\00"
define void @calc_calibration([2 x i32]* nocapture %0, [5 x i32]* nocapture %1, [5 x i32]* nocapture %2) {
%4 = bitcast [2 x i32]* %0 to i8*
%5 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%6 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 1
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 2
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 3
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
%10 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 1, i64 0
%11 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 1, i64 1
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 1, i64 2
%13 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 1, i64 3
%14 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 1, i64 4
br label %15
15: ; preds = %3, %15
%16 = phi i64 [ 0, %3 ], [ %45, %15 ]
%17 = and i64 %16, 1
%18 = icmp eq i64 %17, 0
%19 = select i1 %18, [5 x i32]* %2, [5 x i32]* %1
%20 = select i1 %18, i32* %10, i32* %5
%21 = select i1 %18, i32* %11, i32* %6
%22 = select i1 %18, i32* %12, i32* %7
%23 = select i1 %18, i32* %13, i32* %8
%24 = select i1 %18, i32* %14, i32* %9
%25 = getelementptr inbounds [5 x i32], [5 x i32]* %19, i64 %16, i64 0
%26 = load i32, i32* %25
%27 = load i32, i32* %20
%28 = tail call i32 @calcZeroVal(i32 %26, i32 %27)
store i32 %28, i32* %25
%29 = getelementptr inbounds [5 x i32], [5 x i32]* %19, i64 %16, i64 1
%30 = load i32, i32* %29
%31 = load i32, i32* %21
%32 = tail call i32 @calcZeroVal(i32 %30, i32 %31)
store i32 %32, i32* %29
%33 = getelementptr inbounds [5 x i32], [5 x i32]* %19, i64 %16, i64 2
%34 = load i32, i32* %33
%35 = load i32, i32* %22
%36 = tail call i32 @calcZeroVal(i32 %34, i32 %35)
store i32 %36, i32* %33
%37 = getelementptr inbounds [5 x i32], [5 x i32]* %19, i64 %16, i64 3
%38 = load i32, i32* %37
%39 = load i32, i32* %23
%40 = tail call i32 @calcZeroVal(i32 %38, i32 %39)
store i32 %40, i32* %37
%41 = getelementptr inbounds [5 x i32], [5 x i32]* %19, i64 %16, i64 4
%42 = load i32, i32* %41
%43 = load i32, i32* %24
%44 = tail call i32 @calcZeroVal(i32 %42, i32 %43)
store i32 %44, i32* %41
%45 = add nuw nsw i64 %16, 1
%46 = icmp eq i64 %45, 4
br i1 %46, label %47, label %15
47: ; preds = %15, %47
%48 = phi i64 [ %93, %47 ], [ 0, %15 ]
%49 = and i64 %48, 1
%50 = icmp eq i64 %49, 0
%51 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 %48, i64 0
%52 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 %48, i64 1
%53 = select i1 %50, [5 x i32]* %2, [5 x i32]* %1
%54 = select i1 %50, [5 x i32]* %1, [5 x i32]* %2
%55 = getelementptr inbounds [5 x i32], [5 x i32]* %53, i64 %48, i64 0
%56 = load i32, i32* %55
%57 = load i32, i32* %51
%58 = add nsw i32 %57, %56
store i32 %58, i32* %51
%59 = getelementptr inbounds [5 x i32], [5 x i32]* %54, i64 %48, i64 0
%60 = load i32, i32* %59
%61 = load i32, i32* %52
%62 = add nsw i32 %61, %60
store i32 %62, i32* %52
%63 = getelementptr inbounds [5 x i32], [5 x i32]* %53, i64 %48, i64 1
%64 = load i32, i32* %63
%65 = add nsw i32 %58, %64
store i32 %65, i32* %51
%66 = getelementptr inbounds [5 x i32], [5 x i32]* %54, i64 %48, i64 1
%67 = load i32, i32* %66
%68 = add nsw i32 %62, %67
store i32 %68, i32* %52
%69 = select i1 %50, [5 x i32]* %2, [5 x i32]* %1
%70 = select i1 %50, [5 x i32]* %1, [5 x i32]* %2
%71 = getelementptr inbounds [5 x i32], [5 x i32]* %69, i64 %48, i64 2
%72 = load i32, i32* %71
%73 = add nsw i32 %65, %72
store i32 %73, i32* %51
%74 = getelementptr inbounds [5 x i32], [5 x i32]* %70, i64 %48, i64 2
%75 = load i32, i32* %74
%76 = add nsw i32 %68, %75
store i32 %76, i32* %52
%77 = select i1 %50, [5 x i32]* %2, [5 x i32]* %1
%78 = select i1 %50, [5 x i32]* %1, [5 x i32]* %2
%79 = getelementptr inbounds [5 x i32], [5 x i32]* %77, i64 %48, i64 3
%80 = load i32, i32* %79
%81 = add nsw i32 %73, %80
store i32 %81, i32* %51
%82 = getelementptr inbounds [5 x i32], [5 x i32]* %78, i64 %48, i64 3
%83 = load i32, i32* %82
%84 = add nsw i32 %76, %83
store i32 %84, i32* %52
%85 = select i1 %50, [5 x i32]* %2, [5 x i32]* %1
%86 = select i1 %50, [5 x i32]* %1, [5 x i32]* %2
%87 = getelementptr inbounds [5 x i32], [5 x i32]* %85, i64 %48, i64 4
%88 = load i32, i32* %87
%89 = add nsw i32 %81, %88
store i32 %89, i32* %51
%90 = getelementptr inbounds [5 x i32], [5 x i32]* %86, i64 %48, i64 4
%91 = load i32, i32* %90
%92 = add nsw i32 %84, %91
store i32 %92, i32* %52
%93 = add nuw nsw i64 %48, 1
%94 = icmp eq i64 %93, 4
br i1 %94, label %95, label %47
95: ; preds = %47
%96 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%97 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 0, i64 0
%98 = load i32, i32* %97
%99 = sdiv i32 %98, 5
store i32 %99, i32* %97
%100 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %99)
%101 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%102 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 1, i64 0
%103 = load i32, i32* %102
%104 = sdiv i32 %103, 5
%105 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 1, i64 0
store i32 %104, i32* %105
%106 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %104)
%107 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%108 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 2, i64 0
%109 = load i32, i32* %108
%110 = sdiv i32 %109, 5
%111 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 2, i64 0
store i32 %110, i32* %111
%112 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %110)
%113 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%114 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 3, i64 0
%115 = load i32, i32* %114
%116 = sdiv i32 %115, 5
%117 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 3, i64 0
store i32 %116, i32* %117
%118 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %116)
%119 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%120 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 0, i64 1
%121 = load i32, i32* %120
%122 = sdiv i32 %121, 5
%123 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 0, i64 1
store i32 %122, i32* %123
%124 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %122)
%125 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%126 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 1, i64 1
%127 = load i32, i32* %126
%128 = sdiv i32 %127, 5
%129 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 1, i64 1
store i32 %128, i32* %129
%130 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %128)
%131 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%132 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 2, i64 1
%133 = load i32, i32* %132
%134 = sdiv i32 %133, 5
%135 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 2, i64 1
store i32 %134, i32* %135
%136 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %134)
%137 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%138 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 3, i64 1
%139 = load i32, i32* %138
%140 = sdiv i32 %139, 5
%141 = getelementptr inbounds [2 x i32], [2 x i32]* %0, i64 3, i64 1
store i32 %140, i32* %141
%142 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %140)
%143 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
}