#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 __builtin_inw(int);
void spd_set_memclk(void) {
  unsigned min;
  unsigned device;
  min = 0x250;
  for (device = 0x80; device <= 0x81; device += 1) {
    unsigned cur;
    int latency;
    unsigned long loops;
    cur = 5 | 0xa0;
    latency = __builtin_inw(0xab);
    if (latency > 0x250) {
      loops = 1000000;
      while (--loops)
        ;
      if (!loops) {
        goto end;
      }
      loops = 1000000;
      while (--loops)
        ;
    end:;
    }
    loops = 1000000;
    while (--loops)
      ;
    if (latency > 0x250) {
      ;
    }
    if (cur > 0x250) {
    }
  }
}


x86 assembly (clang, -O0):
<spd_set_memclk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x250,-0x4(%rbp)
movl   $0x80,-0x8(%rbp)
cmpl   $0x81,-0x8(%rbp)
ja     120e <spd_set_memclk+0xfe>
movl   $0xa5,-0xc(%rbp)
mov    $0xab,%edi
call   1030 <__builtin_inw@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x250,-0x10(%rbp)
jle    11b4 <spd_set_memclk+0xa4>
movq   $0xf4240,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1177 <spd_set_memclk+0x67>
jmp    115c <spd_set_memclk+0x4c>
cmpq   $0x0,-0x18(%rbp)
jne    1187 <spd_set_memclk+0x77>
jmp    11af <spd_set_memclk+0x9f>
movq   $0xf4240,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11aa <spd_set_memclk+0x9a>
jmp    118f <spd_set_memclk+0x7f>
jmp    11af <spd_set_memclk+0x9f>
jmp    11b4 <spd_set_memclk+0xa4>
movq   $0xf4240,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11d7 <spd_set_memclk+0xc7>
jmp    11bc <spd_set_memclk+0xac>
cmpl   $0x250,-0x10(%rbp)
jle    11e9 <spd_set_memclk+0xd9>
jmp    11e9 <spd_set_memclk+0xd9>
cmpl   $0x250,-0xc(%rbp)
jbe    11fb <spd_set_memclk+0xeb>
jmp    11fb <spd_set_memclk+0xeb>
jmp    1200 <spd_set_memclk+0xf0>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1126 <spd_set_memclk+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spd_set_memclk>:
push   %rax
mov    $0xab,%edi
call   1030 <__builtin_inw@plt>
mov    $0xab,%edi
pop    %rax
jmp    1030 <__builtin_inw@plt>

LLVM IR (-O0):
define void @spd_set_memclk() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
store i32 592, i32* %1
store i32 128, i32* %2
br label %6
6: ; preds = %46, %0
%7 = load i32, i32* %2
%8 = icmp ule i32 %7, 129
br i1 %8, label %9, label %49
9: ; preds = %6
store i32 165, i32* %3
%10 = call i32 @__builtin_inw(i32 171)
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 592
br i1 %12, label %13, label %31
13: ; preds = %9
store i64 1000000, i64* %5
br label %14
14: ; preds = %18, %13
%15 = load i64, i64* %5
%16 = add i64 %15, -1
store i64 %16, i64* %5
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
br label %14
19: ; preds = %14
%20 = load i64, i64* %5
%21 = icmp ne i64 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %19
br label %30
23: ; preds = %19
store i64 1000000, i64* %5
br label %24
24: ; preds = %28, %23
%25 = load i64, i64* %5
%26 = add i64 %25, -1
store i64 %26, i64* %5
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %24
br label %24
29: ; preds = %24
br label %30
30: ; preds = %29, %22
br label %31
31: ; preds = %30, %9
store i64 1000000, i64* %5
br label %32
32: ; preds = %36, %31
%33 = load i64, i64* %5
%34 = add i64 %33, -1
store i64 %34, i64* %5
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32
br label %32
37: ; preds = %32
%38 = load i32, i32* %4
%39 = icmp sgt i32 %38, 592
br i1 %39, label %40, label %41
40: ; preds = %37
br label %41
41: ; preds = %40, %37
%42 = load i32, i32* %3
%43 = icmp ugt i32 %42, 592
br i1 %43, label %44, label %45
44: ; preds = %41
br label %45
45: ; preds = %44, %41
br label %46
46: ; preds = %45
%47 = load i32, i32* %2
%48 = add i32 %47, 1
store i32 %48, i32* %2
br label %6
49: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @spd_set_memclk() {
%1 = tail call i32 @__builtin_inw(i32 171)
%2 = tail call i32 @__builtin_inw(i32 171)
ret void
}