#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 /*<<< orphan*/ GPIODirModeSet(unsigned long, unsigned long, unsigned long,
                                  unsigned long);
void xGPIODirModeSet(unsigned long ulPort, unsigned long ulPins,
                     unsigned long ulPinIO) {
  unsigned long ulBit;
  ;

  ;
  for (ulBit = 0; ulBit < 16; ulBit++) {
    if (ulPins & (1 << ulBit)) {
      GPIODirModeSet(ulPort, ulBit, ulPinIO & 0xC, ulPinIO & 0x3);
    }
  }
}


x86 assembly (clang, -O0):
<xGPIODirModeSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x10,-0x20(%rbp)
jae    118b <xGPIODirModeSet+0x7b>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
movslq %ecx,%rcx
and    %rcx,%rax
cmp    $0x0,%rax
je     1175 <xGPIODirModeSet+0x65>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
and    $0xc,%rdx
mov    -0x18(%rbp),%rcx
and    $0x3,%rcx
call   1030 <GPIODirModeSet@plt>
jmp    117a <xGPIODirModeSet+0x6a>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112c <xGPIODirModeSet+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xGPIODirModeSet>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r13
mov    %rdi,%r15
mov    %r14d,%r12d
and    $0xc,%r12d
and    $0x3,%r14d
xor    %ebx,%ebx
jmp    114a <xGPIODirModeSet+0x3a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x10,%rbx
je     1163 <xGPIODirModeSet+0x53>
bt     %rbx,%r13
jae    1140 <xGPIODirModeSet+0x30>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r14,%rcx
call   1030 <GPIODirModeSet@plt>
jmp    1140 <xGPIODirModeSet+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @xGPIODirModeSet(i64 %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store i64 %0, i64* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
store i64 0, i64* %7
br label %8
8: ; preds = %28, %3
%9 = load i64, i64* %7
%10 = icmp ult i64 %9, 16
br i1 %10, label %11, label %31
11: ; preds = %8
%12 = load i64, i64* %5
%13 = load i64, i64* %7
%14 = trunc i64 %13 to i32
%15 = shl i32 1, %14
%16 = sext i32 %15 to i64
%17 = and i64 %12, %16
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %27
19: ; preds = %11
%20 = load i64, i64* %4
%21 = load i64, i64* %7
%22 = load i64, i64* %6
%23 = and i64 %22, 12
%24 = load i64, i64* %6
%25 = and i64 %24, 3
%26 = call i32 @GPIODirModeSet(i64 %20, i64 %21, i64 %23, i64 %25)
br label %27
27: ; preds = %19, %11
br label %28
28: ; preds = %27
%29 = load i64, i64* %7
%30 = add i64 %29, 1
store i64 %30, i64* %7
br label %8
31: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @xGPIODirModeSet(i64 %0, i64 %1, i64 %2) {
%4 = and i64 %2, 12
%5 = and i64 %2, 3
br label %6
6: ; preds = %3, %15
%7 = phi i64 [ 0, %3 ], [ %16, %15 ]
%8 = trunc i64 %7 to i32
%9 = shl nuw nsw i32 1, %8
%10 = zext i32 %9 to i64
%11 = and i64 %10, %1
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %6
%14 = tail call i32 @GPIODirModeSet(i64 %0, i64 %7, i64 %4, i64 %5)
br label %15
15: ; preds = %6, %13
%16 = add nuw nsw i64 %7, 1
%17 = icmp eq i64 %16, 16
br i1 %17, label %18, label %6
18: ; preds = %15
ret void
}