#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 */
scalar_t__ GetGpioAddress();
void SetGpio(int pinNum, int pinVal) {
  if (pinNum > 53)
    goto ERROR;
  if (pinNum < 0)
    goto ERROR;
  int *gpio_addr = (int *)GetGpioAddress();
  if (pinNum >= 32)
    gpio_addr += 1;
  int bitValue;
  bitValue = 1 << (pinNum % 32);
  if (pinVal == 0) {
    *(gpio_addr + 10) = bitValue;
  } else {
    *(gpio_addr + 7) = bitValue;
  }
ERROR:
  return;
}


x86 assembly (clang, -O0):
<SetGpio>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x35,-0x4(%rbp)
jle    112d <SetGpio+0x1d>
jmp    119c <SetGpio+0x8c>
cmpl   $0x0,-0x4(%rbp)
jge    113c <SetGpio+0x2c>
jmp    119c <SetGpio+0x8c>
mov    $0x0,%al
call   1030 <GetGpioAddress@plt>
mov    %rax,-0x10(%rbp)
cmpl   $0x20,-0x4(%rbp)
jl     115d <SetGpio+0x4d>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    118d <SetGpio+0x7d>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x28(%rax)
jmp    1197 <SetGpio+0x87>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x1c(%rax)
jmp    119c <SetGpio+0x8c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SetGpio>:
cmp    $0x35,%edi
ja     114b <SetGpio+0x3b>
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
xor    %eax,%eax
call   1030 <GetGpioAddress@plt>
xor    %edx,%edx
cmp    $0x20,%ebp
setae  %dl
mov    $0x1,%esi
mov    %ebp,%ecx
shl    %cl,%esi
lea    0x1c(%rax),%rcx
add    $0x28,%rax
test   %ebx,%ebx
cmovne %rcx,%rax
mov    %esi,(%rax,%rdx,4)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @SetGpio(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = icmp sgt i32 %7, 53
br i1 %8, label %9, label %10
9: ; preds = %2
br label %37
10: ; preds = %2
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10
br label %37
14: ; preds = %10
%15 = call i64 (...) @GetGpioAddress()
%16 = inttoptr i64 %15 to i32*
store i32* %16, i32** %5
%17 = load i32, i32* %3
%18 = icmp sge i32 %17, 32
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i32*, i32** %5
%21 = getelementptr inbounds i32, i32* %20, i64 1
store i32* %21, i32** %5
br label %22
22: ; preds = %19, %14
%23 = load i32, i32* %3
%24 = srem i32 %23, 32
%25 = shl i32 1, %24
store i32 %25, i32* %6
%26 = load i32, i32* %4
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %22
%29 = load i32, i32* %6
%30 = load i32*, i32** %5
%31 = getelementptr inbounds i32, i32* %30, i64 10
store i32 %29, i32* %31
br label %36
32: ; preds = %22
%33 = load i32, i32* %6
%34 = load i32*, i32** %5
%35 = getelementptr inbounds i32, i32* %34, i64 7
store i32 %33, i32* %35
br label %36
36: ; preds = %32, %28
br label %37
37: ; preds = %36, %13, %9
ret void
}

LLVM IR (-O2):
define void @SetGpio(i32 %0, i32 %1) {
%3 = icmp ugt i32 %0, 53
br i1 %3, label %15, label %4
4: ; preds = %2
%5 = tail call i64 (...) @GetGpioAddress()
%6 = inttoptr i64 %5 to i32*
%7 = icmp ugt i32 %0, 31
%8 = zext i1 %7 to i64
%9 = getelementptr i32, i32* %6, i64 %8
%10 = and i32 %0, 31
%11 = shl nuw i32 1, %10
%12 = icmp eq i32 %1, 0
%13 = select i1 %12, i64 10, i64 7
%14 = getelementptr inbounds i32, i32* %9, i64 %13
store i32 %11, i32* %14
br label %15
15: ; preds = %4, %2
ret void
}