#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 */
scalar_t__ getData(unsigned char *);
scalar_t__ isEmpty();
int /*<<< orphan*/ uart_tx_int_disable();
void do_uart_irq(void) {
  int i;
  int cnt;
  unsigned char c;
  if ((*((volatile unsigned long *)0x7F005030)) & (1 << 2)) {
    if (isEmpty()) {
      uart_tx_int_disable();
    } else {
      cnt = ((*((volatile unsigned long *)0x7F005018)) >> 8) & 0x3f;
      cnt = 64 - cnt;
      for (i = 0; i < cnt; i++) {
        if (getData(&c) == 0) {
          (*((volatile unsigned char *)0x7F005020)) = c;
        } else {
          break;
        }
      }
    }
  } else if ((*((volatile unsigned long *)0x7F005030)) & (1 << 0)) {
  }
  (*((volatile unsigned long *)0x7F005030)) = 0xf;
}


x86 assembly (clang, -O0):
<do_uart_irq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x7f005030,%eax
mov    (%rax),%rax
and    $0x4,%rax
cmp    $0x0,%rax
je     11e0 <do_uart_irq+0xb0>
mov    $0x0,%al
call   1040 <isEmpty@plt>
cmp    $0x0,%rax
je     116b <do_uart_irq+0x3b>
mov    $0x0,%al
call   1050 <uart_tx_int_disable@plt>
jmp    11db <do_uart_irq+0xab>
mov    $0x7f005018,%eax
mov    (%rax),%rax
shr    $0x8,%rax
and    $0x3f,%rax
mov    %eax,-0x8(%rbp)
mov    $0x40,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d6 <do_uart_irq+0xa6>
lea    -0x9(%rbp),%rdi
call   1030 <getData@plt>
cmp    $0x0,%rax
jne    11be <do_uart_irq+0x8e>
mov    -0x9(%rbp),%cl
mov    $0x7f005020,%eax
mov    %cl,(%rax)
jmp    11c3 <do_uart_irq+0x93>
jmp    11d6 <do_uart_irq+0xa6>
jmp    11c8 <do_uart_irq+0x98>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1190 <do_uart_irq+0x60>
jmp    11db <do_uart_irq+0xab>
jmp    1200 <do_uart_irq+0xd0>
mov    $0x7f005030,%eax
mov    (%rax),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     11fb <do_uart_irq+0xcb>
jmp    11fb <do_uart_irq+0xcb>
jmp    1200 <do_uart_irq+0xd0>
mov    $0x7f005030,%eax
movq   $0xf,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_uart_irq>:
push   %r14
push   %rbx
push   %rax
testq  $0x4,0x7f005030
jne    114c <do_uart_irq+0x1c>
mov    0x7f005030,%rax
7f
jmp    119d <do_uart_irq+0x6d>
xor    %eax,%eax
call   1040 <isEmpty@plt>
test   %rax,%rax
je     1161 <do_uart_irq+0x31>
xor    %eax,%eax
call   1050 <uart_tx_int_disable@plt>
jmp    119d <do_uart_irq+0x6d>
mov    0x7f005018,%rbx
7f
shr    $0x8,%ebx
or     $0xffffffc0,%ebx
lea    0x7(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1030 <getData@plt>
test   %rax,%rax
jne    119d <do_uart_irq+0x6d>
movzbl 0x7(%rsp),%eax
mov    %al,0x7f005020
inc    %ebx
jne    1180 <do_uart_irq+0x50>
movq   $0xf,0x7f005030
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @do_uart_irq() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = load volatile i64, i64* inttoptr (i64 2130726960 to i64*)
%5 = and i64 %4, 4
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %35
7: ; preds = %0
%8 = call i64 (...) @isEmpty()
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call i32 (...) @uart_tx_int_disable()
br label %34
12: ; preds = %7
%13 = load volatile i64, i64* inttoptr (i64 2130726936 to i64*)
%14 = lshr i64 %13, 8
%15 = and i64 %14, 63
%16 = trunc i64 %15 to i32
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = sub nsw i32 64, %17
store i32 %18, i32* %2
store i32 0, i32* %1
br label %19
19: ; preds = %30, %12
%20 = load i32, i32* %1
%21 = load i32, i32* %2
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %33
23: ; preds = %19
%24 = call i64 @getData(i8* %3)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = load i8, i8* %3
store volatile i8 %27, i8* inttoptr (i64 2130726944 to i8*)
br label %29
28: ; preds = %23
br label %33
29: ; preds = %26
br label %30
30: ; preds = %29
%31 = load i32, i32* %1
%32 = add nsw i32 %31, 1
store i32 %32, i32* %1
br label %19
33: ; preds = %28, %19
br label %34
34: ; preds = %33, %10
br label %41
35: ; preds = %0
%36 = load volatile i64, i64* inttoptr (i64 2130726960 to i64*)
%37 = and i64 %36, 1
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %35
br label %40
40: ; preds = %39, %35
br label %41
41: ; preds = %40, %34
store volatile i64 15, i64* inttoptr (i64 2130726960 to i64*)
ret void
}

LLVM IR (-O2):
define void @do_uart_irq() {
%1 = alloca i8
%2 = load volatile i64, i64* inttoptr (i64 2130726960 to i64*)
%3 = and i64 %2, 4
%4 = icmp eq i64 %3, 0
br i1 %4, label %24, label %5
5: ; preds = %0
%6 = tail call i64 (...) @isEmpty()
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 (...) @uart_tx_int_disable()
br label %26
10: ; preds = %5
%11 = load volatile i64, i64* inttoptr (i64 2130726936 to i64*)
%12 = trunc i64 %11 to i32
%13 = lshr i32 %12, 8
%14 = and i32 %13, 63
%15 = sub nuw nsw i32 64, %14
br label %16
16: ; preds = %10, %20
%17 = phi i32 [ %22, %20 ], [ 0, %10 ]
%18 = call i64 @getData(i8* %1)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %16
%21 = load i8, i8* %1
store volatile i8 %21, i8* inttoptr (i64 2130726944 to i8*)
%22 = add nuw nsw i32 %17, 1
%23 = icmp eq i32 %22, %15
br i1 %23, label %26, label %16
24: ; preds = %0
%25 = load volatile i64, i64* inttoptr (i64 2130726960 to i64*)
br label %26
26: ; preds = %20, %16, %8, %24
store volatile i64 15, i64* inttoptr (i64 2130726960 to i64*)
ret void
}