int ssn_ddrt_init(int mode, int code_stream, unsigned long burst_num,
                  unsigned long send_len, unsigned long addr,
                  unsigned int reversed_bit) {
  unsigned int regval;
  unsigned int value;
  (*(volatile unsigned int *)(0x206d0000 + 0x10) = (burst_num));
  (*(volatile unsigned int *)(0x206d0000 + 0x18) = (send_len));
  (*(volatile unsigned int *)(0x206d0000 + 0x20) = (addr));
  (*(volatile unsigned int *)(0x206d0000 + 0x30) = (reversed_bit));
  (*(volatile unsigned int *)(0x206d0000 + 0x0) = (mode | code_stream | 0x1));
  do {
    regval = (*(volatile unsigned int *)(0x206d0000 + 0x4));
  } while (!(regval & 0x01));
  value = (regval & 0x02) ? 0 : -1;
  return value;
}


x86 assembly (clang, -O0):
<ssn_ddrt_init>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,%ecx
mov    $0x206d0010,%eax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    %eax,%ecx
mov    $0x206d0018,%eax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
mov    $0x206d0020,%eax
mov    %ecx,(%rax)
mov    -0x24(%rbp),%ecx
mov    $0x206d0030,%eax
mov    %ecx,(%rax)
mov    -0x4(%rbp),%ecx
or     -0x8(%rbp),%ecx
or     $0x1,%ecx
mov    $0x206d0000,%eax
mov    %ecx,(%rax)
mov    $0x206d0004,%eax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    115b <ssn_ddrt_init+0x5b>
mov    -0x28(%rbp),%edx
and    $0x2,%edx
mov    $0xffffffff,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ssn_ddrt_init>:
mov    %edx,0x206d0010
mov    %ecx,0x206d0018
mov    %r8d,0x206d0020
20
mov    %r9d,0x206d0030
20
or     %esi,%edi
or     $0x1,%edi
mov    %edi,0x206d0000
nopw   0x0(%rax,%rax,1)
mov    0x206d0004,%eax
test   $0x1,%al
je     1130 <ssn_ddrt_init+0x30>
shr    %eax
and    $0x1,%eax
add    $0xffffffff,%eax
ret

LLVM IR (-O0):
define i32 @ssn_ddrt_init(i32 %0, i32 %1, i64 %2, i64 %3, i64 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i64 %2, i64* %9
store i64 %3, i64* %10
store i64 %4, i64* %11
store i32 %5, i32* %12
%15 = load i64, i64* %9
%16 = trunc i64 %15 to i32
store volatile i32 %16, i32* inttoptr (i64 544014352 to i32*)
%17 = load i64, i64* %10
%18 = trunc i64 %17 to i32
store volatile i32 %18, i32* inttoptr (i64 544014360 to i32*)
%19 = load i64, i64* %11
%20 = trunc i64 %19 to i32
store volatile i32 %20, i32* inttoptr (i64 544014368 to i32*)
%21 = load i32, i32* %12
store volatile i32 %21, i32* inttoptr (i64 544014384 to i32*)
%22 = load i32, i32* %7
%23 = load i32, i32* %8
%24 = or i32 %22, %23
%25 = or i32 %24, 1
store volatile i32 %25, i32* inttoptr (i64 544014336 to i32*)
br label %26
26: ; preds = %28, %6
%27 = load volatile i32, i32* inttoptr (i64 544014340 to i32*)
store i32 %27, i32* %13
br label %28
28: ; preds = %26
%29 = load i32, i32* %13
%30 = and i32 %29, 1
%31 = icmp ne i32 %30, 0
%32 = xor i1 %31, true
br i1 %32, label %26, label %33
33: ; preds = %28
%34 = load i32, i32* %13
%35 = and i32 %34, 2
%36 = icmp ne i32 %35, 0
%37 = zext i1 %36 to i64
%38 = select i1 %36, i32 0, i32 -1
store i32 %38, i32* %14
%39 = load i32, i32* %14
ret i32 %39
}

LLVM IR (-O2):
define i32 @ssn_ddrt_init(i32 %0, i32 %1, i64 %2, i64 %3, i64 %4, i32 %5) {
%7 = trunc i64 %2 to i32
store volatile i32 %7, i32* inttoptr (i64 544014352 to i32*)
%8 = trunc i64 %3 to i32
store volatile i32 %8, i32* inttoptr (i64 544014360 to i32*)
%9 = trunc i64 %4 to i32
store volatile i32 %9, i32* inttoptr (i64 544014368 to i32*)
store volatile i32 %5, i32* inttoptr (i64 544014384 to i32*)
%10 = or i32 %0, %1
%11 = or i32 %10, 1
store volatile i32 %11, i32* inttoptr (i64 544014336 to i32*)
br label %12
12: ; preds = %12, %6
%13 = load volatile i32, i32* inttoptr (i64 544014340 to i32*)
%14 = and i32 %13, 1
%15 = icmp eq i32 %14, 0
br i1 %15, label %12, label %16
16: ; preds = %12
%17 = lshr i32 %13, 1
%18 = and i32 %17, 1
%19 = add nsw i32 %18, -1
ret i32 %19
}