#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);
float findHeading(int optionMatrix[240][520]) {
  int x_offset_min_l;
  int x_offset_max_l;
  int y_offset_min_l;
  int y_offset_max_l;
  x_offset_min_l = 0;
  x_offset_max_l = 120;
  y_offset_min_l = 0;
  y_offset_max_l = 173;
  int x_offset_min_m;
  int x_offset_max_m;
  int y_offset_min_m;
  int y_offset_max_m;
  x_offset_min_m = 0;
  x_offset_max_m = 120;
  y_offset_min_m = 174;
  y_offset_max_m = 346;
  int x_offset_min_r;
  int x_offset_max_r;
  int y_offset_min_r;
  int y_offset_max_r;
  x_offset_min_r = 0;
  x_offset_max_r = 120;
  y_offset_min_r = 347;
  y_offset_max_r = 519;
  int g_pixels_left;
  int g_pixels_middle;
  int g_pixels_right;
  float direction_deg;
  g_pixels_left = optionMatrix[x_offset_max_l][y_offset_max_l] -
                  optionMatrix[x_offset_min_l][y_offset_max_l] -
                  optionMatrix[x_offset_max_l][y_offset_min_l] +
                  optionMatrix[x_offset_min_l][y_offset_min_l];
  g_pixels_middle = optionMatrix[x_offset_max_m][y_offset_max_m] -
                    optionMatrix[x_offset_min_m][y_offset_max_m] -
                    optionMatrix[x_offset_max_m][y_offset_min_m] +
                    optionMatrix[x_offset_min_m][y_offset_min_m];
  g_pixels_right = optionMatrix[x_offset_max_r][y_offset_max_r] -
                   optionMatrix[x_offset_min_r][y_offset_max_r] -
                   optionMatrix[x_offset_max_r][y_offset_min_r] +
                   optionMatrix[x_offset_min_r][y_offset_min_r];
  printf("pixels left %i ", g_pixels_left);
  printf("pixels middel%i ", g_pixels_middle);
  printf("pixels right %i ", g_pixels_right);
  int threshold = 1000;
  if (g_pixels_left > g_pixels_right &&
      g_pixels_left - g_pixels_middle > threshold) {
    direction_deg = -10.0;
  } else if (g_pixels_left < g_pixels_right &&
             g_pixels_right - g_pixels_middle > threshold) {
    direction_deg = 10.0;
  } else {
    direction_deg = 0.0;
  }
  return direction_deg;
}


x86 assembly (clang, -O0):
<findHeading>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x78,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0xad,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x78,-0x20(%rbp)
movl   $0xae,-0x24(%rbp)
movl   $0x15a,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x78,-0x30(%rbp)
movl   $0x15b,-0x34(%rbp)
movl   $0x207,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
imul   $0x820,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x8(%rbp),%rcx
movslq -0xc(%rbp),%rdx
imul   $0x820,%rdx,%rdx
add    %rdx,%rcx
movslq -0x18(%rbp),%rdx
sub    (%rcx,%rdx,4),%eax
mov    -0x8(%rbp),%rcx
movslq -0x10(%rbp),%rdx
imul   $0x820,%rdx,%rdx
add    %rdx,%rcx
movslq -0x14(%rbp),%rdx
sub    (%rcx,%rdx,4),%eax
mov    -0x8(%rbp),%rcx
movslq -0xc(%rbp),%rdx
imul   $0x820,%rdx,%rdx
add    %rdx,%rcx
movslq -0x14(%rbp),%rdx
add    (%rcx,%rdx,4),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
imul   $0x820,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x8(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
imul   $0x820,%rdx,%rdx
add    %rdx,%rcx
movslq -0x28(%rbp),%rdx
sub    (%rcx,%rdx,4),%eax
mov    -0x8(%rbp),%rcx
movslq -0x20(%rbp),%rdx
imul   $0x820,%rdx,%rdx
add    %rdx,%rcx
movslq -0x24(%rbp),%rdx
sub    (%rcx,%rdx,4),%eax
mov    -0x8(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
imul   $0x820,%rdx,%rdx
add    %rdx,%rcx
movslq -0x24(%rbp),%rdx
add    (%rcx,%rdx,4),%eax
mov    %eax,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
imul   $0x820,%rcx,%rcx
add    %rcx,%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x8(%rbp),%rcx
movslq -0x2c(%rbp),%rdx
imul   $0x820,%rdx,%rdx
add    %rdx,%rcx
movslq -0x38(%rbp),%rdx
sub    (%rcx,%rdx,4),%eax
mov    -0x8(%rbp),%rcx
movslq -0x30(%rbp),%rdx
imul   $0x820,%rdx,%rdx
add    %rdx,%rcx
movslq -0x34(%rbp),%rdx
sub    (%rcx,%rdx,4),%eax
mov    -0x8(%rbp),%rcx
movslq -0x2c(%rbp),%rdx
imul   $0x820,%rdx,%rdx
add    %rdx,%rcx
movslq -0x34(%rbp),%rdx
add    (%rcx,%rdx,4),%eax
mov    %eax,-0x44(%rbp)
mov    -0x3c(%rbp),%esi
lea    0xd59(%rip),%rdi
call   1030 <printf@plt>
mov    -0x40(%rbp),%esi
lea    0xd5a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x44(%rbp),%esi
lea    0xd5c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x3e8,-0x4c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jle    1306 <findHeading+0x1f6>
mov    -0x3c(%rbp),%eax
sub    -0x40(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jle    1306 <findHeading+0x1f6>
movss  0xd08(%rip),%xmm0
movss  %xmm0,-0x48(%rbp)
jmp    1340 <findHeading+0x230>
mov    -0x3c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    1333 <findHeading+0x223>
mov    -0x44(%rbp),%eax
sub    -0x40(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jle    1333 <findHeading+0x223>
movss  0xcd7(%rip),%xmm0
movss  %xmm0,-0x48(%rbp)
jmp    133b <findHeading+0x22b>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x48(%rbp)
jmp    1340 <findHeading+0x230>
movss  -0x48(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findHeading>:
push   %rbp
push   %r14
push   %rbx
mov    0x2b4(%rdi),%eax
add    0x3cf00(%rdi),%eax
mov    0x3d1b4(%rdi),%r14d
sub    %eax,%r14d
add    (%rdi),%r14d
mov    0x568(%rdi),%eax
add    0x3d1b8(%rdi),%eax
mov    0x3d468(%rdi),%ebx
sub    %eax,%ebx
add    0x2b8(%rdi),%ebx
mov    0x81c(%rdi),%eax
add    0x3d46c(%rdi),%eax
mov    0x3d71c(%rdi),%ebp
sub    %eax,%ebp
add    0x56c(%rdi),%ebp
lea    0xea0(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
lea    0xea4(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
cmp    %ebp,%r14d
jle    11a7 <findHeading+0x97>
mov    %r14d,%eax
sub    %ebx,%eax
cmp    $0x3e8,%eax
jle    11a7 <findHeading+0x97>
movss  0xe5b(%rip),%xmm0
jmp    11cc <findHeading+0xbc>
mov    %ebp,%eax
sub    %ebx,%eax
cmp    $0x3e9,%eax
jge    11bc <findHeading+0xac>
xorps  %xmm0,%xmm0
cmp    %ebp,%r14d
jge    11c9 <findHeading+0xb9>
jmp    11cc <findHeading+0xbc>
movss  0xe40(%rip),%xmm0
cmp    %ebp,%r14d
jl     11cc <findHeading+0xbc>
xorps  %xmm0,%xmm0
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"pixels left %i \00"
@.str.1 = [17 x i8] c"pixels middel%i \00"
@.str.2 = [17 x i8] c"pixels right %i \00"
define float @findHeading([520 x i32]* %0) {
%2 = alloca [520 x i32]*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca float
%19 = alloca i32
store [520 x i32]* %0, [520 x i32]** %2
store i32 0, i32* %3
store i32 120, i32* %4
store i32 0, i32* %5
store i32 173, i32* %6
store i32 0, i32* %7
store i32 120, i32* %8
store i32 174, i32* %9
store i32 346, i32* %10
store i32 0, i32* %11
store i32 120, i32* %12
store i32 347, i32* %13
store i32 519, i32* %14
%20 = load [520 x i32]*, [520 x i32]** %2
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [520 x i32], [520 x i32]* %20, i64 %22
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [520 x i32], [520 x i32]* %23, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = load [520 x i32]*, [520 x i32]** %2
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [520 x i32], [520 x i32]* %28, i64 %30
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [520 x i32], [520 x i32]* %31, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = sub nsw i32 %27, %35
%37 = load [520 x i32]*, [520 x i32]** %2
%38 = load i32, i32* %4
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [520 x i32], [520 x i32]* %37, i64 %39
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [520 x i32], [520 x i32]* %40, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = sub nsw i32 %36, %44
%46 = load [520 x i32]*, [520 x i32]** %2
%47 = load i32, i32* %3
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [520 x i32], [520 x i32]* %46, i64 %48
%50 = load i32, i32* %5
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [520 x i32], [520 x i32]* %49, i64 0, i64 %51
%53 = load i32, i32* %52
%54 = add nsw i32 %45, %53
store i32 %54, i32* %15
%55 = load [520 x i32]*, [520 x i32]** %2
%56 = load i32, i32* %8
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [520 x i32], [520 x i32]* %55, i64 %57
%59 = load i32, i32* %10
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [520 x i32], [520 x i32]* %58, i64 0, i64 %60
%62 = load i32, i32* %61
%63 = load [520 x i32]*, [520 x i32]** %2
%64 = load i32, i32* %7
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [520 x i32], [520 x i32]* %63, i64 %65
%67 = load i32, i32* %10
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [520 x i32], [520 x i32]* %66, i64 0, i64 %68
%70 = load i32, i32* %69
%71 = sub nsw i32 %62, %70
%72 = load [520 x i32]*, [520 x i32]** %2
%73 = load i32, i32* %8
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [520 x i32], [520 x i32]* %72, i64 %74
%76 = load i32, i32* %9
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [520 x i32], [520 x i32]* %75, i64 0, i64 %77
%79 = load i32, i32* %78
%80 = sub nsw i32 %71, %79
%81 = load [520 x i32]*, [520 x i32]** %2
%82 = load i32, i32* %7
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [520 x i32], [520 x i32]* %81, i64 %83
%85 = load i32, i32* %9
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [520 x i32], [520 x i32]* %84, i64 0, i64 %86
%88 = load i32, i32* %87
%89 = add nsw i32 %80, %88
store i32 %89, i32* %16
%90 = load [520 x i32]*, [520 x i32]** %2
%91 = load i32, i32* %12
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [520 x i32], [520 x i32]* %90, i64 %92
%94 = load i32, i32* %14
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [520 x i32], [520 x i32]* %93, i64 0, i64 %95
%97 = load i32, i32* %96
%98 = load [520 x i32]*, [520 x i32]** %2
%99 = load i32, i32* %11
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds [520 x i32], [520 x i32]* %98, i64 %100
%102 = load i32, i32* %14
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds [520 x i32], [520 x i32]* %101, i64 0, i64 %103
%105 = load i32, i32* %104
%106 = sub nsw i32 %97, %105
%107 = load [520 x i32]*, [520 x i32]** %2
%108 = load i32, i32* %12
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds [520 x i32], [520 x i32]* %107, i64 %109
%111 = load i32, i32* %13
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds [520 x i32], [520 x i32]* %110, i64 0, i64 %112
%114 = load i32, i32* %113
%115 = sub nsw i32 %106, %114
%116 = load [520 x i32]*, [520 x i32]** %2
%117 = load i32, i32* %11
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds [520 x i32], [520 x i32]* %116, i64 %118
%120 = load i32, i32* %13
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds [520 x i32], [520 x i32]* %119, i64 0, i64 %121
%123 = load i32, i32* %122
%124 = add nsw i32 %115, %123
store i32 %124, i32* %17
%125 = load i32, i32* %15
%126 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %125)
%127 = load i32, i32* %16
%128 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %127)
%129 = load i32, i32* %17
%130 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %129)
store i32 1000, i32* %19
%131 = load i32, i32* %15
%132 = load i32, i32* %17
%133 = icmp sgt i32 %131, %132
br i1 %133, label %134, label %141
134: ; preds = %1
%135 = load i32, i32* %15
%136 = load i32, i32* %16
%137 = sub nsw i32 %135, %136
%138 = load i32, i32* %19
%139 = icmp sgt i32 %137, %138
br i1 %139, label %140, label %141
140: ; preds = %134
store float -1.000000e+01, float* %18
br label %154
141: ; preds = %134, %1
%142 = load i32, i32* %15
%143 = load i32, i32* %17
%144 = icmp slt i32 %142, %143
br i1 %144, label %145, label %152
145: ; preds = %141
%146 = load i32, i32* %17
%147 = load i32, i32* %16
%148 = sub nsw i32 %146, %147
%149 = load i32, i32* %19
%150 = icmp sgt i32 %148, %149
br i1 %150, label %151, label %152
151: ; preds = %145
store float 1.000000e+01, float* %18
br label %153
152: ; preds = %145, %141
store float 0.000000e+00, float* %18
br label %153
153: ; preds = %152, %151
br label %154
154: ; preds = %153, %140
%155 = load float, float* %18
ret float %155
}

LLVM IR (-O2):
@.str = [16 x i8] c"pixels left %i \00"
@.str.1 = [17 x i8] c"pixels middel%i \00"
@.str.2 = [17 x i8] c"pixels right %i \00"
define float @findHeading([520 x i32]* nocapture %0) {
%2 = getelementptr inbounds [520 x i32], [520 x i32]* %0, i64 120, i64 173
%3 = load i32, i32* %2
%4 = getelementptr inbounds [520 x i32], [520 x i32]* %0, i64 0, i64 173
%5 = load i32, i32* %4
%6 = getelementptr inbounds [520 x i32], [520 x i32]* %0, i64 120, i64 0
%7 = load i32, i32* %6
%8 = getelementptr inbounds [520 x i32], [520 x i32]* %0, i64 0, i64 0
%9 = load i32, i32* %8
%10 = add i32 %5, %7
%11 = sub i32 %3, %10
%12 = add i32 %11, %9
%13 = getelementptr inbounds [520 x i32], [520 x i32]* %0, i64 120, i64 346
%14 = load i32, i32* %13
%15 = getelementptr inbounds [520 x i32], [520 x i32]* %0, i64 0, i64 346
%16 = load i32, i32* %15
%17 = getelementptr inbounds [520 x i32], [520 x i32]* %0, i64 120, i64 174
%18 = load i32, i32* %17
%19 = getelementptr inbounds [520 x i32], [520 x i32]* %0, i64 0, i64 174
%20 = load i32, i32* %19
%21 = add i32 %16, %18
%22 = sub i32 %14, %21
%23 = add i32 %22, %20
%24 = getelementptr inbounds [520 x i32], [520 x i32]* %0, i64 120, i64 519
%25 = load i32, i32* %24
%26 = getelementptr inbounds [520 x i32], [520 x i32]* %0, i64 0, i64 519
%27 = load i32, i32* %26
%28 = getelementptr inbounds [520 x i32], [520 x i32]* %0, i64 120, i64 347
%29 = load i32, i32* %28
%30 = getelementptr inbounds [520 x i32], [520 x i32]* %0, i64 0, i64 347
%31 = load i32, i32* %30
%32 = add i32 %27, %29
%33 = sub i32 %25, %32
%34 = add i32 %33, %31
%35 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %12)
%36 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%37 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%38 = icmp sgt i32 %12, %34
%39 = sub nsw i32 %12, %23
%40 = icmp sgt i32 %39, 1000
%41 = select i1 %38, i1 %40, i1 false
br i1 %41, label %48, label %42
42: ; preds = %1
%43 = icmp slt i32 %12, %34
%44 = sub nsw i32 %34, %23
%45 = icmp sgt i32 %44, 1000
%46 = select i1 %43, i1 %45, i1 false
%47 = select i1 %46, float 1.000000e+01, float 0.000000e+00
br label %48
48: ; preds = %42, %1
%49 = phi float [ -1.000000e+01, %1 ], [ %47, %42 ]
ret float %49
}