#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 uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ librpip_dt_file_get_raw(int, int, int *, int, int *);
uint32_t librpip_pins_getextpins_from_dt(uint32_t fileid) {
  uint32_t pins;
  uint32_t rlen;
  uint8_t dtconf[40];
  uint32_t i;
  pins = 0;
  rlen = 0;
  librpip_dt_file_get_raw(2, fileid, &dtconf[0], 40, &rlen);
  if (rlen > 3) {
    for (i = 3; i < rlen; i += 4) {
      pins |= (1 << dtconf[i]);
    }
  }
  return pins;
}


x86 assembly (clang, -O0):
<librpip_pins_getextpins_from_dt>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%esi
lea    -0xb0(%rbp),%rdx
mov    $0x2,%edi
mov    $0x28,%ecx
lea    -0xc(%rbp),%r8
call   1030 <librpip_dt_file_get_raw@plt>
cmpl   $0x3,-0xc(%rbp)
jle    11a0 <librpip_pins_getextpins_from_dt+0x90>
movl   $0x3,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119b <librpip_pins_getextpins_from_dt+0x8b>
movslq -0xb4(%rbp),%rax
mov    -0xb0(%rbp,%rax,4),%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xb4(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0xb4(%rbp)
jmp    115d <librpip_pins_getextpins_from_dt+0x4d>
jmp    11a0 <librpip_pins_getextpins_from_dt+0x90>
mov    -0x8(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<librpip_pins_getextpins_from_dt>:
sub    $0xb8,%rsp
mov    %edi,%esi
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%r8
mov    $0x2,%edi
mov    $0x28,%ecx
call   1030 <librpip_dt_file_get_raw@plt>
mov    0xc(%rsp),%ecx
xor    %eax,%eax
cmp    $0x4,%ecx
jl     1161 <librpip_pins_getextpins_from_dt+0x51>
xor    %eax,%eax
mov    $0x3,%edx
nopl   0x0(%rax)
movzbl 0x10(%rsp,%rdx,4),%esi
bts    %esi,%eax
add    $0x4,%rdx
cmp    %rcx,%rdx
jb     1150 <librpip_pins_getextpins_from_dt+0x40>
add    $0xb8,%rsp
ret

LLVM IR (-O0):
define i32 @librpip_pins_getextpins_from_dt(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [40 x i32]
%6 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%7 = load i32, i32* %2
%8 = getelementptr inbounds [40 x i32], [40 x i32]* %5, i64 0, i64 0
%9 = call i32 @librpip_dt_file_get_raw(i32 2, i32 %7, i32* %8, i32 40, i32* %4)
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 3
br i1 %11, label %12, label %29
12: ; preds = %1
store i32 3, i32* %6
br label %13
13: ; preds = %25, %12
%14 = load i32, i32* %6
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %28
17: ; preds = %13
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [40 x i32], [40 x i32]* %5, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = shl i32 1, %21
%23 = load i32, i32* %3
%24 = or i32 %23, %22
store i32 %24, i32* %3
br label %25
25: ; preds = %17
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 4
store i32 %27, i32* %6
br label %13
28: ; preds = %13
br label %29
29: ; preds = %28, %1
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
define i32 @librpip_pins_getextpins_from_dt(i32 %0) {
%2 = alloca i32
%3 = alloca [40 x i32]
%4 = bitcast i32* %2 to i8*
%5 = bitcast [40 x i32]* %3 to i8*
store i32 0, i32* %2
%6 = getelementptr inbounds [40 x i32], [40 x i32]* %3, i64 0, i64 0
%7 = call i32 @librpip_dt_file_get_raw(i32 2, i32 %0, i32* %6, i32 40, i32* %2)
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 3
br i1 %9, label %10, label %21
10: ; preds = %1
%11 = zext i32 %8 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 3, %10 ], [ %19, %12 ]
%14 = phi i32 [ 0, %10 ], [ %18, %12 ]
%15 = getelementptr inbounds [40 x i32], [40 x i32]* %3, i64 0, i64 %13
%16 = load i32, i32* %15
%17 = shl nuw i32 1, %16
%18 = or i32 %17, %14
%19 = add nuw nsw i64 %13, 4
%20 = icmp ult i64 %19, %11
br i1 %20, label %12, label %21
21: ; preds = %12, %1
%22 = phi i32 [ 0, %1 ], [ %18, %12 ]
ret i32 %22
}