#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 uint32_t;

/* Variables and functions */
void OneWireTransaction(uint32_t ui32Base, uint32_t ui32OpMode,
                        uint32_t ui32Data, uint32_t ui32BitCnt) {
  uint32_t ui32Transaction;
  ;

  ;
  ;
  ui32Transaction = (*((volatile uint32_t *)(ui32Base + 0x00000000))) &
                    ~((0x00000006 | 0x00000018 | 0x00070000));
  ui32Transaction |= (ui32OpMode & (0x00000001 | 0x00000004 | 0x00000002));
  if (ui32Transaction & (0x00000004 | 0x00000002)) {
    ui32Transaction |=
        ((((ui32BitCnt % 8) ? (ui32BitCnt / 8) + 1 : (ui32BitCnt / 8)) - 1)
         << 3);
    ui32Transaction |= ((ui32BitCnt % 8) << 16);
    if (ui32Transaction & 0x00000004) {
      (*((volatile uint32_t *)(ui32Base + 0x00000008))) = ui32Data;
    }
  }
  (*((volatile uint32_t *)(ui32Base + 0x00000000))) = ui32Transaction;
}


x86 assembly (clang, -O0):
<OneWireTransaction>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0x0,%eax
cltq
mov    (%rax),%eax
and    $0xfff8ffe1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
and    $0x7,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
and    $0x6,%eax
cmp    $0x0,%eax
je     11bb <OneWireTransaction+0xbb>
mov    -0x10(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1167 <OneWireTransaction+0x67>
mov    -0x10(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1175 <OneWireTransaction+0x75>
mov    -0x10(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
shl    $0x3,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
shl    $0x10,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     11b6 <OneWireTransaction+0xb6>
mov    -0xc(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0x8,%eax
cltq
mov    %ecx,(%rax)
jmp    11bb <OneWireTransaction+0xbb>
mov    -0x14(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0x0,%eax
cltq
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<OneWireTransaction>:
movslq %edi,%r8
mov    $0xfff8ffe1,%eax
and    (%r8),%eax
mov    %esi,%edi
and    $0x7,%edi
or     %eax,%edi
test   $0x6,%sil
je     114c <OneWireTransaction+0x4c>
lea    0x7(%rcx),%eax
test   %ecx,%ecx
cmovns %ecx,%eax
mov    %eax,%r9d
sar    $0x3,%r9d
and    $0xfffffff8,%eax
sub    %eax,%ecx
cmp    $0x1,%ecx
sbb    $0xffffffff,%r9d
lea    -0x8(,%r9,8),%eax
ff
shl    $0x10,%ecx
or     %ecx,%edi
or     %eax,%edi
test   $0x4,%sil
je     114c <OneWireTransaction+0x4c>
mov    %edx,0x8(%r8)
mov    %edi,(%r8)
ret

LLVM IR (-O0):
define void @OneWireTransaction(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %5
%11 = add nsw i32 %10, 0
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i32*
%14 = load volatile i32, i32* %13
%15 = and i32 %14, -458783
store i32 %15, i32* %9
%16 = load i32, i32* %6
%17 = and i32 %16, 7
%18 = load i32, i32* %9
%19 = or i32 %18, %17
store i32 %19, i32* %9
%20 = load i32, i32* %9
%21 = and i32 %20, 6
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %55
23: ; preds = %4
%24 = load i32, i32* %8
%25 = srem i32 %24, 8
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %23
%28 = load i32, i32* %8
%29 = sdiv i32 %28, 8
%30 = add nsw i32 %29, 1
br label %34
31: ; preds = %23
%32 = load i32, i32* %8
%33 = sdiv i32 %32, 8
br label %34
34: ; preds = %31, %27
%35 = phi i32 [ %30, %27 ], [ %33, %31 ]
%36 = sub nsw i32 %35, 1
%37 = shl i32 %36, 3
%38 = load i32, i32* %9
%39 = or i32 %38, %37
store i32 %39, i32* %9
%40 = load i32, i32* %8
%41 = srem i32 %40, 8
%42 = shl i32 %41, 16
%43 = load i32, i32* %9
%44 = or i32 %43, %42
store i32 %44, i32* %9
%45 = load i32, i32* %9
%46 = and i32 %45, 4
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %54
48: ; preds = %34
%49 = load i32, i32* %7
%50 = load i32, i32* %5
%51 = add nsw i32 %50, 8
%52 = sext i32 %51 to i64
%53 = inttoptr i64 %52 to i32*
store volatile i32 %49, i32* %53
br label %54
54: ; preds = %48, %34
br label %55
55: ; preds = %54, %4
%56 = load i32, i32* %9
%57 = load i32, i32* %5
%58 = add nsw i32 %57, 0
%59 = sext i32 %58 to i64
%60 = inttoptr i64 %59 to i32*
store volatile i32 %56, i32* %60
ret void
}

LLVM IR (-O2):
define void @OneWireTransaction(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = sext i32 %0 to i64
%6 = inttoptr i64 %5 to i32*
%7 = load volatile i32, i32* %6
%8 = and i32 %7, -458783
%9 = and i32 %1, 7
%10 = or i32 %8, %9
%11 = and i32 %1, 6
%12 = icmp eq i32 %11, 0
br i1 %12, label %30, label %13
13: ; preds = %4
%14 = srem i32 %3, 8
%15 = icmp ne i32 %14, 0
%16 = sdiv i32 %3, 8
%17 = zext i1 %15 to i32
%18 = add nsw i32 %16, %17
%19 = shl i32 %18, 3
%20 = add i32 %19, -8
%21 = shl nsw i32 %14, 16
%22 = or i32 %10, %21
%23 = or i32 %22, %20
%24 = and i32 %1, 4
%25 = icmp eq i32 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %13
%27 = add nsw i32 %0, 8
%28 = sext i32 %27 to i64
%29 = inttoptr i64 %28 to i32*
store volatile i32 %2, i32* %29
br label %30
30: ; preds = %13, %26, %4
%31 = phi i32 [ %23, %26 ], [ %23, %13 ], [ %10, %4 ]
store volatile i32 %31, i32* %6
ret void
}