#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*/ delay_ms(int);
int /*<<< orphan*/ printf(char *, int, int, int);
void show_temp(int count, int delay) {
  int i;
  int val;
  int tc, tf;
  for (i = 0; i < count; i++) {
    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(delay);
  }
}


x86 assembly (clang, -O0):
<show_temp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b7 <show_temp+0x87>
mov    $0x0,%al
call   1040 <adc_read@plt>
mov    %eax,-0x10(%rbp)
mov    $0x56e,%eax
sub    -0x10(%rbp),%eax
imul   $0xa,%eax,%eax
mov    $0x2b,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x19,%eax
mov    %eax,-0x14(%rbp)
imul   $0x12,-0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x20,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
call   1050 <delay_ms@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1145 <show_temp+0x15>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_temp>:
push   %rbp
push   %r14
push   %rbx
test   %edi,%edi
jle    11b9 <show_temp+0x89>
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xeb9(%rip),%r14
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <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    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %ebx,%edi
call   1050 <delay_ms@plt>
add    $0xffffffff,%ebp
jne    1150 <show_temp+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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