#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 */
typedef int uint32_t;
typedef int uint16_t;

/* Variables and functions */
int mach64_ext_inw(int, void *);
int mach64_ext_readl(int, void *);
uint32_t mach64_ext_inl(uint16_t port, void *p) {
  uint32_t ret;
  switch (port) {
  case 0x56ec:
    ret = mach64_ext_readl(0x400 | 0xb4, p);
    break;
  case 0x5aec:
    ret = mach64_ext_readl(0x400 | 0xb8, p);
    break;
  default:
    ret = mach64_ext_inw(port, p);
    ret |= (mach64_ext_inw(port + 2, p) << 16);
    break;
  };
  return ret;
}


x86 assembly (clang, -O0):
<mach64_ext_inl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x56ec,%eax
je     1158 <mach64_ext_inl+0x38>
jmp    1145 <mach64_ext_inl+0x25>
mov    -0x18(%rbp),%eax
sub    $0x5aec,%eax
je     116e <mach64_ext_inl+0x4e>
jmp    1184 <mach64_ext_inl+0x64>
mov    -0x10(%rbp),%rsi
mov    $0x4b4,%edi
call   1040 <mach64_ext_readl@plt>
mov    %eax,-0x14(%rbp)
jmp    11ab <mach64_ext_inl+0x8b>
mov    -0x10(%rbp),%rsi
mov    $0x4b8,%edi
call   1040 <mach64_ext_readl@plt>
mov    %eax,-0x14(%rbp)
jmp    11ab <mach64_ext_inl+0x8b>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <mach64_ext_inw@plt>
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
add    $0x2,%edi
mov    -0x10(%rbp),%rsi
call   1030 <mach64_ext_inw@plt>
shl    $0x10,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mach64_ext_inl>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x5aec,%edi
je     1140 <mach64_ext_inl+0x20>
mov    %edi,%ebp
cmp    $0x56ec,%edi
jne    1151 <mach64_ext_inl+0x31>
mov    $0x4b4,%edi
jmp    1145 <mach64_ext_inl+0x25>
mov    $0x4b8,%edi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <mach64_ext_readl@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <mach64_ext_inw@plt>
mov    %eax,%r14d
add    $0x2,%ebp
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <mach64_ext_inw@plt>
shl    $0x10,%eax
or     %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @mach64_ext_inl(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = load i32, i32* %3
switch i32 %6, label %13 [
i32 22252, label %7
i32 23276, label %10
]
7: ; preds = %2
%8 = load i8*, i8** %4
%9 = call i32 @mach64_ext_readl(i32 1204, i8* %8)
store i32 %9, i32* %5
br label %24
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = call i32 @mach64_ext_readl(i32 1208, i8* %11)
store i32 %12, i32* %5
br label %24
13: ; preds = %2
%14 = load i32, i32* %3
%15 = load i8*, i8** %4
%16 = call i32 @mach64_ext_inw(i32 %14, i8* %15)
store i32 %16, i32* %5
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 2
%19 = load i8*, i8** %4
%20 = call i32 @mach64_ext_inw(i32 %18, i8* %19)
%21 = shl i32 %20, 16
%22 = load i32, i32* %5
%23 = or i32 %22, %21
store i32 %23, i32* %5
br label %24
24: ; preds = %13, %10, %7
%25 = load i32, i32* %5
ret i32 %25
}

LLVM IR (-O2):
define i32 @mach64_ext_inl(i32 %0, i8* %1) {
switch i32 %0, label %7 [
i32 22252, label %3
i32 23276, label %5
]
3: ; preds = %2
%4 = tail call i32 @mach64_ext_readl(i32 1204, i8* %1)
br label %13
5: ; preds = %2
%6 = tail call i32 @mach64_ext_readl(i32 1208, i8* %1)
br label %13
7: ; preds = %2
%8 = tail call i32 @mach64_ext_inw(i32 %0, i8* %1)
%9 = add nsw i32 %0, 2
%10 = tail call i32 @mach64_ext_inw(i32 %9, i8* %1)
%11 = shl i32 %10, 16
%12 = or i32 %11, %8
br label %13
13: ; preds = %7, %5, %3
%14 = phi i32 [ %12, %7 ], [ %6, %5 ], [ %4, %3 ]
ret i32 %14
}