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

/* Variables and functions */
int /*<<< orphan*/ be200_cmd_rd(int, int);
int /*<<< orphan*/ be200_cmd_wr(int, int, int);
int /*<<< orphan*/ uart1_writeb(int /*<<< orphan*/);
void be200_base_test(uint8_t idx) {
  uint8_t i;
  for (i = 0; i < 44; i++) {
    be200_cmd_wr(idx, i, i);
  }
  for (i = 0; i < 44; i++) {
    uart1_writeb(be200_cmd_rd(idx, i));
  }
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x2c,-0x8(%rbp)
jge    1168 <be200_base_test+0x38>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1050 <be200_cmd_wr@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1142 <be200_base_test+0x12>
movl   $0x0,-0x8(%rbp)
cmpl   $0x2c,-0x8(%rbp)
jge    1199 <be200_base_test+0x69>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <be200_cmd_rd@plt>
mov    %eax,%edi
call   1030 <uart1_writeb@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116f <be200_base_test+0x3f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %ebp,%esi
mov    %ebp,%edx
call   1050 <be200_cmd_wr@plt>
add    $0x1,%ebp
cmp    $0x2c,%ebp
jne    1140 <be200_base_test+0x10>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%edi
mov    %ebp,%esi
call   1040 <be200_cmd_rd@plt>
mov    %eax,%edi
call   1030 <uart1_writeb@plt>
add    $0x1,%ebp
cmp    $0x2c,%ebp
jne    1160 <be200_base_test+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @be200_base_test(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %12, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 44
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = load i32, i32* %3
%11 = call i32 @be200_cmd_wr(i32 %8, i32 %9, i32 %10)
br label %12
12: ; preds = %7
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
br label %4
15: ; preds = %4
store i32 0, i32* %3
br label %16
16: ; preds = %24, %15
%17 = load i32, i32* %3
%18 = icmp slt i32 %17, 44
br i1 %18, label %19, label %27
19: ; preds = %16
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = call i32 @be200_cmd_rd(i32 %20, i32 %21)
%23 = call i32 @uart1_writeb(i32 %22)
br label %24
24: ; preds = %19
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %16
27: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @be200_base_test(i32 %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ 0, %1 ], [ %5, %2 ]
%4 = tail call i32 @be200_cmd_wr(i32 %0, i32 %3, i32 %3)
%5 = add nuw nsw i32 %3, 1
%6 = icmp eq i32 %5, 44
br i1 %6, label %7, label %2
7: ; preds = %2, %7
%8 = phi i32 [ %11, %7 ], [ 0, %2 ]
%9 = tail call i32 @be200_cmd_rd(i32 %0, i32 %8)
%10 = tail call i32 @uart1_writeb(i32 %9)
%11 = add nuw nsw i32 %8, 1
%12 = icmp eq i32 %11, 44
br i1 %12, label %13, label %7
13: ; preds = %7
ret void
}