#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*/ disable_Centaurus_9211_chip_select();
int /*<<< orphan*/ enable_Centaurus_9211_chip_select();
unsigned long read_Centaurus_CX9211_DWdata();
int /*<<< orphan*/ toggle_Centaurus_9211_clock();
int /*<<< orphan*/ write_Centaurus_CX9211_GPIO(unsigned char);
unsigned long Centaurus_read_gpio(int width, unsigned long address) {
  int num_clock_toggles;
  int count;
  unsigned long Addr = address;
  unsigned long data;
  enable_Centaurus_9211_chip_select();
  write_Centaurus_CX9211_GPIO(0);
  write_Centaurus_CX9211_GPIO(0x1);
  for (count = 0; count < 12; count++) {
    write_Centaurus_CX9211_GPIO((unsigned char)(Addr & 0x01));
    Addr = Addr >> 1;
  }
  data = read_Centaurus_CX9211_DWdata();
  num_clock_toggles = 1;
  disable_Centaurus_9211_chip_select();
  for (count = 0; count < num_clock_toggles; count++) {
    toggle_Centaurus_9211_clock();
  }
  return data;
}


x86 assembly (clang, -O0):
<Centaurus_read_gpio>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1060 <enable_Centaurus_9211_chip_select@plt>
xor    %edi,%edi
call   1050 <write_Centaurus_CX9211_GPIO@plt>
mov    $0x1,%edi
call   1050 <write_Centaurus_CX9211_GPIO@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0xc,-0x18(%rbp)
jge    11ba <Centaurus_read_gpio+0x6a>
mov    -0x20(%rbp),%rax
and    $0x1,%rax
movzbl %al,%edi
call   1050 <write_Centaurus_CX9211_GPIO@plt>
mov    -0x20(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1186 <Centaurus_read_gpio+0x36>
mov    $0x0,%al
call   1030 <read_Centaurus_CX9211_DWdata@plt>
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x14(%rbp)
mov    $0x0,%al
call   1040 <disable_Centaurus_9211_chip_select@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11fb <Centaurus_read_gpio+0xab>
mov    $0x0,%al
call   1070 <toggle_Centaurus_9211_clock@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11da <Centaurus_read_gpio+0x8a>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Centaurus_read_gpio>:
push   %rbx
mov    %rsi,%rbx
xor    %eax,%eax
call   1060 <enable_Centaurus_9211_chip_select@plt>
xor    %edi,%edi
call   1050 <write_Centaurus_CX9211_GPIO@plt>
mov    $0x1,%edi
call   1050 <write_Centaurus_CX9211_GPIO@plt>
mov    %ebx,%edi
and    $0x1,%edi
call   1050 <write_Centaurus_CX9211_GPIO@plt>
mov    %ebx,%eax
shr    %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <write_Centaurus_CX9211_GPIO@plt>
mov    %ebx,%eax
shr    $0x2,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <write_Centaurus_CX9211_GPIO@plt>
mov    %ebx,%eax
shr    $0x3,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <write_Centaurus_CX9211_GPIO@plt>
mov    %ebx,%eax
shr    $0x4,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <write_Centaurus_CX9211_GPIO@plt>
mov    %ebx,%eax
shr    $0x5,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <write_Centaurus_CX9211_GPIO@plt>
mov    %ebx,%eax
shr    $0x6,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <write_Centaurus_CX9211_GPIO@plt>
mov    %ebx,%eax
shr    $0x7,%al
movzbl %al,%edi
call   1050 <write_Centaurus_CX9211_GPIO@plt>
mov    %ebx,%edi
shr    $0x8,%edi
and    $0x1,%edi
call   1050 <write_Centaurus_CX9211_GPIO@plt>
mov    %ebx,%edi
shr    $0x9,%edi
and    $0x1,%edi
call   1050 <write_Centaurus_CX9211_GPIO@plt>
mov    %ebx,%edi
shr    $0xa,%edi
and    $0x1,%edi
call   1050 <write_Centaurus_CX9211_GPIO@plt>
shr    $0xb,%ebx
and    $0x1,%ebx
mov    %ebx,%edi
call   1050 <write_Centaurus_CX9211_GPIO@plt>
xor    %eax,%eax
call   1030 <read_Centaurus_CX9211_DWdata@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <disable_Centaurus_9211_chip_select@plt>
xor    %eax,%eax
call   1070 <toggle_Centaurus_9211_clock@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i64 @Centaurus_read_gpio(i32 %0, i64 %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
store i32 %0, i32* %3
store i64 %1, i64* %4
%9 = load i64, i64* %4
store i64 %9, i64* %7
%10 = call i32 (...) @enable_Centaurus_9211_chip_select()
%11 = call i32 @write_Centaurus_CX9211_GPIO(i8 zeroext 0)
%12 = call i32 @write_Centaurus_CX9211_GPIO(i8 zeroext 1)
store i32 0, i32* %6
br label %13
13: ; preds = %23, %2
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 12
br i1 %15, label %16, label %26
16: ; preds = %13
%17 = load i64, i64* %7
%18 = and i64 %17, 1
%19 = trunc i64 %18 to i8
%20 = call i32 @write_Centaurus_CX9211_GPIO(i8 zeroext %19)
%21 = load i64, i64* %7
%22 = lshr i64 %21, 1
store i64 %22, i64* %7
br label %23
23: ; preds = %16
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %13
26: ; preds = %13
%27 = call i64 (...) @read_Centaurus_CX9211_DWdata()
store i64 %27, i64* %8
store i32 1, i32* %5
%28 = call i32 (...) @disable_Centaurus_9211_chip_select()
store i32 0, i32* %6
br label %29
29: ; preds = %35, %26
%30 = load i32, i32* %6
%31 = load i32, i32* %5
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %38
33: ; preds = %29
%34 = call i32 (...) @toggle_Centaurus_9211_clock()
br label %35
35: ; preds = %33
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %29
38: ; preds = %29
%39 = load i64, i64* %8
ret i64 %39
}

LLVM IR (-O2):
define i64 @Centaurus_read_gpio(i32 %0, i64 %1) {
%3 = tail call i32 (...) @enable_Centaurus_9211_chip_select()
%4 = tail call i32 @write_Centaurus_CX9211_GPIO(i8 zeroext 0)
%5 = tail call i32 @write_Centaurus_CX9211_GPIO(i8 zeroext 1)
%6 = trunc i64 %1 to i8
%7 = and i8 %6, 1
%8 = tail call i32 @write_Centaurus_CX9211_GPIO(i8 zeroext %7)
%9 = trunc i64 %1 to i8
%10 = lshr i8 %9, 1
%11 = and i8 %10, 1
%12 = tail call i32 @write_Centaurus_CX9211_GPIO(i8 zeroext %11)
%13 = trunc i64 %1 to i8
%14 = lshr i8 %13, 2
%15 = and i8 %14, 1
%16 = tail call i32 @write_Centaurus_CX9211_GPIO(i8 zeroext %15)
%17 = trunc i64 %1 to i8
%18 = lshr i8 %17, 3
%19 = and i8 %18, 1
%20 = tail call i32 @write_Centaurus_CX9211_GPIO(i8 zeroext %19)
%21 = trunc i64 %1 to i8
%22 = lshr i8 %21, 4
%23 = and i8 %22, 1
%24 = tail call i32 @write_Centaurus_CX9211_GPIO(i8 zeroext %23)
%25 = trunc i64 %1 to i8
%26 = lshr i8 %25, 5
%27 = and i8 %26, 1
%28 = tail call i32 @write_Centaurus_CX9211_GPIO(i8 zeroext %27)
%29 = trunc i64 %1 to i8
%30 = lshr i8 %29, 6
%31 = and i8 %30, 1
%32 = tail call i32 @write_Centaurus_CX9211_GPIO(i8 zeroext %31)
%33 = trunc i64 %1 to i8
%34 = lshr i8 %33, 7
%35 = tail call i32 @write_Centaurus_CX9211_GPIO(i8 zeroext %34)
%36 = lshr i64 %1, 8
%37 = trunc i64 %36 to i8
%38 = and i8 %37, 1
%39 = tail call i32 @write_Centaurus_CX9211_GPIO(i8 zeroext %38)
%40 = lshr i64 %1, 9
%41 = trunc i64 %40 to i8
%42 = and i8 %41, 1
%43 = tail call i32 @write_Centaurus_CX9211_GPIO(i8 zeroext %42)
%44 = lshr i64 %1, 10
%45 = trunc i64 %44 to i8
%46 = and i8 %45, 1
%47 = tail call i32 @write_Centaurus_CX9211_GPIO(i8 zeroext %46)
%48 = lshr i64 %1, 11
%49 = trunc i64 %48 to i8
%50 = and i8 %49, 1
%51 = tail call i32 @write_Centaurus_CX9211_GPIO(i8 zeroext %50)
%52 = tail call i64 (...) @read_Centaurus_CX9211_DWdata()
%53 = tail call i32 (...) @disable_Centaurus_9211_chip_select()
%54 = tail call i32 (...) @toggle_Centaurus_9211_clock()
ret i64 %52
}