#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 chunks();
int list();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ report(int);
int simple();
int main() {
  int pass_simple, pass_chunks, pass_list;
  printf("Starting DMA test\n");
  printf("  Simple DMA: ");
  printf((pass_simple = simple()) ? "Passed\n" : "Failed\n");
  printf("  Chunks DMA: ");
  printf((pass_chunks = chunks()) ? "Passed\n" : "Failed\n");
  printf("  List DMA: ");
  printf((pass_list = list()) ? "Passed\n" : "Failed\n");
  printf("Ending DMA test\n");
  if (pass_simple && pass_chunks && pass_list) {
    report(0xdeaddead);
    return 0;
  } else
    return 3 - pass_simple - pass_chunks - pass_list;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <simple@plt>
mov    %eax,%ecx
mov    %ecx,-0x8(%rbp)
lea    0xea0(%rip),%rdi
lea    0xe91(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <chunks@plt>
mov    %eax,%ecx
mov    %ecx,-0xc(%rbp)
lea    0xe6e(%rip),%rdi
lea    0xe5f(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <list@plt>
mov    %eax,%ecx
mov    %ecx,-0x10(%rbp)
lea    0xe3c(%rip),%rdi
lea    0xe2d(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     1241 <main+0xf1>
cmpl   $0x0,-0xc(%rbp)
je     1241 <main+0xf1>
cmpl   $0x0,-0x10(%rbp)
je     1241 <main+0xf1>
mov    $0xdeaddead,%edi
call   1070 <report@plt>
movl   $0x0,-0x4(%rbp)
jmp    1252 <main+0x102>
mov    $0x3,%eax
sub    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <simple@plt>
mov    %eax,%r15d
test   %eax,%eax
lea    0xe7c(%rip),%r12
lea    0xe7d(%rip),%rbp
mov    %rbp,%rdi
cmovne %r12,%rdi
call   1040 <printf@plt>
lea    0xe72(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <chunks@plt>
mov    %eax,%r14d
test   %eax,%eax
mov    %rbp,%rdi
cmovne %r12,%rdi
call   1040 <printf@plt>
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <list@plt>
mov    %eax,%ebx
test   %eax,%eax
cmovne %r12,%rbp
mov    %rbp,%rdi
call   1040 <printf@plt>
lea    0xe59(%rip),%rdi
call   1030 <puts@plt>
test   %r15d,%r15d
je     1215 <main+0xb5>
test   %r14d,%r14d
je     1215 <main+0xb5>
test   %ebx,%ebx
je     1215 <main+0xb5>
mov    $0xdeaddead,%edi
call   1080 <report@plt>
xor    %eax,%eax
jmp    1223 <main+0xc3>
add    %r14d,%r15d
add    %ebx,%r15d
mov    $0x3,%eax
sub    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Starting DMA test\0A\00"
@.str.1 = [15 x i8] c" Simple DMA: \00"
@.str.2 = [8 x i8] c"Passed\0A\00"
@.str.3 = [8 x i8] c"Failed\0A\00"
@.str.4 = [15 x i8] c" Chunks DMA: \00"
@.str.5 = [13 x i8] c" List DMA: \00"
@.str.6 = [17 x i8] c"Ending DMA test\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (...) @simple()
store i32 %7, i32* %2
%8 = icmp ne i32 %7, 0
%9 = zext i1 %8 to i64
%10 = select i1 %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
%11 = call i32 @printf(i8* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 (...) @chunks()
store i32 %13, i32* %3
%14 = icmp ne i32 %13, 0
%15 = zext i1 %14 to i64
%16 = select i1 %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
%17 = call i32 @printf(i8* %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 (...) @list()
store i32 %19, i32* %4
%20 = icmp ne i32 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
%23 = call i32 @printf(i8* %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%25 = load i32, i32* %2
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %35
27: ; preds = %0
%28 = load i32, i32* %3
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i32, i32* %4
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 @report(i32 -559030611)
store i32 0, i32* %1
br label %42
35: ; preds = %30, %27, %0
%36 = load i32, i32* %2
%37 = sub nsw i32 3, %36
%38 = load i32, i32* %3
%39 = sub nsw i32 %37, %38
%40 = load i32, i32* %4
%41 = sub nsw i32 %39, %40
store i32 %41, i32* %1
br label %42
42: ; preds = %35, %33
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@.str.1 = [15 x i8] c" Simple DMA: \00"
@.str.2 = [8 x i8] c"Passed\0A\00"
@.str.3 = [8 x i8] c"Failed\0A\00"
@.str.4 = [15 x i8] c" Chunks DMA: \00"
@.str.5 = [13 x i8] c" List DMA: \00"
@str = [18 x i8] c"Starting DMA test\00"
@str.7 = [16 x i8] c"Ending DMA test\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 (...) @simple()
%4 = icmp ne i32 %3, 0
%5 = select i1 %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
%6 = tail call i32 @printf(i8* dereferenceable(1) %5)
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%8 = tail call i32 (...) @chunks()
%9 = icmp ne i32 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
%11 = tail call i32 @printf(i8* dereferenceable(1) %10)
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%13 = tail call i32 (...) @list()
%14 = icmp ne i32 %13, 0
%15 = select i1 %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
%16 = tail call i32 @printf(i8* dereferenceable(1) %15)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.7, i64 0, i64 0))
%18 = select i1 %4, i1 %9, i1 false
%19 = select i1 %18, i1 %14, i1 false
br i1 %19, label %20, label %22
20: ; preds = %0
%21 = tail call i32 @report(i32 -559030611)
br label %26
22: ; preds = %0
%23 = add i32 %3, %8
%24 = add i32 %23, %13
%25 = sub i32 3, %24
br label %26
26: ; preds = %22, %20
%27 = phi i32 [ 0, %20 ], [ %25, %22 ]
ret i32 %27
}