#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*/ mips_intr_disable();
void soft_reset() {
  mips_intr_disable();
  if (!(*(volatile unsigned *)(0xBF800000 + (0x83000)) & 0x1000)) {
    *(volatile unsigned *)(0xBF800000 + (0x83008)) = 0x1000;
    while (*(volatile unsigned *)(0xBF800000 + (0x83000)) & 0x800)
      continue;
  }
  *(volatile unsigned *)(0xBF800000 + (0xf230)) = 0;
  *(volatile unsigned *)(0xBF800000 + (0xf230)) = 0xaa996655;
  *(volatile unsigned *)(0xBF800000 + (0xf230)) = 0x556699aa;
  *(volatile unsigned *)(0xBF800000 + (0xf618)) = 1;
  (void)*(volatile unsigned *)(0xBF800000 + (0xf610));
  for (;;)
    continue;
}


x86 assembly (clang, -O0):
<soft_reset>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1030 <mips_intr_disable@plt>
mov    $0xbf883000,%eax
mov    (%rax),%eax
and    $0x1000,%eax
cmp    $0x0,%eax
jne    115a <soft_reset+0x4a>
mov    $0xbf883008,%eax
movl   $0x1000,(%rax)
mov    $0xbf883000,%eax
mov    (%rax),%eax
and    $0x800,%eax
cmp    $0x0,%eax
je     1155 <soft_reset+0x45>
jmp    113b <soft_reset+0x2b>
jmp    115a <soft_reset+0x4a>
mov    $0xbf80f230,%eax
movl   $0x0,(%rax)
mov    $0xbf80f230,%eax
movl   $0xaa996655,(%rax)
mov    $0xbf80f230,%eax
movl   $0x556699aa,(%rax)
mov    $0xbf80f618,%eax
movl   $0x1,(%rax)
mov    $0xbf80f610,%eax
mov    (%rax),%eax
jmp    118d <soft_reset+0x7d>

x86 assembly (clang, -O2):
<soft_reset>:
push   %rbx
mov    $0xbf80f230,%ebx
xor    %eax,%eax
call   1030 <mips_intr_disable@plt>
testl  $0x1000,0x73dd0(%rbx)
jne    114c <soft_reset+0x3c>
movl   $0x1000,0x73dd8(%rbx)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
testl  $0x800,0x73dd0(%rbx)
jne    1140 <soft_reset+0x30>
movl   $0x0,(%rbx)
movl   $0xaa996655,(%rbx)
movl   $0x556699aa,(%rbx)
movl   $0x1,0x3e8(%rbx)
mov    0x3e0(%rbx),%eax
xchg   %ax,%ax
jmp    1170 <soft_reset+0x60>

LLVM IR (-O0):
define void @soft_reset() {
%1 = call i32 (...) @mips_intr_disable()
%2 = load volatile i32, i32* inttoptr (i64 3213373440 to i32*)
%3 = and i32 %2, 4096
%4 = icmp ne i32 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %0
store volatile i32 4096, i32* inttoptr (i64 3213373448 to i32*)
br label %6
6: ; preds = %10, %5
%7 = load volatile i32, i32* inttoptr (i64 3213373440 to i32*)
%8 = and i32 %7, 2048
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %6
br label %6
11: ; preds = %6
br label %12
12: ; preds = %11, %0
store volatile i32 0, i32* inttoptr (i64 3212898864 to i32*)
store volatile i32 -1432787371, i32* inttoptr (i64 3212898864 to i32*)
store volatile i32 1432787370, i32* inttoptr (i64 3212898864 to i32*)
store volatile i32 1, i32* inttoptr (i64 3212899864 to i32*)
%13 = load volatile i32, i32* inttoptr (i64 3212899856 to i32*)
br label %14
14: ; preds = %14, %12
br label %14
}

LLVM IR (-O2):
define void @soft_reset() {
%1 = tail call i32 (...) @mips_intr_disable()
%2 = load volatile i32, i32* inttoptr (i64 3213373440 to i32*)
%3 = and i32 %2, 4096
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %0
store volatile i32 4096, i32* inttoptr (i64 3213373448 to i32*)
br label %6
6: ; preds = %6, %5
%7 = load volatile i32, i32* inttoptr (i64 3213373440 to i32*)
%8 = and i32 %7, 2048
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %6
10: ; preds = %6, %0
store volatile i32 0, i32* inttoptr (i64 3212898864 to i32*)
store volatile i32 -1432787371, i32* inttoptr (i64 3212898864 to i32*)
store volatile i32 1432787370, i32* inttoptr (i64 3212898864 to i32*)
store volatile i32 1, i32* inttoptr (i64 3212899864 to i32*)
%11 = load volatile i32, i32* inttoptr (i64 3212899856 to i32*)
br label %12
12: ; preds = %12, %10
br label %12
}