#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 adc_read();
int /*<<< orphan*/ adc_set_chan(int);
int /*<<< orphan*/ delay_ms(int);
int /*<<< orphan*/ printf(char *, int, int, int);
void adc_test3(void) {
  int val;
  int tc, tf;
  adc_set_chan(16);
  for (;;) {
    val = adc_read();
    tc = ((1390 - val) * 10) / 43;
    tc += 25;
    tf = 32 + (tc * 18) / 10;
    printf("Temp (v,tc,tf): %d %d %d\n", val, tc, tf);
    delay_ms(500);
  }
}


x86 assembly (clang, -O0):
<adc_test3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x10,%edi
call   1030 <adc_set_chan@plt>
mov    $0x0,%al
call   1050 <adc_read@plt>
mov    %eax,-0x4(%rbp)
mov    $0x56e,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
imul   $0xa,%eax,%eax
mov    $0x2b,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x19,%eax
mov    %eax,-0x14(%rbp)
mov    %eax,-0x8(%rbp)
imul   $0x12,-0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x20,%eax
mov    %eax,-0x10(%rbp)
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1f4,%edi
call   1060 <delay_ms@plt>
jmp    1152 <adc_test3+0x12>

x86 assembly (clang, -O2):
<adc_test3>:
push   %rbx
mov    $0x10,%edi
call   1030 <adc_set_chan@plt>
lea    0xeae(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <adc_read@plt>
mov    $0x56e,%ecx
sub    %eax,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
movslq %ecx,%rcx
imul   $0x2fa0be83,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
lea    (%rcx,%rdx,1),%esi
add    %ecx,%edx
add    $0x19,%edx
lea    (%rsi,%rsi,1),%ecx
add    $0x32,%ecx
lea    (%rcx,%rcx,8),%ecx
movslq %ecx,%rcx
imul   $0x66666667,%rcx,%rcx
mov    %rcx,%rsi
sar    $0x22,%rsi
shr    $0x3f,%rcx
add    %esi,%ecx
add    $0x20,%ecx
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x1f4,%edi
call   1060 <delay_ms@plt>
jmp    1160 <adc_test3+0x20>

LLVM IR (-O0):
@.str = [26 x i8] c"Temp (v,tc,tf): %d %d %d\0A\00"
define void @adc_test3() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @adc_set_chan(i32 16)
br label %5
5: ; preds = %5, %0
%6 = call i32 (...) @adc_read()
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = sub nsw i32 1390, %7
%9 = mul nsw i32 %8, 10
%10 = sdiv i32 %9, 43
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = add nsw i32 %11, 25
store i32 %12, i32* %2
%13 = load i32, i32* %2
%14 = mul nsw i32 %13, 18
%15 = sdiv i32 %14, 10
%16 = add nsw i32 32, %15
store i32 %16, i32* %3
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18, i32 %19)
%21 = call i32 @delay_ms(i32 500)
br label %5
}

LLVM IR (-O2):
@.str = [26 x i8] c"Temp (v,tc,tf): %d %d %d\0A\00"
define void @adc_test3() {
%1 = tail call i32 @adc_set_chan(i32 16)
br label %2
2: ; preds = %2, %0
%3 = tail call i32 (...) @adc_read()
%4 = sub nsw i32 1390, %3
%5 = mul nsw i32 %4, 10
%6 = sdiv i32 %5, 43
%7 = add nsw i32 %6, 25
%8 = mul nsw i32 %7, 18
%9 = sdiv i32 %8, 10
%10 = add nsw i32 %9, 32
%11 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %7, i32 %10)
%12 = tail call i32 @delay_ms(i32 500)
br label %2
}