#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*/ _panic(char *, int, char *, int);
int /*<<< orphan*/ _sleep(int /*<<< orphan*/);
int /*<<< orphan*/ check_if_gpio_legal(int);
int get32(int);
int /*<<< orphan*/ put32(int, int);
void gpio_output_init(int n) {
  if (!check_if_gpio_legal(n)) {
    _panic("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/Yradex/RaspberryPi3_OS/refs/heads/master/"
           "os/driver/gpio.c",
           26, "GPIO%d out of range", n);
  }
  int ra;
  ra = get32((0xFFFFFF0000000000uL + 0x3F200000 + 0x00000000) + 4 * (n / 10));
  ra &= ~(7 << ((n % 10) * 3));
  ra |= 1 << ((n % 10) * 3);
  put32((0xFFFFFF0000000000uL + 0x3F200000 + 0x00000000) + 4 * (n / 10), ra);
  _sleep(0);
}


x86 assembly (clang, -O0):
<gpio_output_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <check_if_gpio_legal@plt>
cmp    $0x0,%eax
jne    1187 <gpio_output_init+0x37>
mov    -0x4(%rbp),%ecx
lea    0xe8a(%rip),%rdi
mov    $0x1a,%esi
lea    0xf12(%rip),%rdx
call   1040 <_panic@plt>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
shl    $0x2,%eax
cltq
movabs $0xffffff003f200000,%rcx
ff ff ff
add    %rcx,%rax
mov    %eax,%edi
call   1070 <get32@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
imul   $0x3,%edx,%ecx
mov    $0x7,%eax
shl    %cl,%eax
xor    $0xffffffff,%eax
and    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
imul   $0x3,%edx,%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
shl    $0x2,%eax
cltq
movabs $0xffffff003f200000,%rcx
ff ff ff
add    %rcx,%rax
mov    %eax,%edi
mov    -0x8(%rbp),%esi
call   1060 <put32@plt>
xor    %edi,%edi
call   1030 <_sleep@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gpio_output_init>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
call   1050 <check_if_gpio_legal@plt>
test   %eax,%eax
jne    1179 <gpio_output_init+0x29>
lea    0xe9a(%rip),%rdi
lea    0xf27(%rip),%rdx
mov    $0x1a,%esi
mov    %ebx,%ecx
call   1040 <_panic@plt>
movslq %ebx,%rax
imul   $0x66666667,%rax,%rbp
mov    %rbp,%rax
shr    $0x3f,%rax
sar    $0x22,%rbp
add    %eax,%ebp
lea    0x3f200000(,%rbp,4),%r14d
3f
mov    %r14d,%edi
call   1070 <get32@plt>
add    %ebp,%ebp
lea    0x0(%rbp,%rbp,4),%ecx
sub    %ecx,%ebx
lea    (%rbx,%rbx,2),%ecx
mov    $0x7,%esi
shl    %cl,%esi
not    %esi
and    %eax,%esi
bts    %ecx,%esi
mov    %r14d,%edi
call   1060 <put32@plt>
xor    %edi,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <_sleep@plt>

LLVM IR (-O0):
@.str = [148 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Yradex/RaspberryPi3_OS/refs/heads/master/os/driver/gpio.c\00"
@.str.1 = [20 x i8] c"GPIO%d out of range\00"
define void @gpio_output_init(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @check_if_gpio_legal(i32 %4)
%6 = icmp ne i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %1
%8 = load i32, i32* %2
%9 = call i32 @_panic(i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str, i64 0, i64 0), i32 26, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %7, %1
%11 = load i32, i32* %2
%12 = sdiv i32 %11, 10
%13 = mul nsw i32 4, %12
%14 = sext i32 %13 to i64
%15 = add i64 -1098452566016, %14
%16 = trunc i64 %15 to i32
%17 = call i32 @get32(i32 %16)
store i32 %17, i32* %3
%18 = load i32, i32* %2
%19 = srem i32 %18, 10
%20 = mul nsw i32 %19, 3
%21 = shl i32 7, %20
%22 = xor i32 %21, -1
%23 = load i32, i32* %3
%24 = and i32 %23, %22
store i32 %24, i32* %3
%25 = load i32, i32* %2
%26 = srem i32 %25, 10
%27 = mul nsw i32 %26, 3
%28 = shl i32 1, %27
%29 = load i32, i32* %3
%30 = or i32 %29, %28
store i32 %30, i32* %3
%31 = load i32, i32* %2
%32 = sdiv i32 %31, 10
%33 = mul nsw i32 4, %32
%34 = sext i32 %33 to i64
%35 = add i64 -1098452566016, %34
%36 = trunc i64 %35 to i32
%37 = load i32, i32* %3
%38 = call i32 @put32(i32 %36, i32 %37)
%39 = call i32 @_sleep(i32 0)
ret void
}

LLVM IR (-O2):
@.str = [148 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Yradex/RaspberryPi3_OS/refs/heads/master/os/driver/gpio.c\00"
@.str.1 = [20 x i8] c"GPIO%d out of range\00"
define void @gpio_output_init(i32 %0) {
%2 = tail call i32 @check_if_gpio_legal(i32 %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @_panic(i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str, i64 0, i64 0), i32 26, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %6
6: ; preds = %4, %1
%7 = sdiv i32 %0, 10
%8 = shl nsw i32 %7, 2
%9 = add nsw i32 %8, 1059061760
%10 = tail call i32 @get32(i32 %9)
%11 = srem i32 %0, 10
%12 = mul nsw i32 %11, 3
%13 = shl nuw nsw i32 7, %12
%14 = xor i32 %13, -1
%15 = and i32 %10, %14
%16 = shl nuw nsw i32 1, %12
%17 = or i32 %15, %16
%18 = tail call i32 @put32(i32 %9, i32 %17)
%19 = tail call i32 @_sleep(i32 0)
ret void
}