#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*/ led_clr_dp(int);
int /*<<< orphan*/ led_set_code(int, unsigned char);
int /*<<< orphan*/ led_set_dp(int);
scalar_t__ radio_get_stereo();
void radio_freq_cb(unsigned int freq) {
  unsigned char tmp;
  tmp = (unsigned char)(freq / 10);
  led_set_code(4, tmp / 100 + 0x30);
  led_set_code(3, (tmp % 100) / 10 + 0x30);
  led_set_code(2, (tmp % 100) % 10 + 0x30);
  tmp = (unsigned char)(freq % 10);
  led_set_code(1, tmp + 0x30);
  if (radio_get_stereo()) {
    led_set_dp(5);
  } else {
    led_clr_dp(5);
  }
}


x86 assembly (clang, -O0):
<radio_freq_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %al,-0x5(%rbp)
movzbl -0x5(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x30,%eax
mov    $0x4,%edi
movzbl %al,%esi
call   1040 <led_set_code@plt>
movzbl -0x5(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%eax
mov    $0x3,%edi
movzbl %al,%esi
call   1040 <led_set_code@plt>
movzbl -0x5(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%al
mov    $0x2,%edi
movzbl %al,%esi
call   1040 <led_set_code@plt>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %dl,%al
mov    %al,-0x5(%rbp)
movzbl -0x5(%rbp),%eax
add    $0x30,%eax
mov    $0x1,%edi
movzbl %al,%esi
call   1040 <led_set_code@plt>
mov    $0x0,%al
call   1060 <radio_get_stereo@plt>
cmp    $0x0,%rax
je     1209 <radio_freq_cb+0xc9>
mov    $0x5,%edi
call   1030 <led_set_dp@plt>
jmp    1213 <radio_freq_cb+0xd3>
mov    $0x5,%edi
call   1050 <led_clr_dp@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<radio_freq_cb>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
mov    %edi,%eax
mov    $0xcccccccd,%r15d
imul   %rax,%r15
shr    $0x23,%r15
movzbl %r15b,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rax,%rcx,8),%eax
movzwl %ax,%ebp
shr    $0xc,%ebp
lea    0x30(%rbp),%eax
movzbl %al,%esi
mov    $0x4,%edi
call   1040 <led_set_code@plt>
imul   $0x64,%ebp,%eax
mov    %r15d,%ecx
sub    %al,%cl
movzbl %cl,%ebp
imul   $0xcd,%ebp,%ebx
shr    $0xb,%ebx
mov    %ebx,%eax
or     $0x30,%al
movzbl %al,%esi
mov    $0x3,%edi
call   1040 <led_set_code@plt>
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%eax
sub    %al,%bpl
or     $0x30,%bpl
movzbl %bpl,%esi
mov    $0x2,%edi
call   1040 <led_set_code@plt>
add    %r15d,%r15d
lea    (%r15,%r15,4),%eax
sub    %eax,%r14d
or     $0x30,%r14b
movzbl %r14b,%esi
mov    $0x1,%edi
call   1040 <led_set_code@plt>
xor    %eax,%eax
call   1060 <radio_get_stereo@plt>
mov    $0x5,%edi
add    $0x8,%rsp
test   %rax,%rax
je     11f5 <radio_freq_cb+0xb5>
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <led_set_dp@plt>
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <led_clr_dp@plt>

LLVM IR (-O0):
define void @radio_freq_cb(i32 %0) {
%2 = alloca i32
%3 = alloca i8
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = udiv i32 %4, 10
%6 = trunc i32 %5 to i8
store i8 %6, i8* %3
%7 = load i8, i8* %3
%8 = zext i8 %7 to i32
%9 = sdiv i32 %8, 100
%10 = add nsw i32 %9, 48
%11 = trunc i32 %10 to i8
%12 = call i32 @led_set_code(i32 4, i8 zeroext %11)
%13 = load i8, i8* %3
%14 = zext i8 %13 to i32
%15 = srem i32 %14, 100
%16 = sdiv i32 %15, 10
%17 = add nsw i32 %16, 48
%18 = trunc i32 %17 to i8
%19 = call i32 @led_set_code(i32 3, i8 zeroext %18)
%20 = load i8, i8* %3
%21 = zext i8 %20 to i32
%22 = srem i32 %21, 100
%23 = srem i32 %22, 10
%24 = add nsw i32 %23, 48
%25 = trunc i32 %24 to i8
%26 = call i32 @led_set_code(i32 2, i8 zeroext %25)
%27 = load i32, i32* %2
%28 = urem i32 %27, 10
%29 = trunc i32 %28 to i8
store i8 %29, i8* %3
%30 = load i8, i8* %3
%31 = zext i8 %30 to i32
%32 = add nsw i32 %31, 48
%33 = trunc i32 %32 to i8
%34 = call i32 @led_set_code(i32 1, i8 zeroext %33)
%35 = call i64 (...) @radio_get_stereo()
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %1
%38 = call i32 @led_set_dp(i32 5)
br label %41
39: ; preds = %1
%40 = call i32 @led_clr_dp(i32 5)
br label %41
41: ; preds = %39, %37
ret void
}

LLVM IR (-O2):
define void @radio_freq_cb(i32 %0) {
%2 = udiv i32 %0, 10
%3 = trunc i32 %2 to i8
%4 = udiv i8 %3, 100
%5 = or i8 %4, 48
%6 = tail call i32 @led_set_code(i32 4, i8 zeroext %5)
%7 = urem i8 %3, 100
%8 = udiv i8 %7, 10
%9 = or i8 %8, 48
%10 = tail call i32 @led_set_code(i32 3, i8 zeroext %9)
%11 = urem i8 %7, 10
%12 = or i8 %11, 48
%13 = tail call i32 @led_set_code(i32 2, i8 zeroext %12)
%14 = urem i32 %0, 10
%15 = trunc i32 %14 to i8
%16 = or i8 %15, 48
%17 = tail call i32 @led_set_code(i32 1, i8 zeroext %16)
%18 = tail call i64 (...) @radio_get_stereo()
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %1
%21 = tail call i32 @led_set_dp(i32 5)
br label %24
22: ; preds = %1
%23 = tail call i32 @led_clr_dp(i32 5)
br label %24
24: ; preds = %22, %20
ret void
}