#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 */
unsigned int dma_get(unsigned int *, int);
int /*<<< orphan*/ printf(char *, ...);
void dma_mm2s_status(unsigned int *dma_virtual_address) {
  unsigned int status = dma_get(dma_virtual_address, 0x04);
  printf("Memory-mapped to stream status (0x%08x@0x%02x):", status, 0x04);
  if (status & 0x00000001)
    printf(" halted");
  else
    printf(" running");
  if (status & 0x00000002)
    printf(" idle");
  if (status & 0x00000008)
    printf(" SGIncld");
  if (status & 0x00000010)
    printf(" DMAIntErr");
  if (status & 0x00000020)
    printf(" DMASlvErr");
  if (status & 0x00000040)
    printf(" DMADecErr");
  if (status & 0x00000100)
    printf(" SGIntErr");
  if (status & 0x00000200)
    printf(" SGSlvErr");
  if (status & 0x00000400)
    printf(" SGDecErr");
  if (status & 0x00001000)
    printf(" IOC_Irq");
  if (status & 0x00002000)
    printf(" Dly_Irq");
  if (status & 0x00004000)
    printf(" Err_Irq");
  printf("\n");
}


x86 assembly (clang, -O0):
<dma_mm2s_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x4,%esi
call   1040 <dma_get@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xeb9(%rip),%rdi
mov    $0x4,%edx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1175 <dma_mm2s_status+0x55>
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1183 <dma_mm2s_status+0x63>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     11a0 <dma_mm2s_status+0x80>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     11bd <dma_mm2s_status+0x9d>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     11da <dma_mm2s_status+0xba>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     11f7 <dma_mm2s_status+0xd7>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
and    $0x40,%eax
cmp    $0x0,%eax
je     1214 <dma_mm2s_status+0xf4>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
and    $0x100,%eax
cmp    $0x0,%eax
je     1233 <dma_mm2s_status+0x113>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
and    $0x200,%eax
cmp    $0x0,%eax
je     1252 <dma_mm2s_status+0x132>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
and    $0x400,%eax
cmp    $0x0,%eax
je     1271 <dma_mm2s_status+0x151>
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
and    $0x1000,%eax
cmp    $0x0,%eax
je     1290 <dma_mm2s_status+0x170>
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
and    $0x2000,%eax
cmp    $0x0,%eax
je     12af <dma_mm2s_status+0x18f>
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
and    $0x4000,%eax
cmp    $0x0,%eax
je     12ce <dma_mm2s_status+0x1ae>
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dma_mm2s_status>:
push   %rbx
mov    $0x4,%esi
call   1050 <dma_get@plt>
mov    %eax,%ebx
lea    0xebc(%rip),%rdi
mov    %eax,%esi
mov    $0x4,%edx
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x1,%bl
lea    0xedc(%rip),%rax
lea    0xecd(%rip),%rdi
cmove  %rax,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x2,%bl
jne    11f8 <dma_mm2s_status+0xc8>
test   $0x8,%bl
jne    120f <dma_mm2s_status+0xdf>
test   $0x10,%bl
jne    1226 <dma_mm2s_status+0xf6>
test   $0x20,%bl
jne    123d <dma_mm2s_status+0x10d>
test   $0x40,%bl
jne    1254 <dma_mm2s_status+0x124>
test   $0x100,%ebx
jne    126e <dma_mm2s_status+0x13e>
test   $0x200,%ebx
jne    1288 <dma_mm2s_status+0x158>
test   $0x400,%ebx
jne    12a2 <dma_mm2s_status+0x172>
test   $0x1000,%ebx
jne    12bc <dma_mm2s_status+0x18c>
test   $0x2000,%ebx
jne    12d6 <dma_mm2s_status+0x1a6>
test   $0x4000,%ebx
je     11ed <dma_mm2s_status+0xbd>
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
pop    %rbx
jmp    1030 <putchar@plt>
lea    0xe42(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x8,%bl
je     1180 <dma_mm2s_status+0x50>
lea    0xe31(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x10,%bl
je     1189 <dma_mm2s_status+0x59>
lea    0xe23(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x20,%bl
je     1192 <dma_mm2s_status+0x62>
lea    0xe17(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x40,%bl
je     119b <dma_mm2s_status+0x6b>
lea    0xe0b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x100,%ebx
je     11a7 <dma_mm2s_status+0x77>
lea    0xdfc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x200,%ebx
je     11b3 <dma_mm2s_status+0x83>
lea    0xdec(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x400,%ebx
je     11bf <dma_mm2s_status+0x8f>
lea    0xddc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x1000,%ebx
je     11cb <dma_mm2s_status+0x9b>
lea    0xdcc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x2000,%ebx
je     11d7 <dma_mm2s_status+0xa7>
lea    0xdbb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x4000,%ebx
jne    11df <dma_mm2s_status+0xaf>
jmp    11ed <dma_mm2s_status+0xbd>

LLVM IR (-O0):
@.str = [48 x i8] c"Memory-mapped to stream status (0x%08x@0x%02x):\00"
@.str.1 = [8 x i8] c" halted\00"
@.str.2 = [9 x i8] c" running\00"
@.str.3 = [6 x i8] c" idle\00"
@.str.4 = [9 x i8] c" SGIncld\00"
@.str.5 = [11 x i8] c" DMAIntErr\00"
@.str.6 = [11 x i8] c" DMASlvErr\00"
@.str.7 = [11 x i8] c" DMADecErr\00"
@.str.8 = [10 x i8] c" SGIntErr\00"
@.str.9 = [10 x i8] c" SGSlvErr\00"
@.str.10 = [10 x i8] c" SGDecErr\00"
@.str.11 = [9 x i8] c" IOC_Irq\00"
@.str.12 = [9 x i8] c" Dly_Irq\00"
@.str.13 = [9 x i8] c" Err_Irq\00"
@.str.14 = [2 x i8] c"\0A\00"
define void @dma_mm2s_status(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = call i32 @dma_get(i32* %4, i32 4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 %6, i32 4)
%8 = load i32, i32* %3
%9 = and i32 %8, 1
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %15
13: ; preds = %1
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %13, %11
%16 = load i32, i32* %3
%17 = and i32 %16, 2
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %19, %15
%22 = load i32, i32* %3
%23 = and i32 %22, 8
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %27
27: ; preds = %25, %21
%28 = load i32, i32* %3
%29 = and i32 %28, 16
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
br label %33
33: ; preds = %31, %27
%34 = load i32, i32* %3
%35 = and i32 %34, 32
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
br label %39
39: ; preds = %37, %33
%40 = load i32, i32* %3
%41 = and i32 %40, 64
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
br label %45
45: ; preds = %43, %39
%46 = load i32, i32* %3
%47 = and i32 %46, 256
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %45
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
br label %51
51: ; preds = %49, %45
%52 = load i32, i32* %3
%53 = and i32 %52, 512
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %51
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
br label %57
57: ; preds = %55, %51
%58 = load i32, i32* %3
%59 = and i32 %58, 1024
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %57
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
br label %63
63: ; preds = %61, %57
%64 = load i32, i32* %3
%65 = and i32 %64, 4096
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %63
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0))
br label %69
69: ; preds = %67, %63
%70 = load i32, i32* %3
%71 = and i32 %70, 8192
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %69
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0))
br label %75
75: ; preds = %73, %69
%76 = load i32, i32* %3
%77 = and i32 %76, 16384
%78 = icmp ne i32 %77, 0
br i1 %78, label %79, label %81
79: ; preds = %75
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0))
br label %81
81: ; preds = %79, %75
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [48 x i8] c"Memory-mapped to stream status (0x%08x@0x%02x):\00"
@.str.1 = [8 x i8] c" halted\00"
@.str.2 = [9 x i8] c" running\00"
@.str.3 = [6 x i8] c" idle\00"
@.str.4 = [9 x i8] c" SGIncld\00"
@.str.5 = [11 x i8] c" DMAIntErr\00"
@.str.6 = [11 x i8] c" DMASlvErr\00"
@.str.7 = [11 x i8] c" DMADecErr\00"
@.str.8 = [10 x i8] c" SGIntErr\00"
@.str.9 = [10 x i8] c" SGSlvErr\00"
@.str.10 = [10 x i8] c" SGDecErr\00"
@.str.11 = [9 x i8] c" IOC_Irq\00"
@.str.12 = [9 x i8] c" Dly_Irq\00"
@.str.13 = [9 x i8] c" Err_Irq\00"
define void @dma_mm2s_status(i32* %0) {
%2 = tail call i32 @dma_get(i32* %0, i32 4)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 %2, i32 4)
%4 = and i32 %2, 1
%5 = icmp eq i32 %4, 0
%6 = select i1 %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %6)
%8 = and i32 %2, 2
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %1
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %12
12: ; preds = %10, %1
%13 = and i32 %2, 8
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
%18 = and i32 %2, 16
%19 = icmp eq i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
br label %22
22: ; preds = %20, %17
%23 = and i32 %2, 32
%24 = icmp eq i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
br label %27
27: ; preds = %25, %22
%28 = and i32 %2, 64
%29 = icmp eq i32 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
%33 = and i32 %2, 256
%34 = icmp eq i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
br label %37
37: ; preds = %35, %32
%38 = and i32 %2, 512
%39 = icmp eq i32 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %37
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
br label %42
42: ; preds = %40, %37
%43 = and i32 %2, 1024
%44 = icmp eq i32 %43, 0
br i1 %44, label %47, label %45
45: ; preds = %42
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
br label %47
47: ; preds = %45, %42
%48 = and i32 %2, 4096
%49 = icmp eq i32 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %47
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0))
br label %52
52: ; preds = %50, %47
%53 = and i32 %2, 8192
%54 = icmp eq i32 %53, 0
br i1 %54, label %57, label %55
55: ; preds = %52
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0))
br label %57
57: ; preds = %55, %52
%58 = and i32 %2, 16384
%59 = icmp eq i32 %58, 0
br i1 %59, label %62, label %60
60: ; preds = %57
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0))
br label %62
62: ; preds = %60, %57
%63 = tail call i32 @putchar(i32 10)
ret void
}