#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 DM9000_ior(int);
int /*<<< orphan*/ DM9000_iow(int, int);
int /*<<< orphan*/ sw_printf(char *);
int /*<<< orphan*/ sw_usleep(int);
void dm9000_reset(void) {
  ;
  DM9000_iow(0x1e, (1 << 0));
  DM9000_iow(0x1f, 0);
  DM9000_iow(0x00, ((1 << 1) | (1 << 0)));
  do {
    ;
    sw_usleep(25);
  } while (DM9000_ior(0x00) & 1);
  DM9000_iow(0x00, 0);
  DM9000_iow(0x00, ((1 << 1) | (1 << 0)));
  do {
    ;
    sw_usleep(25);
  } while (DM9000_ior(0x00) & 1);
  if ((DM9000_ior(0x2A) != 0x0) || (DM9000_ior(0x2B) != 0x90))
    sw_printf("ERROR: resetting DM9000 -> not responding\n");
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
mov    $0x1e,%edi
mov    $0x1,%esi
call   1030 <DM9000_iow@plt>
mov    $0x1f,%edi
xor    %esi,%esi
call   1030 <DM9000_iow@plt>
xor    %edi,%edi
mov    $0x3,%esi
call   1030 <DM9000_iow@plt>
mov    $0x19,%edi
call   1060 <sw_usleep@plt>
xor    %edi,%edi
call   1050 <DM9000_ior@plt>
and    $0x1,%eax
cmp    $0x0,%eax
jne    116b <dm9000_reset+0x2b>
xor    %esi,%esi
mov    %esi,%edi
call   1030 <DM9000_iow@plt>
xor    %edi,%edi
mov    $0x3,%esi
call   1030 <DM9000_iow@plt>
mov    $0x19,%edi
call   1060 <sw_usleep@plt>
xor    %edi,%edi
call   1050 <DM9000_ior@plt>
and    $0x1,%eax
cmp    $0x0,%eax
jne    119d <dm9000_reset+0x5d>
mov    $0x2a,%edi
call   1050 <DM9000_ior@plt>
cmp    $0x0,%eax
jne    11e2 <dm9000_reset+0xa2>
mov    $0x2b,%edi
call   1050 <DM9000_ior@plt>
cmp    $0x90,%eax
je     11ee <dm9000_reset+0xae>
lea    0xe17(%rip),%rdi
call   1040 <sw_printf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rax
mov    $0x1e,%edi
mov    $0x1,%esi
call   1030 <DM9000_iow@plt>
mov    $0x1f,%edi
xor    %esi,%esi
call   1030 <DM9000_iow@plt>
xor    %edi,%edi
mov    $0x3,%esi
call   1030 <DM9000_iow@plt>
nopl   0x0(%rax,%rax,1)
mov    $0x19,%edi
call   1060 <sw_usleep@plt>
xor    %edi,%edi
call   1050 <DM9000_ior@plt>
test   $0x1,%al
jne    1170 <dm9000_reset+0x30>
xor    %edi,%edi
xor    %esi,%esi
call   1030 <DM9000_iow@plt>
xor    %edi,%edi
mov    $0x3,%esi
call   1030 <DM9000_iow@plt>
nopw   0x0(%rax,%rax,1)
mov    $0x19,%edi
call   1060 <sw_usleep@plt>
xor    %edi,%edi
call   1050 <DM9000_ior@plt>
test   $0x1,%al
jne    11a0 <dm9000_reset+0x60>
mov    $0x2a,%edi
call   1050 <DM9000_ior@plt>
test   %eax,%eax
jne    11d6 <dm9000_reset+0x96>
mov    $0x2b,%edi
call   1050 <DM9000_ior@plt>
cmp    $0x90,%eax
jne    11d6 <dm9000_reset+0x96>
pop    %rax
ret
lea    0xe23(%rip),%rdi
pop    %rax
jmp    1040 <sw_printf@plt>

LLVM IR (-O0):
@.str = [43 x i8] c"ERROR: resetting DM9000 -> not responding\0A\00"
define void @dm9000_reset() {
%1 = call i32 @DM9000_iow(i32 30, i32 1)
%2 = call i32 @DM9000_iow(i32 31, i32 0)
%3 = call i32 @DM9000_iow(i32 0, i32 3)
br label %4
4: ; preds = %6, %0
%5 = call i32 @sw_usleep(i32 25)
br label %6
6: ; preds = %4
%7 = call i32 @DM9000_ior(i32 0)
%8 = and i32 %7, 1
%9 = icmp ne i32 %8, 0
br i1 %9, label %4, label %10
10: ; preds = %6
%11 = call i32 @DM9000_iow(i32 0, i32 0)
%12 = call i32 @DM9000_iow(i32 0, i32 3)
br label %13
13: ; preds = %15, %10
%14 = call i32 @sw_usleep(i32 25)
br label %15
15: ; preds = %13
%16 = call i32 @DM9000_ior(i32 0)
%17 = and i32 %16, 1
%18 = icmp ne i32 %17, 0
br i1 %18, label %13, label %19
19: ; preds = %15
%20 = call i32 @DM9000_ior(i32 42)
%21 = icmp ne i32 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = call i32 @DM9000_ior(i32 43)
%24 = icmp ne i32 %23, 144
br i1 %24, label %25, label %27
25: ; preds = %22, %19
%26 = call i32 @sw_printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %25, %22
ret void
}

LLVM IR (-O2):
@.str = [43 x i8] c"ERROR: resetting DM9000 -> not responding\0A\00"
define void @dm9000_reset() {
%1 = tail call i32 @DM9000_iow(i32 30, i32 1)
%2 = tail call i32 @DM9000_iow(i32 31, i32 0)
%3 = tail call i32 @DM9000_iow(i32 0, i32 3)
br label %4
4: ; preds = %4, %0
%5 = tail call i32 @sw_usleep(i32 25)
%6 = tail call i32 @DM9000_ior(i32 0)
%7 = and i32 %6, 1
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %4
9: ; preds = %4
%10 = tail call i32 @DM9000_iow(i32 0, i32 0)
%11 = tail call i32 @DM9000_iow(i32 0, i32 3)
br label %12
12: ; preds = %12, %9
%13 = tail call i32 @sw_usleep(i32 25)
%14 = tail call i32 @DM9000_ior(i32 0)
%15 = and i32 %14, 1
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %12
17: ; preds = %12
%18 = tail call i32 @DM9000_ior(i32 42)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = tail call i32 @DM9000_ior(i32 43)
%22 = icmp eq i32 %21, 144
br i1 %22, label %25, label %23
23: ; preds = %20, %17
%24 = tail call i32 @sw_printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
br label %25
25: ; preds = %23, %20
ret void
}