#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 __u64;
typedef int __u16;

/* Variables and functions */
__u64 get_lba_capacity(__u16 *idw) {
  __u64 nsects = (idw[58] << 16) | idw[57];
  if (idw[49] & 0x200) {
    nsects = (idw[61] << 16) | idw[60];
    if ((idw[83] & 0xc000) == 0x4000 && (idw[86] & 0x0400)) {
      nsects = (__u64)idw[103] << 48 | (__u64)idw[102] << 32 |
               (__u64)idw[101] << 16 | idw[100];
    }
  }
  return nsects;
}


x86 assembly (clang, -O0):
<get_lba_capacity>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0xe8(%rax),%eax
shl    $0x10,%eax
mov    -0x8(%rbp),%rcx
or     0xe4(%rcx),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    0xc4(%rax),%eax
and    $0x200,%eax
cmp    $0x0,%eax
je     11cd <get_lba_capacity+0xcd>
mov    -0x8(%rbp),%rax
mov    0xf4(%rax),%eax
shl    $0x10,%eax
mov    -0x8(%rbp),%rcx
or     0xf0(%rcx),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    0x14c(%rax),%eax
and    $0xc000,%eax
cmp    $0x4000,%eax
jne    11c8 <get_lba_capacity+0xc8>
mov    -0x8(%rbp),%rax
mov    0x158(%rax),%eax
and    $0x400,%eax
cmp    $0x0,%eax
je     11c8 <get_lba_capacity+0xc8>
mov    -0x8(%rbp),%rax
mov    0x19c(%rax),%eax
mov    $0x30,%ecx
shl    %cl,%eax
mov    -0x8(%rbp),%rcx
mov    0x198(%rcx),%edx
mov    $0x20,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
mov    0x194(%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
or     0x190(%rcx),%eax
mov    %eax,-0xc(%rbp)
jmp    11cd <get_lba_capacity+0xcd>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_lba_capacity>:
testb  $0x2,0xc5(%rdi)
jne    1119 <get_lba_capacity+0x19>
mov    0xe8(%rdi),%eax
shl    $0x10,%eax
or     0xe4(%rdi),%eax
ret
mov    0xf4(%rdi),%eax
shl    $0x10,%eax
or     0xf0(%rdi),%eax
ret

LLVM IR (-O0):
define i32 @get_lba_capacity(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = getelementptr inbounds i32, i32* %4, i64 58
%6 = load i32, i32* %5
%7 = shl i32 %6, 16
%8 = load i32*, i32** %2
%9 = getelementptr inbounds i32, i32* %8, i64 57
%10 = load i32, i32* %9
%11 = or i32 %7, %10
store i32 %11, i32* %3
%12 = load i32*, i32** %2
%13 = getelementptr inbounds i32, i32* %12, i64 49
%14 = load i32, i32* %13
%15 = and i32 %14, 512
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %57
17: ; preds = %1
%18 = load i32*, i32** %2
%19 = getelementptr inbounds i32, i32* %18, i64 61
%20 = load i32, i32* %19
%21 = shl i32 %20, 16
%22 = load i32*, i32** %2
%23 = getelementptr inbounds i32, i32* %22, i64 60
%24 = load i32, i32* %23
%25 = or i32 %21, %24
store i32 %25, i32* %3
%26 = load i32*, i32** %2
%27 = getelementptr inbounds i32, i32* %26, i64 83
%28 = load i32, i32* %27
%29 = and i32 %28, 49152
%30 = icmp eq i32 %29, 16384
br i1 %30, label %31, label %56
31: ; preds = %17
%32 = load i32*, i32** %2
%33 = getelementptr inbounds i32, i32* %32, i64 86
%34 = load i32, i32* %33
%35 = and i32 %34, 1024
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %56
37: ; preds = %31
%38 = load i32*, i32** %2
%39 = getelementptr inbounds i32, i32* %38, i64 103
%40 = load i32, i32* %39
%41 = shl i32 %40, 48
%42 = load i32*, i32** %2
%43 = getelementptr inbounds i32, i32* %42, i64 102
%44 = load i32, i32* %43
%45 = shl i32 %44, 32
%46 = or i32 %41, %45
%47 = load i32*, i32** %2
%48 = getelementptr inbounds i32, i32* %47, i64 101
%49 = load i32, i32* %48
%50 = shl i32 %49, 16
%51 = or i32 %46, %50
%52 = load i32*, i32** %2
%53 = getelementptr inbounds i32, i32* %52, i64 100
%54 = load i32, i32* %53
%55 = or i32 %51, %54
store i32 %55, i32* %3
br label %56
56: ; preds = %37, %31, %17
br label %57
57: ; preds = %56, %1
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
define i32 @get_lba_capacity(i32* nocapture %0) {
%2 = getelementptr inbounds i32, i32* %0, i64 58
%3 = load i32, i32* %2
%4 = shl i32 %3, 16
%5 = getelementptr inbounds i32, i32* %0, i64 57
%6 = load i32, i32* %5
%7 = or i32 %4, %6
%8 = getelementptr inbounds i32, i32* %0, i64 49
%9 = load i32, i32* %8
%10 = and i32 %9, 512
%11 = icmp eq i32 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %1
%13 = getelementptr inbounds i32, i32* %0, i64 61
%14 = load i32, i32* %13
%15 = shl i32 %14, 16
%16 = getelementptr inbounds i32, i32* %0, i64 60
%17 = load i32, i32* %16
%18 = or i32 %15, %17
br label %19
19: ; preds = %12, %1
%20 = phi i32 [ %7, %1 ], [ %18, %12 ]
ret i32 %20
}