#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 get_ext_div_from_latency(int);
int get_od_from_cntl(int);
int /*<<< orphan*/ printf(char *, ...);
int show_freq(int *table) {
  int i;
  int latency;
  int od, k;
  while (table[0]) {
    od = get_od_from_cntl(table[1]);
    switch (od) {
    case 0:
      k = 1;
      break;
    case 1:
      k = 2;
      break;
    case 2:
      k = 4;
      break;
    default:
      k = 999;
    }
    latency = get_ext_div_from_latency(table[2]);
    printf("\t\t{ %4d,", table[0] / 1000);
    printf(" 0x%08X,", table[1]);
    printf(" 0x%08X },", table[2]);
    printf(" /* fvco %4d, / %d, /%2d */", table[3] / 1000, k,
           latency ? ((latency + 1) * 2) : 1);
    printf("\n");
    table += 4;
  }
}


x86 assembly (clang, -O0):
<show_freq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
je     1285 <show_freq+0x155>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
call   1030 <get_od_from_cntl@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
test   %eax,%eax
je     118d <show_freq+0x5d>
jmp    116b <show_freq+0x3b>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
je     1199 <show_freq+0x69>
jmp    117c <show_freq+0x4c>
mov    -0x24(%rbp),%eax
sub    $0x2,%eax
je     11a5 <show_freq+0x75>
jmp    11b1 <show_freq+0x81>
movl   $0x1,-0x20(%rbp)
jmp    11b8 <show_freq+0x88>
movl   $0x2,-0x20(%rbp)
jmp    11b8 <show_freq+0x88>
movl   $0x4,-0x20(%rbp)
jmp    11b8 <show_freq+0x88>
movl   $0x3e7,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%edi
call   1040 <get_ext_div_from_latency@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%esi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1242 <show_freq+0x112>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
shl    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    124f <show_freq+0x11f>
mov    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    124f <show_freq+0x11f>
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%ecx
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
jmp    113c <show_freq+0xc>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_freq>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmpl   $0x0,(%rdi)
je     1239 <show_freq+0xf9>
mov    %rdi,%rbx
add    $0x10,%rbx
lea    0xeb0(%rip),%r12
mov    $0x1,%r15d
lea    0xeae(%rip),%r13
jmp    1212 <show_freq+0xd2>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    -0x8(%rbx),%edi
call   1050 <get_ext_div_from_latency@plt>
mov    %eax,%r14d
movslq -0x10(%rbx),%rax
imul   $0x10624dd3,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x26,%rsi
add    %eax,%esi
lea    0xe56(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    -0xc(%rbx),%esi
lea    0xe4e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    -0x8(%rbx),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movslq -0x4(%rbx),%rax
imul   $0x10624dd3,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x26,%rsi
add    %eax,%esi
test   %r14d,%r14d
lea    0x2(%r14,%r14,1),%ecx
cmove  %r15d,%ecx
mov    %r13,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpl   $0x0,(%rbx)
lea    0x10(%rbx),%rbx
je     1239 <show_freq+0xf9>
mov    -0xc(%rbx),%edi
call   1040 <get_od_from_cntl@plt>
mov    $0x3e7,%ebp
cmp    $0x2,%eax
ja     1180 <show_freq+0x40>
cltq
lea    0xe0b(%rip),%rcx
mov    (%rcx,%rax,4),%ebp
jmp    1180 <show_freq+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"\09\09{ %4d,\00"
@.str.1 = [9 x i8] c" 0x%08X,\00"
@.str.2 = [11 x i8] c" 0x%08X },\00"
@.str.3 = [28 x i8] c" /* fvco %4d, / %d, /%2d */\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @show_freq(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
br label %8
8: ; preds = %53, %1
%9 = load i32*, i32** %3
%10 = getelementptr inbounds i32, i32* %9, i64 0
%11 = load i32, i32* %10
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %59
13: ; preds = %8
%14 = load i32*, i32** %3
%15 = getelementptr inbounds i32, i32* %14, i64 1
%16 = load i32, i32* %15
%17 = call i32 @get_od_from_cntl(i32 %16)
store i32 %17, i32* %6
%18 = load i32, i32* %6
switch i32 %18, label %22 [
i32 0, label %19
i32 1, label %20
i32 2, label %21
]
19: ; preds = %13
store i32 1, i32* %7
br label %23
20: ; preds = %13
store i32 2, i32* %7
br label %23
21: ; preds = %13
store i32 4, i32* %7
br label %23
22: ; preds = %13
store i32 999, i32* %7
br label %23
23: ; preds = %22, %21, %20, %19
%24 = load i32*, i32** %3
%25 = getelementptr inbounds i32, i32* %24, i64 2
%26 = load i32, i32* %25
%27 = call i32 @get_ext_div_from_latency(i32 %26)
store i32 %27, i32* %5
%28 = load i32*, i32** %3
%29 = getelementptr inbounds i32, i32* %28, i64 0
%30 = load i32, i32* %29
%31 = sdiv i32 %30, 1000
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = load i32*, i32** %3
%34 = getelementptr inbounds i32, i32* %33, i64 1
%35 = load i32, i32* %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%37 = load i32*, i32** %3
%38 = getelementptr inbounds i32, i32* %37, i64 2
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %39)
%41 = load i32*, i32** %3
%42 = getelementptr inbounds i32, i32* %41, i64 3
%43 = load i32, i32* %42
%44 = sdiv i32 %43, 1000
%45 = load i32, i32* %7
%46 = load i32, i32* %5
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %23
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
%51 = mul nsw i32 %50, 2
br label %53
52: ; preds = %23
br label %53
53: ; preds = %52, %48
%54 = phi i32 [ %51, %48 ], [ 1, %52 ]
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %44, i32 %45, i32 %54)
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%57 = load i32*, i32** %3
%58 = getelementptr inbounds i32, i32* %57, i64 4
store i32* %58, i32** %3
br label %8
59: ; preds = %8
%60 = load i32, i32* %2
ret i32 %60
}

LLVM IR (-O2):
@.str = [9 x i8] c"\09\09{ %4d,\00"
@.str.1 = [9 x i8] c" 0x%08X,\00"
@.str.2 = [11 x i8] c" 0x%08X },\00"
@.str.3 = [28 x i8] c" /* fvco %4d, / %d, /%2d */\00"
@switch.table.show_freq = [3 x i32] [i32 1, i32 2, i32 4]
define i32 @show_freq(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = icmp eq i32 %2, 0
br i1 %3, label %38, label %4
4: ; preds = %1, %14
%5 = phi i32* [ %35, %14 ], [ %0, %1 ]
%6 = getelementptr inbounds i32, i32* %5, i64 1
%7 = load i32, i32* %6
%8 = tail call i32 @get_od_from_cntl(i32 %7)
%9 = icmp ult i32 %8, 3
br i1 %9, label %10, label %14
10: ; preds = %4
%11 = sext i32 %8 to i64
%12 = getelementptr inbounds [3 x i32], [3 x i32]* @switch.table.show_freq, i64 0, i64 %11
%13 = load i32, i32* %12
br label %14
14: ; preds = %4, %10
%15 = phi i32 [ %13, %10 ], [ 999, %4 ]
%16 = getelementptr inbounds i32, i32* %5, i64 2
%17 = load i32, i32* %16
%18 = tail call i32 @get_ext_div_from_latency(i32 %17)
%19 = load i32, i32* %5
%20 = sdiv i32 %19, 1000
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %6
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %16
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds i32, i32* %5, i64 3
%27 = load i32, i32* %26
%28 = sdiv i32 %27, 1000
%29 = icmp eq i32 %18, 0
%30 = shl i32 %18, 1
%31 = add i32 %30, 2
%32 = select i1 %29, i32 1, i32 %31
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %28, i32 %15, i32 %32)
%34 = tail call i32 @putchar(i32 10)
%35 = getelementptr inbounds i32, i32* %5, i64 4
%36 = load i32, i32* %35
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %4
38: ; preds = %14, %1
ret i32 undef
}