#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 */
typedef int uint16_t;

/* Variables and functions */
int read_from_spi(int);
int /*<<< orphan*/ write_to_spi(int, int);
void cca_modus(void) {
  uint16_t buffer;
  buffer = read_from_spi(0x06);
  buffer = buffer | (1);
  buffer = buffer & ~(2);
  write_to_spi(0x06, buffer);
  buffer = read_from_spi(0x06);
  buffer = buffer | (1 << 4);
  buffer = buffer & ~(1 << 5);
  write_to_spi(0x06, buffer);
  buffer = read_from_spi(0x29);
  buffer = buffer & (0x00FF);
  buffer = buffer / (-2);
}


x86 assembly (clang, -O0):
<cca_modus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x6,%edi
call   1030 <read_from_spi@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xfffffffd,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
mov    $0x6,%edi
call   1040 <write_to_spi@plt>
mov    $0x6,%edi
call   1030 <read_from_spi@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
or     $0x10,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xffffffdf,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
mov    $0x6,%edi
call   1040 <write_to_spi@plt>
mov    $0x29,%edi
call   1030 <read_from_spi@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xfffffffe,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cca_modus>:
push   %rax
mov    $0x6,%edi
call   1030 <read_from_spi@plt>
and    $0xfffffffc,%eax
lea    0x1(%rax),%esi
mov    $0x6,%edi
call   1040 <write_to_spi@plt>
mov    $0x6,%edi
call   1030 <read_from_spi@plt>
and    $0xffffffcf,%eax
lea    0x10(%rax),%esi
mov    $0x6,%edi
call   1040 <write_to_spi@plt>
mov    $0x29,%edi
pop    %rax
jmp    1030 <read_from_spi@plt>

LLVM IR (-O0):
define void @cca_modus() {
%1 = alloca i32
%2 = call i32 @read_from_spi(i32 6)
store i32 %2, i32* %1
%3 = load i32, i32* %1
%4 = or i32 %3, 1
store i32 %4, i32* %1
%5 = load i32, i32* %1
%6 = and i32 %5, -3
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = call i32 @write_to_spi(i32 6, i32 %7)
%9 = call i32 @read_from_spi(i32 6)
store i32 %9, i32* %1
%10 = load i32, i32* %1
%11 = or i32 %10, 16
store i32 %11, i32* %1
%12 = load i32, i32* %1
%13 = and i32 %12, -33
store i32 %13, i32* %1
%14 = load i32, i32* %1
%15 = call i32 @write_to_spi(i32 6, i32 %14)
%16 = call i32 @read_from_spi(i32 41)
store i32 %16, i32* %1
%17 = load i32, i32* %1
%18 = and i32 %17, 255
store i32 %18, i32* %1
%19 = load i32, i32* %1
%20 = sdiv i32 %19, -2
store i32 %20, i32* %1
ret void
}

LLVM IR (-O2):
define void @cca_modus() {
%1 = tail call i32 @read_from_spi(i32 6)
%2 = and i32 %1, -4
%3 = or i32 %2, 1
%4 = tail call i32 @write_to_spi(i32 6, i32 %3)
%5 = tail call i32 @read_from_spi(i32 6)
%6 = and i32 %5, -49
%7 = or i32 %6, 16
%8 = tail call i32 @write_to_spi(i32 6, i32 %7)
%9 = tail call i32 @read_from_spi(i32 41)
ret void
}