#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*/ serialCommand(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int hr20SetTemperature(int temperature) {
  if (temperature % 5)
    return 0;
  char buffer[255];
  char response[255];
  sprintf(buffer, "\rA%x\r", temperature / 5);
  serialCommand(buffer, response);
  return 1;
}


x86 assembly (clang, -O0):
<hr20SetTemperature>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     114e <hr20SetTemperature+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    1188 <hr20SetTemperature+0x68>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
lea    0xe97(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x110(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1030 <serialCommand@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hr20SetTemperature>:
imul   $0xcccccccd,%edi,%ecx
add    $0x19999999,%ecx
xor    %eax,%eax
cmp    $0x33333332,%ecx
jbe    1137 <hr20SetTemperature+0x17>
ret
push   %rbx
sub    $0x200,%rsp
movslq %edi,%rax
imul   $0x66666667,%rax,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x21,%rdx
add    %eax,%edx
lea    0xea3(%rip),%rsi
lea    0x100(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <sprintf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <serialCommand@plt>
mov    $0x1,%eax
add    $0x200,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"\0DA%x\0D\00"
define i32 @hr20SetTemperature(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [255 x i8]
%5 = alloca [255 x i8]
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = srem i32 %6, 5
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 0, i32* %2
br label %18
10: ; preds = %1
%11 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%12 = load i32, i32* %3
%13 = sdiv i32 %12, 5
%14 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%16 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%17 = call i32 @serialCommand(i8* %15, i8* %16)
store i32 1, i32* %2
br label %18
18: ; preds = %10, %9
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@.str = [6 x i8] c"\0DA%x\0D\00"
define i32 @hr20SetTemperature(i32 %0) {
%2 = alloca [255 x i8]
%3 = alloca [255 x i8]
%4 = srem i32 %0, 5
%5 = sdiv i32 %0, 5
%6 = icmp eq i32 %4, 0
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%10 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %5)
%11 = call i32 @serialCommand(i8* %8, i8* %9)
br label %12
12: ; preds = %1, %7
%13 = phi i32 [ 1, %7 ], [ 0, %1 ]
ret i32 %13
}