#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*/ printf(char *, ...);
unsigned int scan_file(char const *, char *);
void decode_state(const char *prefix) {
  unsigned int NEXT_DESC_PTR = scan_file(prefix, "NEXT_DESC_PTR");
  unsigned int START_ADDR = scan_file(prefix, "START_ADDR");
  unsigned int CONFIG = scan_file(prefix, "CONFIG");
  unsigned int X_COUNT = scan_file(prefix, "X_COUNT");
  unsigned int X_MODIFY = scan_file(prefix, "X_MODIFY");
  unsigned int Y_COUNT = scan_file(prefix, "Y_COUNT");
  unsigned int Y_MODIFY = scan_file(prefix, "Y_MODIFY");
  unsigned int CURR_DESC_PTR = scan_file(prefix, "CURR_DESC_PTR");
  unsigned int CURR_ADDR = scan_file(prefix, "CURR_ADDR");
  unsigned int IRQ_STATUS = scan_file(prefix, "IRQ_STATUS");
  unsigned int CURR_X_COUNT = scan_file(prefix, "CURR_X_COUNT");
  unsigned int CURR_Y_COUNT = scan_file(prefix, "CURR_Y_COUNT");
  printf("  --- %s ---\n", prefix);
  printf("desc: curr: 0x%08x  next: 0x%08x\n", CURR_DESC_PTR, NEXT_DESC_PTR);
  printf("addr: curr: 0x%08x start: 0x%08x\n", CURR_ADDR, START_ADDR);
  printf("X: curr: 0x%04x count: 0x%04x mod: 0x%04x (%i)\n", CURR_X_COUNT,
         X_COUNT, X_MODIFY, (short)X_MODIFY);
  printf("Y: curr: 0x%04x count: 0x%04x mod: 0x%04x (%i)\n", CURR_Y_COUNT,
         Y_COUNT, Y_MODIFY, (short)Y_MODIFY);
  printf("dma config: 0x%04x (%sabled %s ", CONFIG,
         (CONFIG & (1 << 0)) ? "en" : "dis",
         (CONFIG & (0x1 << 1)) ? "write" : "read");
  switch (CONFIG & (0x3 << 2)) {
  case 0x3:
    printf("WDSIZE:INVALID ");
    break;
  case 0x2:
    printf("32-bit ");
    break;
  case 0x1:
    printf("16-bit ");
    break;
  case 0x0:
    printf("8-bit ");
    break;
  }
  printf("%s %s%s%s", (CONFIG & (0x1 << 4)) ? "2D" : "1D",
         (CONFIG & (0x1 << 5)) ? "sync " : "",
         (CONFIG & (0x1 << 6)) ? "di_sel " : "",
         (CONFIG & (0x1 << 7)) ? "interrupt " : "");
  unsigned int NDSIZE = CONFIG & (0xF << 8);
  if (NDSIZE > 0 && NDSIZE < 10)
    printf("NDSIZE_%i ", NDSIZE);
  else if (NDSIZE >= 10)
    printf("NDSIZE:INVALID:%i ", NDSIZE);
  unsigned int FLOW = CONFIG & (0x7 << 12);
  switch (FLOW) {
  case 0:
    printf("stop");
    break;
  case 1:
    printf("autobuffer");
    break;
  case 4:
    printf("descriptor_array");
    break;
  case 6:
    printf("descriptor_list_small");
    break;
  case 7:
    printf("descriptor_list_large");
    break;
  default:
    printf("FLOW:INVALID:%i", FLOW);
  }
  printf(")\n");
  printf("irq status: 0x%04x (%s%s%s%s)\n", IRQ_STATUS,
         (IRQ_STATUS & (0x1 << 0)) ? "done " : "",
         (IRQ_STATUS & (0x1 << 1)) ? "err " : "",
         (IRQ_STATUS & (0x1 << 2)) ? "dfetch " : "",
         (IRQ_STATUS & (0x1 << 3)) ? "run " : "");
}


x86 assembly (clang, -O0):
<decode_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xef9(%rip),%rsi
call   1040 <scan_file@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xef4(%rip),%rsi
call   1040 <scan_file@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeec(%rip),%rsi
call   1040 <scan_file@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xf1a(%rip),%rsi
call   1040 <scan_file@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xecd(%rip),%rsi
call   1040 <scan_file@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xf01(%rip),%rsi
call   1040 <scan_file@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb0(%rip),%rsi
call   1040 <scan_file@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1040 <scan_file@plt>
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1040 <scan_file@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1040 <scan_file@plt>
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1040 <scan_file@plt>
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1040 <scan_file@plt>
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe84(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x49(%rbp)
call   1030 <printf@plt>
mov    -0x49(%rbp),%al
mov    -0x28(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
mov    -0x49(%rbp),%al
mov    -0x2c(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
mov    -0x49(%rbp),%al
mov    -0x34(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    %cx,%di
movswl %di,%r8d
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
mov    -0x49(%rbp),%al
mov    -0x38(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    %cx,%di
movswl %di,%r8d
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
mov    -0x49(%rbp),%al
mov    -0x14(%rbp),%esi
mov    %sil,%r8b
lea    0xed4(%rip),%rcx
lea    0xed0(%rip),%rdx
test   $0x1,%r8b
cmovne %rcx,%rdx
lea    0xec5(%rip),%rdi
lea    0xec4(%rip),%rcx
test   $0x2,%r8b
cmovne %rdi,%rcx
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
and    $0xc,%eax
mov    %rax,-0x48(%rbp)
sub    $0x3,%eax
ja     133c <decode_state+0x21c>
mov    -0x48(%rbp),%rax
lea    0xd14(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    133c <decode_state+0x21c>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    133c <decode_state+0x21c>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    133c <decode_state+0x21c>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%ecx
and    $0x10,%ecx
lea    0xe6e(%rip),%rsi
lea    0xe64(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
mov    -0x14(%rbp),%ecx
and    $0x20,%ecx
lea    0xdbc(%rip),%rdx
lea    0xe4f(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
mov    -0x14(%rbp),%edi
and    $0x40,%edi
lea    0xda1(%rip),%rcx
lea    0xe3a(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%rcx
mov    -0x14(%rbp),%edi
and    $0x80,%edi
lea    0xd83(%rip),%r8
lea    0xe24(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%r8
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
and    $0xf00,%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jbe    13ee <decode_state+0x2ce>
cmpl   $0xa,-0x3c(%rbp)
jae    13ee <decode_state+0x2ce>
mov    -0x3c(%rbp),%esi
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    140e <decode_state+0x2ee>
cmpl   $0xa,-0x3c(%rbp)
jb     1409 <decode_state+0x2e9>
mov    -0x3c(%rbp),%esi
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    140e <decode_state+0x2ee>
mov    -0x14(%rbp),%eax
and    $0x7000,%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %rax,-0x58(%rbp)
sub    $0x7,%rax
ja     149d <decode_state+0x37d>
mov    -0x58(%rbp),%rax
lea    0xbdb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    14ae <decode_state+0x38e>
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    14ae <decode_state+0x38e>
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    14ae <decode_state+0x38e>
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    14ae <decode_state+0x38e>
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    14ae <decode_state+0x38e>
mov    -0x40(%rbp),%esi
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xc69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%esi
mov    -0x30(%rbp),%ecx
and    $0x1,%ecx
lea    0xc54(%rip),%rdx
lea    0xd9a(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
mov    -0x30(%rbp),%edi
and    $0x2,%edi
lea    0xc39(%rip),%rcx
lea    0xd85(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%rcx
mov    -0x30(%rbp),%edi
and    $0x4,%edi
lea    0xc1e(%rip),%r8
lea    0xd6f(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%r8
mov    -0x30(%rbp),%edi
and    $0x8,%edi
lea    0xc03(%rip),%r9
lea    0xd5c(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%r9
lea    0xd1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_state>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbp
lea    0xeb8(%rip),%rsi
call   1050 <scan_file@plt>
mov    %eax,0x1c(%rsp)
lea    0xeb6(%rip),%rsi
mov    %rbp,%rdi
call   1050 <scan_file@plt>
mov    %eax,0x20(%rsp)
lea    0xeae(%rip),%rsi
mov    %rbp,%rdi
call   1050 <scan_file@plt>
mov    %eax,%ebx
lea    0xede(%rip),%rsi
mov    %rbp,%rdi
call   1050 <scan_file@plt>
mov    %eax,0x18(%rsp)
lea    0xe91(%rip),%rsi
mov    %rbp,%rdi
call   1050 <scan_file@plt>
mov    %eax,0x10(%rsp)
lea    0xec5(%rip),%rsi
mov    %rbp,%rdi
call   1050 <scan_file@plt>
mov    %eax,0x14(%rsp)
lea    0xe74(%rip),%rsi
mov    %rbp,%rdi
call   1050 <scan_file@plt>
mov    %eax,0xc(%rsp)
lea    0xe6a(%rip),%rsi
mov    %rbp,%rdi
call   1050 <scan_file@plt>
mov    %eax,%r15d
lea    0xe66(%rip),%rsi
mov    %rbp,%rdi
call   1050 <scan_file@plt>
mov    %eax,%r12d
lea    0xe5e(%rip),%rsi
mov    %rbp,%rdi
call   1050 <scan_file@plt>
mov    %eax,0x24(%rsp)
lea    0xe56(%rip),%rsi
mov    %rbp,%rdi
call   1050 <scan_file@plt>
mov    %eax,%r13d
lea    0xe51(%rip),%rsi
mov    %rbp,%rdi
call   1050 <scan_file@plt>
mov    %eax,%r14d
lea    0xe4c(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe49(%rip),%rdi
mov    %r15d,%esi
mov    0x1c(%rsp),%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe56(%rip),%rdi
mov    %r12d,%esi
mov    0x20(%rsp),%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%ecx
movswl %cx,%r8d
lea    0xe5b(%rip),%rdi
mov    %r13d,%esi
mov    0x18(%rsp),%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%ecx
movswl %cx,%r8d
lea    0xe6e(%rip),%rdi
mov    %r14d,%esi
mov    0x14(%rsp),%edx
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x1,%bl
lea    0xea9(%rip),%rax
lea    0xe9f(%rip),%rdx
cmove  %rax,%rdx
test   $0x2,%bl
lea    0xe9e(%rip),%rax
lea    0xe91(%rip),%rcx
cmove  %rax,%rcx
lea    0xe5f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0xc,%bl
jne    12de <decode_state+0x1ae>
lea    0xe7c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x10,%bl
lea    0xe7f(%rip),%rax
lea    0xe75(%rip),%rsi
cmove  %rax,%rsi
test   $0x20,%bl
lea    0xdf3(%rip),%rbp
lea    0xe66(%rip),%rdx
cmove  %rbp,%rdx
test   $0x40,%bl
lea    0xe5e(%rip),%rcx
cmove  %rbp,%rcx
test   $0x80,%bl
lea    0xe58(%rip),%r8
cmove  %rbp,%r8
lea    0xe2f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%esi
and    $0xf00,%esi
je     134a <decode_state+0x21a>
lea    0xe40(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
and    $0x7000,%ebx
je     1364 <decode_state+0x234>
lea    0xe42(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1372 <decode_state+0x242>
lea    0xe2b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe69(%rip),%rdi
call   1030 <puts@plt>
mov    0x24(%rsp),%esi
test   $0x1,%sil
lea    0xe3d(%rip),%rdx
cmove  %rbp,%rdx
test   $0x2,%sil
lea    0xe34(%rip),%rcx
cmove  %rbp,%rcx
test   $0x4,%sil
lea    0xe2a(%rip),%r8
cmove  %rbp,%r8
test   $0x8,%sil
lea    0xe23(%rip),%r9
cmove  %rbp,%r9
lea    0xde6(%rip),%rdi
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"NEXT_DESC_PTR\00"
@.str.1 = [11 x i8] c"START_ADDR\00"
@.str.2 = [7 x i8] c"CONFIG\00"
@.str.3 = [8 x i8] c"X_COUNT\00"
@.str.4 = [9 x i8] c"X_MODIFY\00"
@.str.5 = [8 x i8] c"Y_COUNT\00"
@.str.6 = [9 x i8] c"Y_MODIFY\00"
@.str.7 = [14 x i8] c"CURR_DESC_PTR\00"
@.str.8 = [10 x i8] c"CURR_ADDR\00"
@.str.9 = [11 x i8] c"IRQ_STATUS\00"
@.str.10 = [13 x i8] c"CURR_X_COUNT\00"
@.str.11 = [13 x i8] c"CURR_Y_COUNT\00"
@.str.12 = [14 x i8] c" --- %s ---\0A\00"
@.str.13 = [34 x i8] c"desc: curr: 0x%08x next: 0x%08x\0A\00"
@.str.14 = [34 x i8] c"addr: curr: 0x%08x start: 0x%08x\0A\00"
@.str.15 = [48 x i8] c"X: curr: 0x%04x count: 0x%04x mod: 0x%04x (%i)\0A\00"
@.str.16 = [48 x i8] c"Y: curr: 0x%04x count: 0x%04x mod: 0x%04x (%i)\0A\00"
@.str.17 = [32 x i8] c"dma config: 0x%04x (%sabled %s \00"
@.str.18 = [3 x i8] c"en\00"
@.str.19 = [4 x i8] c"dis\00"
@.str.20 = [6 x i8] c"write\00"
@.str.21 = [5 x i8] c"read\00"
@.str.22 = [16 x i8] c"WDSIZE:INVALID \00"
@.str.23 = [8 x i8] c"32-bit \00"
@.str.24 = [8 x i8] c"16-bit \00"
@.str.25 = [7 x i8] c"8-bit \00"
@.str.26 = [10 x i8] c"%s %s%s%s\00"
@.str.27 = [3 x i8] c"2D\00"
@.str.28 = [3 x i8] c"1D\00"
@.str.29 = [6 x i8] c"sync \00"
@.str.30 = [1 x i8] zeroinitializer
@.str.31 = [8 x i8] c"di_sel \00"
@.str.32 = [11 x i8] c"interrupt \00"
@.str.33 = [11 x i8] c"NDSIZE_%i \00"
@.str.34 = [19 x i8] c"NDSIZE:INVALID:%i \00"
@.str.35 = [5 x i8] c"stop\00"
@.str.36 = [11 x i8] c"autobuffer\00"
@.str.37 = [17 x i8] c"descriptor_array\00"
@.str.38 = [22 x i8] c"descriptor_list_small\00"
@.str.39 = [22 x i8] c"descriptor_list_large\00"
@.str.40 = [16 x i8] c"FLOW:INVALID:%i\00"
@.str.41 = [3 x i8] c")\0A\00"
@.str.42 = [31 x i8] c"irq status: 0x%04x (%s%s%s%s)\0A\00"
@.str.43 = [6 x i8] c"done \00"
@.str.44 = [5 x i8] c"err \00"
@.str.45 = [8 x i8] c"dfetch \00"
@.str.46 = [5 x i8] c"run \00"
define void @decode_state(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i8* %0, i8** %2
%17 = load i8*, i8** %2
%18 = call i32 @scan_file(i8* %17, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 %18, i32* %3
%19 = load i8*, i8** %2
%20 = call i32 @scan_file(i8* %19, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i32 %20, i32* %4
%21 = load i8*, i8** %2
%22 = call i32 @scan_file(i8* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i32 %22, i32* %5
%23 = load i8*, i8** %2
%24 = call i32 @scan_file(i8* %23, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
store i32 %24, i32* %6
%25 = load i8*, i8** %2
%26 = call i32 @scan_file(i8* %25, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
store i32 %26, i32* %7
%27 = load i8*, i8** %2
%28 = call i32 @scan_file(i8* %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
store i32 %28, i32* %8
%29 = load i8*, i8** %2
%30 = call i32 @scan_file(i8* %29, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
store i32 %30, i32* %9
%31 = load i8*, i8** %2
%32 = call i32 @scan_file(i8* %31, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
store i32 %32, i32* %10
%33 = load i8*, i8** %2
%34 = call i32 @scan_file(i8* %33, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
store i32 %34, i32* %11
%35 = load i8*, i8** %2
%36 = call i32 @scan_file(i8* %35, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
store i32 %36, i32* %12
%37 = load i8*, i8** %2
%38 = call i32 @scan_file(i8* %37, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
store i32 %38, i32* %13
%39 = load i8*, i8** %2
%40 = call i32 @scan_file(i8* %39, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0))
store i32 %40, i32* %14
%41 = load i8*, i8** %2
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i8* %41)
%43 = load i32, i32* %10
%44 = load i32, i32* %3
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.13, i64 0, i64 0), i32 %43, i32 %44)
%46 = load i32, i32* %11
%47 = load i32, i32* %4
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.14, i64 0, i64 0), i32 %46, i32 %47)
%49 = load i32, i32* %13
%50 = load i32, i32* %6
%51 = load i32, i32* %7
%52 = load i32, i32* %7
%53 = trunc i32 %52 to i16
%54 = sext i16 %53 to i32
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.15, i64 0, i64 0), i32 %49, i32 %50, i32 %51, i32 %54)
%56 = load i32, i32* %14
%57 = load i32, i32* %8
%58 = load i32, i32* %9
%59 = load i32, i32* %9
%60 = trunc i32 %59 to i16
%61 = sext i16 %60 to i32
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.16, i64 0, i64 0), i32 %56, i32 %57, i32 %58, i32 %61)
%63 = load i32, i32* %5
%64 = load i32, i32* %5
%65 = and i32 %64, 1
%66 = icmp ne i32 %65, 0
%67 = zext i1 %66 to i64
%68 = select i1 %66, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.19, i64 0, i64 0)
%69 = load i32, i32* %5
%70 = and i32 %69, 2
%71 = icmp ne i32 %70, 0
%72 = zext i1 %71 to i64
%73 = select i1 %71, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.21, i64 0, i64 0)
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.17, i64 0, i64 0), i32 %63, i8* %68, i8* %73)
%75 = load i32, i32* %5
%76 = and i32 %75, 12
switch i32 %76, label %85 [
i32 3, label %77
i32 2, label %79
i32 1, label %81
i32 0, label %83
]
77: ; preds = %1
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.22, i64 0, i64 0))
br label %85
79: ; preds = %1
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.23, i64 0, i64 0))
br label %85
81: ; preds = %1
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.24, i64 0, i64 0))
br label %85
83: ; preds = %1
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.25, i64 0, i64 0))
br label %85
85: ; preds = %1, %83, %81, %79, %77
%86 = load i32, i32* %5
%87 = and i32 %86, 16
%88 = icmp ne i32 %87, 0
%89 = zext i1 %88 to i64
%90 = select i1 %88, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.27, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.28, i64 0, i64 0)
%91 = load i32, i32* %5
%92 = and i32 %91, 32
%93 = icmp ne i32 %92, 0
%94 = zext i1 %93 to i64
%95 = select i1 %93, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.29, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.30, i64 0, i64 0)
%96 = load i32, i32* %5
%97 = and i32 %96, 64
%98 = icmp ne i32 %97, 0
%99 = zext i1 %98 to i64
%100 = select i1 %98, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.31, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.30, i64 0, i64 0)
%101 = load i32, i32* %5
%102 = and i32 %101, 128
%103 = icmp ne i32 %102, 0
%104 = zext i1 %103 to i64
%105 = select i1 %103, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.32, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.30, i64 0, i64 0)
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.26, i64 0, i64 0), i8* %90, i8* %95, i8* %100, i8* %105)
%107 = load i32, i32* %5
%108 = and i32 %107, 3840
store i32 %108, i32* %15
%109 = load i32, i32* %15
%110 = icmp ugt i32 %109, 0
br i1 %110, label %111, label %117
111: ; preds = %85
%112 = load i32, i32* %15
%113 = icmp ult i32 %112, 10
br i1 %113, label %114, label %117
114: ; preds = %111
%115 = load i32, i32* %15
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.33, i64 0, i64 0), i32 %115)
br label %124
117: ; preds = %111, %85
%118 = load i32, i32* %15
%119 = icmp uge i32 %118, 10
br i1 %119, label %120, label %123
120: ; preds = %117
%121 = load i32, i32* %15
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.34, i64 0, i64 0), i32 %121)
br label %123
123: ; preds = %120, %117
br label %124
124: ; preds = %123, %114
%125 = load i32, i32* %5
%126 = and i32 %125, 28672
store i32 %126, i32* %16
%127 = load i32, i32* %16
switch i32 %127, label %138 [
i32 0, label %128
i32 1, label %130
i32 4, label %132
i32 6, label %134
i32 7, label %136
]
128: ; preds = %124
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.35, i64 0, i64 0))
br label %141
130: ; preds = %124
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.36, i64 0, i64 0))
br label %141
132: ; preds = %124
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.37, i64 0, i64 0))
br label %141
134: ; preds = %124
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.38, i64 0, i64 0))
br label %141
136: ; preds = %124
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.39, i64 0, i64 0))
br label %141
138: ; preds = %124
%139 = load i32, i32* %16
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.40, i64 0, i64 0), i32 %139)
br label %141
141: ; preds = %138, %136, %134, %132, %130, %128
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.41, i64 0, i64 0))
%143 = load i32, i32* %12
%144 = load i32, i32* %12
%145 = and i32 %144, 1
%146 = icmp ne i32 %145, 0
%147 = zext i1 %146 to i64
%148 = select i1 %146, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.43, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.30, i64 0, i64 0)
%149 = load i32, i32* %12
%150 = and i32 %149, 2
%151 = icmp ne i32 %150, 0
%152 = zext i1 %151 to i64
%153 = select i1 %151, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.44, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.30, i64 0, i64 0)
%154 = load i32, i32* %12
%155 = and i32 %154, 4
%156 = icmp ne i32 %155, 0
%157 = zext i1 %156 to i64
%158 = select i1 %156, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.45, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.30, i64 0, i64 0)
%159 = load i32, i32* %12
%160 = and i32 %159, 8
%161 = icmp ne i32 %160, 0
%162 = zext i1 %161 to i64
%163 = select i1 %161, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.46, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.30, i64 0, i64 0)
%164 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.42, i64 0, i64 0), i32 %143, i8* %148, i8* %153, i8* %158, i8* %163)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"NEXT_DESC_PTR\00"
@.str.1 = [11 x i8] c"START_ADDR\00"
@.str.2 = [7 x i8] c"CONFIG\00"
@.str.3 = [8 x i8] c"X_COUNT\00"
@.str.4 = [9 x i8] c"X_MODIFY\00"
@.str.5 = [8 x i8] c"Y_COUNT\00"
@.str.6 = [9 x i8] c"Y_MODIFY\00"
@.str.7 = [14 x i8] c"CURR_DESC_PTR\00"
@.str.8 = [10 x i8] c"CURR_ADDR\00"
@.str.9 = [11 x i8] c"IRQ_STATUS\00"
@.str.10 = [13 x i8] c"CURR_X_COUNT\00"
@.str.11 = [13 x i8] c"CURR_Y_COUNT\00"
@.str.12 = [14 x i8] c" --- %s ---\0A\00"
@.str.13 = [34 x i8] c"desc: curr: 0x%08x next: 0x%08x\0A\00"
@.str.14 = [34 x i8] c"addr: curr: 0x%08x start: 0x%08x\0A\00"
@.str.15 = [48 x i8] c"X: curr: 0x%04x count: 0x%04x mod: 0x%04x (%i)\0A\00"
@.str.16 = [48 x i8] c"Y: curr: 0x%04x count: 0x%04x mod: 0x%04x (%i)\0A\00"
@.str.17 = [32 x i8] c"dma config: 0x%04x (%sabled %s \00"
@.str.18 = [3 x i8] c"en\00"
@.str.19 = [4 x i8] c"dis\00"
@.str.20 = [6 x i8] c"write\00"
@.str.21 = [5 x i8] c"read\00"
@.str.25 = [7 x i8] c"8-bit \00"
@.str.26 = [10 x i8] c"%s %s%s%s\00"
@.str.27 = [3 x i8] c"2D\00"
@.str.28 = [3 x i8] c"1D\00"
@.str.29 = [6 x i8] c"sync \00"
@.str.30 = [1 x i8] zeroinitializer
@.str.31 = [8 x i8] c"di_sel \00"
@.str.32 = [11 x i8] c"interrupt \00"
@.str.34 = [19 x i8] c"NDSIZE:INVALID:%i \00"
@.str.35 = [5 x i8] c"stop\00"
@.str.40 = [16 x i8] c"FLOW:INVALID:%i\00"
@.str.42 = [31 x i8] c"irq status: 0x%04x (%s%s%s%s)\0A\00"
@.str.43 = [6 x i8] c"done \00"
@.str.44 = [5 x i8] c"err \00"
@.str.45 = [8 x i8] c"dfetch \00"
@.str.46 = [5 x i8] c"run \00"
@str = [2 x i8] c")\00"
define void @decode_state(i8* %0) {
%2 = tail call i32 @scan_file(i8* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @scan_file(i8* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @scan_file(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @scan_file(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%6 = tail call i32 @scan_file(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%7 = tail call i32 @scan_file(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%8 = tail call i32 @scan_file(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%9 = tail call i32 @scan_file(i8* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%10 = tail call i32 @scan_file(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%11 = tail call i32 @scan_file(i8* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
%12 = tail call i32 @scan_file(i8* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
%13 = tail call i32 @scan_file(i8* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0))
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i8* %0)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.13, i64 0, i64 0), i32 %9, i32 %2)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.14, i64 0, i64 0), i32 %10, i32 %3)
%17 = shl i32 %6, 16
%18 = ashr exact i32 %17, 16
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.15, i64 0, i64 0), i32 %12, i32 %5, i32 %6, i32 %18)
%20 = shl i32 %8, 16
%21 = ashr exact i32 %20, 16
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.16, i64 0, i64 0), i32 %13, i32 %7, i32 %8, i32 %21)
%23 = and i32 %4, 1
%24 = icmp eq i32 %23, 0
%25 = select i1 %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0)
%26 = and i32 %4, 2
%27 = icmp eq i32 %26, 0
%28 = select i1 %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.21, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.20, i64 0, i64 0)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.17, i64 0, i64 0), i32 %4, i8* %25, i8* %28)
%30 = and i32 %4, 12
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %1
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.25, i64 0, i64 0))
br label %34
34: ; preds = %1, %32
%35 = and i32 %4, 16
%36 = icmp eq i32 %35, 0
%37 = select i1 %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.28, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.27, i64 0, i64 0)
%38 = and i32 %4, 32
%39 = icmp eq i32 %38, 0
%40 = select i1 %39, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.30, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.29, i64 0, i64 0)
%41 = and i32 %4, 64
%42 = icmp eq i32 %41, 0
%43 = select i1 %42, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.30, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.31, i64 0, i64 0)
%44 = and i32 %4, 128
%45 = icmp eq i32 %44, 0
%46 = select i1 %45, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.30, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.32, i64 0, i64 0)
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.26, i64 0, i64 0), i8* %37, i8* %40, i8* %43, i8* %46)
%48 = and i32 %4, 3840
%49 = icmp eq i32 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %34
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.34, i64 0, i64 0), i32 %48)
br label %52
52: ; preds = %34, %50
%53 = and i32 %4, 28672
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %52
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.35, i64 0, i64 0))
br label %59
57: ; preds = %52
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.40, i64 0, i64 0), i32 %53)
br label %59
59: ; preds = %57, %55
%60 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%61 = and i32 %11, 1
%62 = icmp eq i32 %61, 0
%63 = select i1 %62, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.30, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.43, i64 0, i64 0)
%64 = and i32 %11, 2
%65 = icmp eq i32 %64, 0
%66 = select i1 %65, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.30, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.44, i64 0, i64 0)
%67 = and i32 %11, 4
%68 = icmp eq i32 %67, 0
%69 = select i1 %68, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.30, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.45, i64 0, i64 0)
%70 = and i32 %11, 8
%71 = icmp eq i32 %70, 0
%72 = select i1 %71, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.30, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.46, i64 0, i64 0)
%73 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.42, i64 0, i64 0), i32 %11, i8* %63, i8* %66, i8* %69, i8* %72)
ret void
}