unsigned int leon3_ahbslv_scan(register unsigned int vendor,
                               register unsigned int driver) {
  register unsigned int conf, i, *confp;
  register unsigned int cfg_area =
      (unsigned int)(0xfff00000 | 0xff000 | (1 << 11));
  for (i = 0; i < 8; i++) {
    confp = (unsigned int *)(cfg_area + (i * 8 * 4));
    conf = *confp;
    if (((((conf) >> 24) & 0xff) == vendor) &&
        ((((conf) >> 12) & 0xfff) == driver)) {
      return (unsigned int)confp;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<leon3_ahbslv_scan>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0xfffff800,-0x24(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jae    1186 <leon3_ahbslv_scan+0x86>
mov    -0x24(%rbp),%eax
mov    -0x14(%rbp),%ecx
shl    $0x3,%ecx
shl    $0x2,%ecx
add    %ecx,%eax
mov    %eax,%eax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
shr    $0x18,%eax
and    $0xff,%eax
cmp    -0x8(%rbp),%eax
jne    1173 <leon3_ahbslv_scan+0x73>
mov    -0x10(%rbp),%eax
shr    $0xc,%eax
and    $0xfff,%eax
cmp    -0xc(%rbp),%eax
jne    1173 <leon3_ahbslv_scan+0x73>
mov    -0x20(%rbp),%rax
mov    %eax,-0x4(%rbp)
jmp    118d <leon3_ahbslv_scan+0x8d>
jmp    1178 <leon3_ahbslv_scan+0x78>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1118 <leon3_ahbslv_scan+0x18>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<leon3_ahbslv_scan>:
mov    $0xfffff800,%ecx
mov    (%rcx),%edx
mov    %edx,%eax
shr    $0x18,%eax
cmp    %edi,%eax
jne    1126 <leon3_ahbslv_scan+0x26>
shr    $0xc,%edx
and    $0xfff,%edx
mov    $0xfffff800,%eax
cmp    %esi,%edx
je     1212 <leon3_ahbslv_scan+0x112>
mov    0x20(%rcx),%edx
mov    %edx,%eax
shr    $0x18,%eax
cmp    %edi,%eax
jne    1148 <leon3_ahbslv_scan+0x48>
shr    $0xc,%edx
and    $0xfff,%edx
mov    $0xfffff820,%eax
cmp    %esi,%edx
je     1212 <leon3_ahbslv_scan+0x112>
mov    0x40(%rcx),%edx
mov    %edx,%eax
shr    $0x18,%eax
cmp    %edi,%eax
jne    116a <leon3_ahbslv_scan+0x6a>
shr    $0xc,%edx
and    $0xfff,%edx
mov    $0xfffff840,%eax
cmp    %esi,%edx
je     1212 <leon3_ahbslv_scan+0x112>
mov    0x60(%rcx),%edx
mov    %edx,%eax
shr    $0x18,%eax
cmp    %edi,%eax
jne    118c <leon3_ahbslv_scan+0x8c>
shr    $0xc,%edx
and    $0xfff,%edx
mov    $0xfffff860,%eax
cmp    %esi,%edx
je     1212 <leon3_ahbslv_scan+0x112>
mov    0x80(%rcx),%edx
mov    %edx,%eax
shr    $0x18,%eax
cmp    %edi,%eax
jne    11ad <leon3_ahbslv_scan+0xad>
shr    $0xc,%edx
and    $0xfff,%edx
mov    $0xfffff880,%eax
cmp    %esi,%edx
je     1212 <leon3_ahbslv_scan+0x112>
mov    0xa0(%rcx),%edx
mov    %edx,%eax
shr    $0x18,%eax
cmp    %edi,%eax
jne    11ce <leon3_ahbslv_scan+0xce>
shr    $0xc,%edx
and    $0xfff,%edx
mov    $0xfffff8a0,%eax
cmp    %esi,%edx
je     1212 <leon3_ahbslv_scan+0x112>
mov    0xc0(%rcx),%edx
mov    %edx,%eax
shr    $0x18,%eax
cmp    %edi,%eax
jne    11ef <leon3_ahbslv_scan+0xef>
shr    $0xc,%edx
and    $0xfff,%edx
mov    $0xfffff8c0,%eax
cmp    %esi,%edx
je     1212 <leon3_ahbslv_scan+0x112>
mov    0xe0(%rcx),%ecx
mov    %ecx,%eax
shr    $0x18,%eax
cmp    %edi,%eax
jne    1210 <leon3_ahbslv_scan+0x110>
shr    $0xc,%ecx
and    $0xfff,%ecx
mov    $0xfffff8e0,%eax
cmp    %esi,%ecx
je     1212 <leon3_ahbslv_scan+0x112>
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @leon3_ahbslv_scan(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 -2048, i32* %9
store i32 0, i32* %7
br label %10
10: ; preds = %38, %2
%11 = load i32, i32* %7
%12 = icmp ult i32 %11, 8
br i1 %12, label %13, label %41
13: ; preds = %10
%14 = load i32, i32* %9
%15 = load i32, i32* %7
%16 = mul i32 %15, 8
%17 = mul i32 %16, 4
%18 = add i32 %14, %17
%19 = zext i32 %18 to i64
%20 = inttoptr i64 %19 to i32*
store i32* %20, i32** %8
%21 = load i32*, i32** %8
%22 = load i32, i32* %21
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = lshr i32 %23, 24
%25 = and i32 %24, 255
%26 = load i32, i32* %4
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %37
28: ; preds = %13
%29 = load i32, i32* %6
%30 = lshr i32 %29, 12
%31 = and i32 %30, 4095
%32 = load i32, i32* %5
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %37
34: ; preds = %28
%35 = load i32*, i32** %8
%36 = ptrtoint i32* %35 to i32
store i32 %36, i32* %3
br label %42
37: ; preds = %28, %13
br label %38
38: ; preds = %37
%39 = load i32, i32* %7
%40 = add i32 %39, 1
store i32 %40, i32* %7
br label %10
41: ; preds = %10
store i32 0, i32* %3
br label %42
42: ; preds = %41, %34
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
define i32 @leon3_ahbslv_scan(i32 %0, i32 %1) {
%3 = load i32, i32* inttoptr (i64 4294965248 to i32*)
%4 = lshr i32 %3, 24
%5 = icmp eq i32 %4, %0
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = lshr i32 %3, 12
%8 = and i32 %7, 4095
%9 = icmp eq i32 %8, %1
br i1 %9, label %67, label %10
10: ; preds = %2, %6
%11 = load i32, i32* inttoptr (i64 4294965280 to i32*)
%12 = lshr i32 %11, 24
%13 = icmp eq i32 %12, %0
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = lshr i32 %11, 12
%16 = and i32 %15, 4095
%17 = icmp eq i32 %16, %1
br i1 %17, label %67, label %18
18: ; preds = %14, %10
%19 = load i32, i32* inttoptr (i64 4294965312 to i32*)
%20 = lshr i32 %19, 24
%21 = icmp eq i32 %20, %0
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = lshr i32 %19, 12
%24 = and i32 %23, 4095
%25 = icmp eq i32 %24, %1
br i1 %25, label %67, label %26
26: ; preds = %22, %18
%27 = load i32, i32* inttoptr (i64 4294965344 to i32*)
%28 = lshr i32 %27, 24
%29 = icmp eq i32 %28, %0
br i1 %29, label %30, label %34
30: ; preds = %26
%31 = lshr i32 %27, 12
%32 = and i32 %31, 4095
%33 = icmp eq i32 %32, %1
br i1 %33, label %67, label %34
34: ; preds = %30, %26
%35 = load i32, i32* inttoptr (i64 4294965376 to i32*)
%36 = lshr i32 %35, 24
%37 = icmp eq i32 %36, %0
br i1 %37, label %38, label %42
38: ; preds = %34
%39 = lshr i32 %35, 12
%40 = and i32 %39, 4095
%41 = icmp eq i32 %40, %1
br i1 %41, label %67, label %42
42: ; preds = %38, %34
%43 = load i32, i32* inttoptr (i64 4294965408 to i32*)
%44 = lshr i32 %43, 24
%45 = icmp eq i32 %44, %0
br i1 %45, label %46, label %50
46: ; preds = %42
%47 = lshr i32 %43, 12
%48 = and i32 %47, 4095
%49 = icmp eq i32 %48, %1
br i1 %49, label %67, label %50
50: ; preds = %46, %42
%51 = load i32, i32* inttoptr (i64 4294965440 to i32*)
%52 = lshr i32 %51, 24
%53 = icmp eq i32 %52, %0
br i1 %53, label %54, label %58
54: ; preds = %50
%55 = lshr i32 %51, 12
%56 = and i32 %55, 4095
%57 = icmp eq i32 %56, %1
br i1 %57, label %67, label %58
58: ; preds = %54, %50
%59 = load i32, i32* inttoptr (i64 4294965472 to i32*)
%60 = lshr i32 %59, 24
%61 = icmp eq i32 %60, %0
br i1 %61, label %62, label %66
62: ; preds = %58
%63 = lshr i32 %59, 12
%64 = and i32 %63, 4095
%65 = icmp eq i32 %64, %1
br i1 %65, label %67, label %66
66: ; preds = %62, %58
br label %67
67: ; preds = %66, %62, %54, %46, %38, %30, %22, %14, %6
%68 = phi i32 [ -2048, %6 ], [ -2016, %14 ], [ -1984, %22 ], [ -1952, %30 ], [ -1920, %38 ], [ -1888, %46 ], [ -1856, %54 ], [ -1824, %62 ], [ 0, %66 ]
ret i32 %68
}