#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 calc_lowcomp1(int, int, int, int);
int calc_lowcomp(int a, int b0, int b1, int bin) {
  if (bin < 7) {
    return calc_lowcomp1(a, b0, b1, 384);
  } else if (bin < 20) {
    return calc_lowcomp1(a, b0, b1, 320);
  } else {
    return ((a - 128) > (0) ? (a - 128) : (0));
  }
}


x86 assembly (clang, -O0):
<calc_lowcomp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
cmpl   $0x7,-0x14(%rbp)
jge    1149 <calc_lowcomp+0x39>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    $0x180,%ecx
call   1030 <calc_lowcomp1@plt>
mov    %eax,-0x4(%rbp)
jmp    119f <calc_lowcomp+0x8f>
cmpl   $0x14,-0x14(%rbp)
jge    116e <calc_lowcomp+0x5e>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    $0x140,%ecx
call   1030 <calc_lowcomp1@plt>
mov    %eax,-0x4(%rbp)
jmp    119f <calc_lowcomp+0x8f>
mov    -0x8(%rbp),%eax
sub    $0x80,%eax
cmp    $0x0,%eax
jle    118f <calc_lowcomp+0x7f>
mov    -0x8(%rbp),%eax
sub    $0x80,%eax
mov    %eax,-0x18(%rbp)
jmp    1199 <calc_lowcomp+0x89>
xor    %eax,%eax
mov    %eax,-0x18(%rbp)
jmp    1199 <calc_lowcomp+0x89>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_lowcomp>:
cmp    $0x6,%ecx
jg     111f <calc_lowcomp+0xf>
mov    $0x180,%ecx
jmp    1030 <calc_lowcomp1@plt>
cmp    $0x13,%ecx
ja     112e <calc_lowcomp+0x1e>
mov    $0x140,%ecx
jmp    1030 <calc_lowcomp1@plt>
cmp    $0x81,%edi
mov    $0x80,%eax
cmovge %edi,%eax
add    $0xffffff80,%eax
ret

LLVM IR (-O0):
define i32 @calc_lowcomp(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%10 = load i32, i32* %9
%11 = icmp slt i32 %10, 7
br i1 %11, label %12, label %17
12: ; preds = %4
%13 = load i32, i32* %6
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = call i32 @calc_lowcomp1(i32 %13, i32 %14, i32 %15, i32 384)
store i32 %16, i32* %5
br label %35
17: ; preds = %4
%18 = load i32, i32* %9
%19 = icmp slt i32 %18, 20
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = load i32, i32* %8
%24 = call i32 @calc_lowcomp1(i32 %21, i32 %22, i32 %23, i32 320)
store i32 %24, i32* %5
br label %35
25: ; preds = %17
%26 = load i32, i32* %6
%27 = sub nsw i32 %26, 128
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i32, i32* %6
%31 = sub nsw i32 %30, 128
br label %33
32: ; preds = %25
br label %33
33: ; preds = %32, %29
%34 = phi i32 [ %31, %29 ], [ 0, %32 ]
store i32 %34, i32* %5
br label %35
35: ; preds = %33, %20, %12
%36 = load i32, i32* %5
ret i32 %36
}

LLVM IR (-O2):
define i32 @calc_lowcomp(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp slt i32 %3, 7
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i32 @calc_lowcomp1(i32 %0, i32 %1, i32 %2, i32 384)
br label %16
8: ; preds = %4
%9 = icmp ult i32 %3, 20
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = tail call i32 @calc_lowcomp1(i32 %0, i32 %1, i32 %2, i32 320)
br label %16
12: ; preds = %8
%13 = icmp sgt i32 %0, 128
%14 = select i1 %13, i32 %0, i32 128
%15 = add nsw i32 %14, -128
br label %16
16: ; preds = %12, %10, %6
%17 = phi i32 [ %7, %6 ], [ %11, %10 ], [ %15, %12 ]
ret i32 %17
}