#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_920_Div();
unsigned int get_freq_920_CLK();
unsigned get_speed_clock(void) {
  int n, m;
  unsigned sysfreq = 0;
  unsigned lfreq[25] = {60,  66,  80,  100, 120, 133, 150, 166, 200,
                        210, 220, 240, 250, 266, 270, 275, 280, 285,
                        290, 295, 300, 305, 310, 315, 320};
  sysfreq = get_freq_920_CLK();
  sysfreq *= get_920_Div() + 1;
  m = (sysfreq / 1000000) + 4;
  n = 0;
  for (n = 24; n > 1; n--) {
    if (lfreq[n] < m)
      break;
  }
  return lfreq[n];
}


x86 assembly (clang, -O0):
<get_speed_clock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0xc(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x64,%edx
call   1040 <memcpy@plt>
mov    $0x0,%al
call   1050 <get_freq_920_CLK@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <get_920_Div@plt>
add    $0x1,%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xf4240,%ecx
xor    %edx,%edx
div    %ecx
add    $0x4,%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
movl   $0x18,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
jle    11c2 <get_speed_clock+0x92>
movslq -0x4(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%eax
cmp    -0x8(%rbp),%eax
jae    11af <get_speed_clock+0x7f>
jmp    11c2 <get_speed_clock+0x92>
jmp    11b4 <get_speed_clock+0x84>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    118f <get_speed_clock+0x5f>
movslq -0x4(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_speed_clock>:
push   %rbx
xor    %eax,%eax
call   1040 <get_freq_920_CLK@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <get_920_Div@plt>
add    $0x1,%eax
imul   %ebx,%eax
mov    $0x18,%ecx
cmp    $0x12e5093f,%eax
ja     127d <get_speed_clock+0x15d>
mov    $0x17,%ecx
cmp    $0x1298bdff,%eax
ja     127d <get_speed_clock+0x15d>
mov    $0x16,%ecx
cmp    $0x124c72bf,%eax
ja     127d <get_speed_clock+0x15d>
mov    $0x15,%ecx
cmp    $0x1200277f,%eax
ja     127d <get_speed_clock+0x15d>
mov    $0x14,%ecx
cmp    $0x11b3dc3f,%eax
ja     127d <get_speed_clock+0x15d>
mov    $0x13,%ecx
cmp    $0x116790ff,%eax
ja     127d <get_speed_clock+0x15d>
mov    $0x12,%ecx
cmp    $0x111b45bf,%eax
ja     127d <get_speed_clock+0x15d>
mov    $0x11,%ecx
cmp    $0x10cefa7f,%eax
ja     127d <get_speed_clock+0x15d>
mov    $0x10,%ecx
cmp    $0x1082af3f,%eax
ja     127d <get_speed_clock+0x15d>
mov    $0xf,%ecx
cmp    $0x103663ff,%eax
ja     127d <get_speed_clock+0x15d>
mov    $0xe,%ecx
cmp    $0xfea18bf,%eax
ja     127d <get_speed_clock+0x15d>
mov    $0xd,%ecx
cmp    $0xfad0fbf,%eax
ja     127d <get_speed_clock+0x15d>
mov    $0xc,%ecx
cmp    $0xeb8ebbf,%eax
ja     127d <get_speed_clock+0x15d>
mov    $0xb,%ecx
cmp    $0xe20553f,%eax
ja     127d <get_speed_clock+0x15d>
mov    $0xa,%ecx
cmp    $0xcef283f,%eax
ja     127d <get_speed_clock+0x15d>
mov    $0x9,%ecx
cmp    $0xc5691bf,%eax
ja     127d <get_speed_clock+0x15d>
mov    $0x8,%ecx
cmp    $0xbbdfb3f,%eax
ja     127d <get_speed_clock+0x15d>
mov    $0x7,%ecx
cmp    $0x9b72ebf,%eax
ja     127d <get_speed_clock+0x15d>
mov    $0x6,%ecx
cmp    $0x8c30abf,%eax
ja     127d <get_speed_clock+0x15d>
mov    $0x5,%ecx
cmp    $0x7bfa47f,%eax
ja     127d <get_speed_clock+0x15d>
mov    $0x4,%ecx
cmp    $0x6f9473f,%eax
ja     127d <get_speed_clock+0x15d>
mov    $0x3,%ecx
cmp    $0x5c81a3f,%eax
ja     127d <get_speed_clock+0x15d>
cmp    $0x496ed40,%eax
mov    $0x1,%ecx
sbb    $0xffffffffffffffff,%rcx
lea    0xd7c(%rip),%rax
mov    (%rax,%rcx,4),%eax
pop    %rbx
ret

LLVM IR (-O0):
@__const.get_speed_clock.lfreq = [25 x i32] [i32 60, i32 66, i32 80, i32 100, i32 120, i32 133, i32 150, i32 166, i32 200, i32 210, i32 220, i32 240, i32 250, i32 266, i32 270, i32 275, i32 280, i32 285, i32 290, i32 295, i32 300, i32 305, i32 310, i32 315, i32 320]
define i32 @get_speed_clock() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [25 x i32]
store i32 0, i32* %3
%5 = bitcast [25 x i32]* %4 to i8*
%6 = call i32 (...) @get_freq_920_CLK()
store i32 %6, i32* %3
%7 = call i32 (...) @get_920_Div()
%8 = add nsw i32 %7, 1
%9 = load i32, i32* %3
%10 = mul i32 %9, %8
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = udiv i32 %11, 1000000
%13 = add i32 %12, 4
store i32 %13, i32* %2
store i32 0, i32* %1
store i32 24, i32* %1
br label %14
14: ; preds = %26, %0
%15 = load i32, i32* %1
%16 = icmp sgt i32 %15, 1
br i1 %16, label %17, label %29
17: ; preds = %14
%18 = load i32, i32* %1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [25 x i32], [25 x i32]* %4, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = load i32, i32* %2
%23 = icmp ult i32 %21, %22
br i1 %23, label %24, label %25
24: ; preds = %17
br label %29
25: ; preds = %17
br label %26
26: ; preds = %25
%27 = load i32, i32* %1
%28 = add nsw i32 %27, -1
store i32 %28, i32* %1
br label %14
29: ; preds = %24, %14
%30 = load i32, i32* %1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [25 x i32], [25 x i32]* %4, i64 0, i64 %31
%33 = load i32, i32* %32
ret i32 %33
}

LLVM IR (-O2):
@__const.get_speed_clock.lfreq = [25 x i32] [i32 60, i32 66, i32 80, i32 100, i32 120, i32 133, i32 150, i32 166, i32 200, i32 210, i32 220, i32 240, i32 250, i32 266, i32 270, i32 275, i32 280, i32 285, i32 290, i32 295, i32 300, i32 305, i32 310, i32 315, i32 320]
define i32 @get_speed_clock() {
%1 = tail call i32 (...) @get_freq_920_CLK()
%2 = tail call i32 (...) @get_920_Div()
%3 = add nsw i32 %2, 1
%4 = mul i32 %3, %1
%5 = icmp ugt i32 %4, 316999999
br i1 %5, label %51, label %6
6: ; preds = %0
%7 = icmp ugt i32 %4, 311999999
br i1 %7, label %51, label %8
8: ; preds = %6
%9 = icmp ugt i32 %4, 306999999
br i1 %9, label %51, label %10
10: ; preds = %8
%11 = icmp ugt i32 %4, 301999999
br i1 %11, label %51, label %12
12: ; preds = %10
%13 = icmp ugt i32 %4, 296999999
br i1 %13, label %51, label %14
14: ; preds = %12
%15 = icmp ugt i32 %4, 291999999
br i1 %15, label %51, label %16
16: ; preds = %14
%17 = icmp ugt i32 %4, 286999999
br i1 %17, label %51, label %18
18: ; preds = %16
%19 = icmp ugt i32 %4, 281999999
br i1 %19, label %51, label %20
20: ; preds = %18
%21 = icmp ugt i32 %4, 276999999
br i1 %21, label %51, label %22
22: ; preds = %20
%23 = icmp ugt i32 %4, 271999999
br i1 %23, label %51, label %24
24: ; preds = %22
%25 = icmp ugt i32 %4, 266999999
br i1 %25, label %51, label %26
26: ; preds = %24
%27 = icmp ugt i32 %4, 262999999
br i1 %27, label %51, label %28
28: ; preds = %26
%29 = icmp ugt i32 %4, 246999999
br i1 %29, label %51, label %30
30: ; preds = %28
%31 = icmp ugt i32 %4, 236999999
br i1 %31, label %51, label %32
32: ; preds = %30
%33 = icmp ugt i32 %4, 216999999
br i1 %33, label %51, label %34
34: ; preds = %32
%35 = icmp ugt i32 %4, 206999999
br i1 %35, label %51, label %36
36: ; preds = %34
%37 = icmp ugt i32 %4, 196999999
br i1 %37, label %51, label %38
38: ; preds = %36
%39 = icmp ugt i32 %4, 162999999
br i1 %39, label %51, label %40
40: ; preds = %38
%41 = icmp ugt i32 %4, 146999999
br i1 %41, label %51, label %42
42: ; preds = %40
%43 = icmp ugt i32 %4, 129999999
br i1 %43, label %51, label %44
44: ; preds = %42
%45 = icmp ugt i32 %4, 116999999
br i1 %45, label %51, label %46
46: ; preds = %44
%47 = icmp ugt i32 %4, 96999999
br i1 %47, label %51, label %48
48: ; preds = %46
%49 = icmp ugt i32 %4, 76999999
%50 = select i1 %49, i64 2, i64 1
br label %51
51: ; preds = %48, %46, %44, %42, %40, %38, %36, %34, %32, %30, %28, %26, %24, %22, %20, %18, %16, %14, %12, %10, %8, %6, %0
%52 = phi i64 [ 24, %0 ], [ 23, %6 ], [ 22, %8 ], [ 21, %10 ], [ 20, %12 ], [ 19, %14 ], [ 18, %16 ], [ 17, %18 ], [ 16, %20 ], [ 15, %22 ], [ 14, %24 ], [ 13, %26 ], [ 12, %28 ], [ 11, %30 ], [ 10, %32 ], [ 9, %34 ], [ 8, %36 ], [ 7, %38 ], [ 6, %40 ], [ 5, %42 ], [ 4, %44 ], [ 3, %46 ], [ %50, %48 ]
%53 = getelementptr inbounds [25 x i32], [25 x i32]* @__const.get_speed_clock.lfreq, i64 0, i64 %52
%54 = load i32, i32* %53
ret i32 %54
}