#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*/ DMAL_ReadUInt32(int, unsigned long *);
int /*<<< orphan*/ DMAL_WriteUInt32(int, unsigned long);
void WriteGx(unsigned long inRegAddr, unsigned long inData) {
  int is_timing_register;
  unsigned long reg_timing_cfg;
  DMAL_WriteUInt32(0x8300, 0x4758);
  is_timing_register = (0x8330 == inRegAddr) || (0x8334 == inRegAddr) ||
                       (0x8338 == inRegAddr) || (0x833C == inRegAddr) ||
                       (0x8340 == inRegAddr) || (0x8344 == inRegAddr) ||
                       (0x8348 == inRegAddr) || (0x834C == inRegAddr);
  if (is_timing_register) {
    DMAL_ReadUInt32(0x8308, &reg_timing_cfg);
    DMAL_WriteUInt32(0x8308, reg_timing_cfg & ~0x0020);
  }
  DMAL_WriteUInt32(inRegAddr, inData);
  if (is_timing_register) {
    DMAL_WriteUInt32(0x8308, reg_timing_cfg);
  }
}


x86 assembly (clang, -O0):
<WriteGx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x8300,%edi
mov    $0x4758,%esi
call   1030 <DMAL_WriteUInt32@plt>
mov    $0x1,%al
mov    $0x8330,%ecx
cmp    -0x8(%rbp),%rcx
mov    %al,-0x21(%rbp)
je     11da <WriteGx+0xba>
mov    $0x1,%al
mov    $0x8334,%ecx
cmp    -0x8(%rbp),%rcx
mov    %al,-0x21(%rbp)
je     11da <WriteGx+0xba>
mov    $0x1,%al
mov    $0x8338,%ecx
cmp    -0x8(%rbp),%rcx
mov    %al,-0x21(%rbp)
je     11da <WriteGx+0xba>
mov    $0x1,%al
mov    $0x833c,%ecx
cmp    -0x8(%rbp),%rcx
mov    %al,-0x21(%rbp)
je     11da <WriteGx+0xba>
mov    $0x1,%al
mov    $0x8340,%ecx
cmp    -0x8(%rbp),%rcx
mov    %al,-0x21(%rbp)
je     11da <WriteGx+0xba>
mov    $0x1,%al
mov    $0x8344,%ecx
cmp    -0x8(%rbp),%rcx
mov    %al,-0x21(%rbp)
je     11da <WriteGx+0xba>
mov    $0x1,%al
mov    $0x8348,%ecx
cmp    -0x8(%rbp),%rcx
mov    %al,-0x21(%rbp)
je     11da <WriteGx+0xba>
mov    $0x834c,%eax
cmp    -0x8(%rbp),%rax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     120f <WriteGx+0xef>
mov    $0x8308,%edi
lea    -0x20(%rbp),%rsi
call   1040 <DMAL_ReadUInt32@plt>
mov    -0x20(%rbp),%rsi
and    $0xffffffffffffffdf,%rsi
mov    $0x8308,%edi
call   1030 <DMAL_WriteUInt32@plt>
mov    -0x8(%rbp),%rax
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
call   1030 <DMAL_WriteUInt32@plt>
cmpl   $0x0,-0x14(%rbp)
je     1236 <WriteGx+0x116>
mov    -0x20(%rbp),%rsi
mov    $0x8308,%edi
call   1030 <DMAL_WriteUInt32@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WriteGx>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x4758,%esi
mov    $0x8300,%edi
call   1030 <DMAL_WriteUInt32@plt>
lea    -0x8330(%rbx),%rax
rol    $0x3e,%rax
cmp    $0x7,%rax
ja     1189 <WriteGx+0x69>
mov    %rsp,%rsi
mov    $0x8308,%edi
call   1040 <DMAL_ReadUInt32@plt>
mov    (%rsp),%rsi
and    $0xffffffffffffffdf,%rsi
mov    $0x8308,%edi
call   1030 <DMAL_WriteUInt32@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <DMAL_WriteUInt32@plt>
mov    (%rsp),%rsi
mov    $0x8308,%edi
call   1030 <DMAL_WriteUInt32@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %ebx,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <DMAL_WriteUInt32@plt>

LLVM IR (-O0):
define void @WriteGx(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
%6 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%7 = call i32 @DMAL_WriteUInt32(i32 33536, i64 18264)
%8 = load i64, i64* %3
%9 = icmp eq i64 33584, %8
br i1 %9, label %31, label %10
10: ; preds = %2
%11 = load i64, i64* %3
%12 = icmp eq i64 33588, %11
br i1 %12, label %31, label %13
13: ; preds = %10
%14 = load i64, i64* %3
%15 = icmp eq i64 33592, %14
br i1 %15, label %31, label %16
16: ; preds = %13
%17 = load i64, i64* %3
%18 = icmp eq i64 33596, %17
br i1 %18, label %31, label %19
19: ; preds = %16
%20 = load i64, i64* %3
%21 = icmp eq i64 33600, %20
br i1 %21, label %31, label %22
22: ; preds = %19
%23 = load i64, i64* %3
%24 = icmp eq i64 33604, %23
br i1 %24, label %31, label %25
25: ; preds = %22
%26 = load i64, i64* %3
%27 = icmp eq i64 33608, %26
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = load i64, i64* %3
%30 = icmp eq i64 33612, %29
br label %31
31: ; preds = %28, %25, %22, %19, %16, %13, %10, %2
%32 = phi i1 [ true, %25 ], [ true, %22 ], [ true, %19 ], [ true, %16 ], [ true, %13 ], [ true, %10 ], [ true, %2 ], [ %30, %28 ]
%33 = zext i1 %32 to i32
store i32 %33, i32* %5
%34 = load i32, i32* %5
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %31
%37 = call i32 @DMAL_ReadUInt32(i32 33544, i64* %6)
%38 = load i64, i64* %6
%39 = and i64 %38, -33
%40 = call i32 @DMAL_WriteUInt32(i32 33544, i64 %39)
br label %41
41: ; preds = %36, %31
%42 = load i64, i64* %3
%43 = trunc i64 %42 to i32
%44 = load i64, i64* %4
%45 = call i32 @DMAL_WriteUInt32(i32 %43, i64 %44)
%46 = load i32, i32* %5
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %41
%49 = load i64, i64* %6
%50 = call i32 @DMAL_WriteUInt32(i32 33544, i64 %49)
br label %51
51: ; preds = %48, %41
ret void
}

LLVM IR (-O2):
define void @WriteGx(i64 %0, i64 %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = tail call i32 @DMAL_WriteUInt32(i32 33536, i64 18264)
%6 = add i64 %0, -33584
%7 = tail call i64 @llvm.fshl.i64(i64 %6, i64 %6, i64 62)
%8 = icmp ult i64 %7, 8
br i1 %8, label %9, label %18
9: ; preds = %2
%10 = call i32 @DMAL_ReadUInt32(i32 33544, i64* %3)
%11 = load i64, i64* %3
%12 = and i64 %11, -33
%13 = call i32 @DMAL_WriteUInt32(i32 33544, i64 %12)
%14 = trunc i64 %0 to i32
%15 = call i32 @DMAL_WriteUInt32(i32 %14, i64 %1)
%16 = load i64, i64* %3
%17 = call i32 @DMAL_WriteUInt32(i32 33544, i64 %16)
br label %21
18: ; preds = %2
%19 = trunc i64 %0 to i32
%20 = tail call i32 @DMAL_WriteUInt32(i32 %19, i64 %1)
br label %21
21: ; preds = %18, %9
ret void
}