#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 */
unsigned char GPIOPinLockStatus(unsigned long, unsigned char);
void GPIOPinLock(unsigned long ulPort, unsigned char ucPins) {
  ;
  if (GPIOPinLockStatus(ulPort, ucPins) != ucPins) {
    (*((volatile unsigned long *)(ulPort + 0x00000520))) = 0x4C4F434B;
    (*((volatile unsigned long *)(ulPort + 0x00000524))) &= ~(ucPins);
    (*((volatile unsigned long *)(ulPort + 0x00000520))) = 0x00000000;
  }
}


x86 assembly (clang, -O0):
<GPIOPinLock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rdi
movzbl -0x9(%rbp),%esi
call   1030 <GPIOPinLockStatus@plt>
movzbl %al,%eax
movzbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
je     117b <GPIOPinLock+0x6b>
mov    -0x8(%rbp),%rax
movq   $0x4c4f434b,0x520(%rax)
4b 43 4f 4c
movzbl -0x9(%rbp),%eax
xor    $0xffffffff,%eax
movslq %eax,%rdx
mov    -0x8(%rbp),%rax
mov    0x524(%rax),%rcx
and    %rdx,%rcx
mov    %rcx,0x524(%rax)
mov    -0x8(%rbp),%rax
movq   $0x0,0x520(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GPIOPinLock>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <GPIOPinLockStatus@plt>
cmp    %bpl,%al
je     1146 <GPIOPinLock+0x36>
movzbl %bpl,%eax
movq   $0x4c4f434b,0x520(%rbx)
4b 43 4f 4c
not    %rax
and    %rax,0x524(%rbx)
movq   $0x0,0x520(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @GPIOPinLock(i64 %0, i8 zeroext %1) {
%3 = alloca i64
%4 = alloca i8
store i64 %0, i64* %3
store i8 %1, i8* %4
%5 = load i64, i64* %3
%6 = load i8, i8* %4
%7 = call zeroext i8 @GPIOPinLockStatus(i64 %5, i8 zeroext %6)
%8 = zext i8 %7 to i32
%9 = load i8, i8* %4
%10 = zext i8 %9 to i32
%11 = icmp ne i32 %8, %10
br i1 %11, label %12, label %28
12: ; preds = %2
%13 = load i64, i64* %3
%14 = add i64 %13, 1312
%15 = inttoptr i64 %14 to i64*
store volatile i64 1280262987, i64* %15
%16 = load i8, i8* %4
%17 = zext i8 %16 to i32
%18 = xor i32 %17, -1
%19 = sext i32 %18 to i64
%20 = load i64, i64* %3
%21 = add i64 %20, 1316
%22 = inttoptr i64 %21 to i64*
%23 = load volatile i64, i64* %22
%24 = and i64 %23, %19
store volatile i64 %24, i64* %22
%25 = load i64, i64* %3
%26 = add i64 %25, 1312
%27 = inttoptr i64 %26 to i64*
store volatile i64 0, i64* %27
br label %28
28: ; preds = %12, %2
ret void
}

LLVM IR (-O2):
define void @GPIOPinLock(i64 %0, i8 zeroext %1) {
%3 = tail call zeroext i8 @GPIOPinLockStatus(i64 %0, i8 zeroext %1)
%4 = icmp eq i8 %3, %1
br i1 %4, label %14, label %5
5: ; preds = %2
%6 = zext i8 %1 to i64
%7 = add i64 %0, 1312
%8 = inttoptr i64 %7 to i64*
store volatile i64 1280262987, i64* %8
%9 = xor i64 %6, -1
%10 = add i64 %0, 1316
%11 = inttoptr i64 %10 to i64*
%12 = load volatile i64, i64* %11
%13 = and i64 %12, %9
store volatile i64 %13, i64* %11
store volatile i64 0, i64* %8
br label %14
14: ; preds = %5, %2
ret void
}