#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*/ I2C_Puts(int, int, int, unsigned char *);
unsigned int thermo_temp_to_hex(char);
void thermo_lo_threshold_set(char temp) {
  unsigned int val;
  ;
  if (temp == (char)(128))
    temp = ((-55) - 1);
  else {
    if (temp > (85))
      temp = (85);
    if (temp < (-55))
      temp = (-55);
  }
  val = thermo_temp_to_hex(temp);
  I2C_Puts(0x94, 0x2, 2, (unsigned char *)&val);
  I2C_Puts(0x94, 0x3, 2, (unsigned char *)&val);
}


x86 assembly (clang, -O0):
<thermo_lo_threshold_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0xffffff80,%eax
jne    1144 <thermo_lo_threshold_set+0x24>
movb   $0xc8,-0x1(%rbp)
jmp    116b <thermo_lo_threshold_set+0x4b>
movsbl -0x1(%rbp),%eax
cmp    $0x55,%eax
jle    1155 <thermo_lo_threshold_set+0x35>
movb   $0x55,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0xffffffc9,%eax
jge    1166 <thermo_lo_threshold_set+0x46>
movb   $0xc9,-0x1(%rbp)
jmp    116b <thermo_lo_threshold_set+0x4b>
movsbl -0x1(%rbp),%edi
call   1040 <thermo_temp_to_hex@plt>
mov    %eax,-0x8(%rbp)
lea    -0x8(%rbp),%rcx
mov    $0x94,%edi
mov    $0x2,%edx
mov    %edx,%esi
call   1030 <I2C_Puts@plt>
lea    -0x8(%rbp),%rcx
mov    $0x94,%edi
mov    $0x3,%esi
mov    $0x2,%edx
call   1030 <I2C_Puts@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<thermo_lo_threshold_set>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x55,%dil
mov    $0x55,%eax
cmovl  %edi,%eax
cmp    $0xca,%al
mov    $0xc9,%ecx
cmovge %eax,%ecx
cmp    $0x80,%dil
mov    $0xc8,%eax
cmovne %ecx,%eax
movsbl %al,%edi
call   1040 <thermo_temp_to_hex@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rbx
mov    $0x94,%edi
mov    $0x2,%esi
mov    $0x2,%edx
mov    %rbx,%rcx
call   1030 <I2C_Puts@plt>
mov    $0x94,%edi
mov    $0x3,%esi
mov    $0x2,%edx
mov    %rbx,%rcx
call   1030 <I2C_Puts@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @thermo_lo_threshold_set(i8 signext %0) {
%2 = alloca i8
%3 = alloca i32
store i8 %0, i8* %2
%4 = load i8, i8* %2
%5 = sext i8 %4 to i32
%6 = icmp eq i32 %5, -128
br i1 %6, label %7, label %8
7: ; preds = %1
store i8 -56, i8* %2
br label %19
8: ; preds = %1
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp sgt i32 %10, 85
br i1 %11, label %12, label %13
12: ; preds = %8
store i8 85, i8* %2
br label %13
13: ; preds = %12, %8
%14 = load i8, i8* %2
%15 = sext i8 %14 to i32
%16 = icmp slt i32 %15, -55
br i1 %16, label %17, label %18
17: ; preds = %13
store i8 -55, i8* %2
br label %18
18: ; preds = %17, %13
br label %19
19: ; preds = %18, %7
%20 = load i8, i8* %2
%21 = call i32 @thermo_temp_to_hex(i8 signext %20)
store i32 %21, i32* %3
%22 = bitcast i32* %3 to i8*
%23 = call i32 @I2C_Puts(i32 148, i32 2, i32 2, i8* %22)
%24 = bitcast i32* %3 to i8*
%25 = call i32 @I2C_Puts(i32 148, i32 3, i32 2, i8* %24)
ret void
}

LLVM IR (-O2):
define void @thermo_lo_threshold_set(i8 signext %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = icmp eq i8 %0, -128
%5 = icmp slt i8 %0, 85
%6 = select i1 %5, i8 %0, i8 85
%7 = icmp sgt i8 %6, -55
%8 = select i1 %7, i8 %6, i8 -55
%9 = select i1 %4, i8 -56, i8 %8
%10 = tail call i32 @thermo_temp_to_hex(i8 signext %9)
store i32 %10, i32* %2
%11 = call i32 @I2C_Puts(i32 148, i32 2, i32 2, i8* %3)
%12 = call i32 @I2C_Puts(i32 148, i32 3, i32 2, i8* %3)
ret void
}