#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 */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int log10_approx(int /*<<< orphan*/);
int calc_dewpoint_approx(uint8_t rh, int t) {
  int k, tmp;
  k = (100 * log10_approx(rh) - 20000) / 43;
  tmp = t / 10;
  tmp = 881 * tmp;
  tmp = tmp / (243 + t / 10);
  k += tmp * 2;
  tmp = 1762 - k;
  tmp = 24310 / tmp;
  tmp *= k;
  if (tmp < 0) {
    tmp -= 51;
  } else {
    tmp += 51;
  }
  return (tmp / 10);
}


x86 assembly (clang, -O0):
<calc_dewpoint_approx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <log10_approx@plt>
imul   $0x64,%eax,%eax
sub    $0x4e20,%eax
mov    $0x2b,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
imul   $0x371,-0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    $0xf3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x6e2,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x5ef6,%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    11b8 <calc_dewpoint_approx+0xa8>
mov    -0x10(%rbp),%eax
sub    $0x33,%eax
mov    %eax,-0x10(%rbp)
jmp    11c1 <calc_dewpoint_approx+0xb1>
mov    -0x10(%rbp),%eax
add    $0x33,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_dewpoint_approx>:
push   %rbx
mov    %esi,%ebx
call   1030 <log10_approx@plt>
imul   $0x64,%eax,%eax
add    $0xffffb1e0,%eax
cltq
imul   $0x2fa0be83,%rax,%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
sar    $0x23,%rcx
add    %eax,%ecx
movslq %ebx,%rax
imul   $0x66666667,%rax,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rdx
lea    (%rdx,%rsi,1),%eax
imul   $0x371,%eax,%eax
add    %edx,%esi
add    $0xf3,%esi
cltd
idiv   %esi
lea    (%rcx,%rax,2),%ecx
mov    $0x6e2,%esi
sub    %ecx,%esi
mov    $0x5ef6,%eax
xor    %edx,%edx
idiv   %esi
imul   %ecx,%eax
lea    0x33(%rax),%ecx
lea    -0x33(%rax),%edx
test   %eax,%eax
cmovns %ecx,%edx
movslq %edx,%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @calc_dewpoint_approx(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = call i32 @log10_approx(i32 %7)
%9 = mul nsw i32 100, %8
%10 = sub nsw i32 %9, 20000
%11 = sdiv i32 %10, 43
store i32 %11, i32* %5
%12 = load i32, i32* %4
%13 = sdiv i32 %12, 10
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = mul nsw i32 881, %14
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = load i32, i32* %4
%18 = sdiv i32 %17, 10
%19 = add nsw i32 243, %18
%20 = sdiv i32 %16, %19
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = mul nsw i32 %21, 2
%23 = load i32, i32* %5
%24 = add nsw i32 %23, %22
store i32 %24, i32* %5
%25 = load i32, i32* %5
%26 = sub nsw i32 1762, %25
store i32 %26, i32* %6
%27 = load i32, i32* %6
%28 = sdiv i32 24310, %27
store i32 %28, i32* %6
%29 = load i32, i32* %5
%30 = load i32, i32* %6
%31 = mul nsw i32 %30, %29
store i32 %31, i32* %6
%32 = load i32, i32* %6
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %2
%35 = load i32, i32* %6
%36 = sub nsw i32 %35, 51
store i32 %36, i32* %6
br label %40
37: ; preds = %2
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 51
store i32 %39, i32* %6
br label %40
40: ; preds = %37, %34
%41 = load i32, i32* %6
%42 = sdiv i32 %41, 10
ret i32 %42
}

LLVM IR (-O2):
define i32 @calc_dewpoint_approx(i32 %0, i32 %1) {
%3 = tail call i32 @log10_approx(i32 %0)
%4 = mul nsw i32 %3, 100
%5 = add nsw i32 %4, -20000
%6 = sdiv i32 %5, 43
%7 = sdiv i32 %1, 10
%8 = mul nsw i32 %7, 881
%9 = add nsw i32 %7, 243
%10 = sdiv i32 %8, %9
%11 = shl nsw i32 %10, 1
%12 = add nsw i32 %6, %11
%13 = sub nsw i32 1762, %12
%14 = sdiv i32 24310, %13
%15 = mul nsw i32 %12, %14
%16 = icmp slt i32 %15, 0
%17 = select i1 %16, i32 -51, i32 51
%18 = add nsw i32 %17, %15
%19 = sdiv i32 %18, 10
ret i32 %19
}