#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*/ printf(char *, ...);
void radeon_rom_legacy_clocks(unsigned char *bios, int hdr) {
  int pll_info_block = (*((unsigned short *)(bios + (hdr + 0x30))));
  if (pll_info_block == 0) {
    printf("No clock info block in BIOS\n");
    return;
  }
  printf("Clock info block:\n");
  printf("  SCLK   : %f\n",
         (*((unsigned short *)(bios + (pll_info_block + 0x08)))) / 100.0);
  printf("  MCLK   : %f\n",
         (*((unsigned short *)(bios + (pll_info_block + 0x0a)))) / 100.0);
  printf("  RefClk : %f\n",
         (*((unsigned short *)(bios + (pll_info_block + 0x0e)))) / 100.0);
  printf("  RefDiv : %d\n",
         (*((unsigned short *)(bios + (pll_info_block + 0x10)))));
  printf("  VCO Min: %f\n",
         (*((unsigned int *)(bios + (pll_info_block + 0x12)))) / 100.0);
  printf("  VCO Max: %f\n",
         (*((unsigned int *)(bios + (pll_info_block + 0x16)))) / 100.0);
  printf("\n");
}


x86 assembly (clang, -O0):
<radeon_rom_legacy_clocks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x30,%ecx
movslq %ecx,%rcx
movzwl (%rax,%rcx,1),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1150 <radeon_rom_legacy_clocks+0x40>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1264 <radeon_rom_legacy_clocks+0x154>
lea    0xece(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x21(%rbp)
call   1030 <printf@plt>
mov    -0x8(%rbp),%rcx
movslq -0x10(%rbp),%rax
movzwl 0x8(%rax,%rcx,1),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe86(%rip),%xmm1
movsd  %xmm1,-0x20(%rbp)
divsd  %xmm1,%xmm0
lea    0xeae(%rip),%rdi
mov    $0x1,%al
mov    %al,-0x11(%rbp)
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm1
mov    -0x11(%rbp),%al
mov    -0x8(%rbp),%rdx
movslq -0x10(%rbp),%rcx
movzwl 0xa(%rcx,%rdx,1),%ecx
cvtsi2sd %ecx,%xmm0
divsd  %xmm1,%xmm0
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm1
mov    -0x11(%rbp),%al
mov    -0x8(%rbp),%rdx
movslq -0x10(%rbp),%rcx
movzwl 0xe(%rcx,%rdx,1),%ecx
cvtsi2sd %ecx,%xmm0
divsd  %xmm1,%xmm0
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
mov    -0x8(%rbp),%rdx
movslq -0x10(%rbp),%rcx
movzwl 0x10(%rcx,%rdx,1),%esi
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm1
mov    -0x11(%rbp),%al
mov    -0x8(%rbp),%rdx
movslq -0x10(%rbp),%rcx
mov    0x12(%rcx,%rdx,1),%ecx
cvtsi2sd %rcx,%xmm0
divsd  %xmm1,%xmm0
lea    0xe4e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rcx
movslq -0x10(%rbp),%rax
mov    0x16(%rax,%rcx,1),%eax
cvtsi2sd %rax,%xmm0
movsd  0xdbc(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe34(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<radeon_rom_legacy_clocks>:
push   %r14
push   %rbx
push   %rax
movslq %esi,%rax
movzwl 0x30(%rax,%rdi,1),%ebx
test   %rbx,%rbx
je     1225 <radeon_rom_legacy_clocks+0xf5>
mov    %rdi,%r14
lea    0xf13(%rip),%rdi
call   1040 <puts@plt>
movzwl 0x8(%rbx,%r14,1),%eax
cvtsi2sd %eax,%xmm0
divsd  0xe9a(%rip),%xmm0
lea    0xe9b(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movzwl 0xa(%rbx,%r14,1),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xe77(%rip),%xmm0
lea    0xe87(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movzwl 0xe(%rbx,%r14,1),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xe54(%rip),%xmm0
lea    0xe73(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movzwl 0x10(%rbx,%r14,1),%esi
lea    0xe6e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x12(%rbx,%r14,1),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  0xe1d(%rip),%xmm0
lea    0xe5a(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    0x16(%rbx,%r14,1),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  0xdfa(%rip),%xmm0
lea    0xe46(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putchar@plt>
lea    0xe48(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"No clock info block in BIOS\0A\00"
@.str.1 = [19 x i8] c"Clock info block:\0A\00"
@.str.2 = [15 x i8] c" SCLK : %f\0A\00"
@.str.3 = [15 x i8] c" MCLK : %f\0A\00"
@.str.4 = [15 x i8] c" RefClk : %f\0A\00"
@.str.5 = [15 x i8] c" RefDiv : %d\0A\00"
@.str.6 = [15 x i8] c" VCO Min: %f\0A\00"
@.str.7 = [15 x i8] c" VCO Max: %f\0A\00"
@.str.8 = [2 x i8] c"\0A\00"
define void @radeon_rom_legacy_clocks(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = load i32, i32* %4
%8 = add nsw i32 %7, 48
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %6, i64 %9
%11 = bitcast i8* %10 to i16*
%12 = load i16, i16* %11
%13 = zext i16 %12 to i32
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %83
18: ; preds = %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%20 = load i8*, i8** %3
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %20, i64 %23
%25 = bitcast i8* %24 to i16*
%26 = load i16, i16* %25
%27 = zext i16 %26 to i32
%28 = sitofp i32 %27 to double
%29 = fdiv double %28, 1.000000e+02
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), double %29)
%31 = load i8*, i8** %3
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 10
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %31, i64 %34
%36 = bitcast i8* %35 to i16*
%37 = load i16, i16* %36
%38 = zext i16 %37 to i32
%39 = sitofp i32 %38 to double
%40 = fdiv double %39, 1.000000e+02
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), double %40)
%42 = load i8*, i8** %3
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 14
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %42, i64 %45
%47 = bitcast i8* %46 to i16*
%48 = load i16, i16* %47
%49 = zext i16 %48 to i32
%50 = sitofp i32 %49 to double
%51 = fdiv double %50, 1.000000e+02
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), double %51)
%53 = load i8*, i8** %3
%54 = load i32, i32* %5
%55 = add nsw i32 %54, 16
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %53, i64 %56
%58 = bitcast i8* %57 to i16*
%59 = load i16, i16* %58
%60 = zext i16 %59 to i32
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %60)
%62 = load i8*, i8** %3
%63 = load i32, i32* %5
%64 = add nsw i32 %63, 18
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %62, i64 %65
%67 = bitcast i8* %66 to i32*
%68 = load i32, i32* %67
%69 = uitofp i32 %68 to double
%70 = fdiv double %69, 1.000000e+02
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), double %70)
%72 = load i8*, i8** %3
%73 = load i32, i32* %5
%74 = add nsw i32 %73, 22
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %72, i64 %75
%77 = bitcast i8* %76 to i32*
%78 = load i32, i32* %77
%79 = uitofp i32 %78 to double
%80 = fdiv double %79, 1.000000e+02
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), double %80)
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %83
83: ; preds = %18, %16
ret void
}

LLVM IR (-O2):
@.str.2 = [15 x i8] c" SCLK : %f\0A\00"
@.str.3 = [15 x i8] c" MCLK : %f\0A\00"
@.str.4 = [15 x i8] c" RefClk : %f\0A\00"
@.str.5 = [15 x i8] c" RefDiv : %d\0A\00"
@.str.6 = [15 x i8] c" VCO Min: %f\0A\00"
@.str.7 = [15 x i8] c" VCO Max: %f\0A\00"
@str = [18 x i8] c"Clock info block:\00"
@str.9 = [28 x i8] c"No clock info block in BIOS\00"
define void @radeon_rom_legacy_clocks(i8* nocapture %0, i32 %1) {
%3 = add nsw i32 %1, 48
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = bitcast i8* %5 to i16*
%7 = load i16, i16* %6
%8 = zext i16 %7 to i32
%9 = icmp eq i16 %7, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.9, i64 0, i64 0))
br label %62
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%14 = add nuw nsw i32 %8, 8
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = bitcast i8* %16 to i16*
%18 = load i16, i16* %17
%19 = uitofp i16 %18 to double
%20 = fdiv double %19, 1.000000e+02
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), double %20)
%22 = add nuw nsw i32 %8, 10
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %0, i64 %23
%25 = bitcast i8* %24 to i16*
%26 = load i16, i16* %25
%27 = uitofp i16 %26 to double
%28 = fdiv double %27, 1.000000e+02
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), double %28)
%30 = add nuw nsw i32 %8, 14
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %0, i64 %31
%33 = bitcast i8* %32 to i16*
%34 = load i16, i16* %33
%35 = uitofp i16 %34 to double
%36 = fdiv double %35, 1.000000e+02
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), double %36)
%38 = add nuw nsw i32 %8, 16
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %0, i64 %39
%41 = bitcast i8* %40 to i16*
%42 = load i16, i16* %41
%43 = zext i16 %42 to i32
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %43)
%45 = add nuw nsw i32 %8, 18
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %0, i64 %46
%48 = bitcast i8* %47 to i32*
%49 = load i32, i32* %48
%50 = uitofp i32 %49 to double
%51 = fdiv double %50, 1.000000e+02
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), double %51)
%53 = add nuw nsw i32 %8, 22
%54 = zext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %0, i64 %54
%56 = bitcast i8* %55 to i32*
%57 = load i32, i32* %56
%58 = uitofp i32 %57 to double
%59 = fdiv double %58, 1.000000e+02
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), double %59)
%61 = tail call i32 @putchar(i32 10)
br label %62
62: ; preds = %12, %10
ret void
}