#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ *stdout;
void print_usage(bool help) {
  FILE *stream = (help) ? stdout : stderr;
  double default_size;
  fprintf(stream,
          "Usage: axidma_benchmark [-v] [-t <(V)DMA tx channel>] "
          "[-r <(V)DMA rx channel>] [-i <Tx transfer size (MiB)>] "
          "[-b <Tx transfer size (bytes)>] [-f <Tx frame size (HxWxD)>] "
          "[-o <Rx transfer size (MiB)>] [-s <Rx transfer size (bytes)>] "
          "[-g <Rx frame size (HxWxD)>] [-n <number transfers>]\n");
  if (!help) {
    return;
  }
  default_size =
      (((double)(((int)((1920 * 1080) * sizeof(int))))) / (1024.0 * 1024.0));
  fprintf(stream, "\t-v:\t\t\t\tUse the AXI VDMA channels instead of AXI DMA "
                  "ones for the transfer.\n");
  fprintf(stream,
          "\t-t <DMA tx channel>:\t\t\tThe device id of the DMA "
          "channel to use for transmitting the data to the PL fabric.\n");
  fprintf(stream,
          "\t-r <DMA rx channel>:\t\t\tThe device id of the DMA "
          "channel to use for receiving the the data from the PL fabric.\n");
  fprintf(stream,
          "\t-i <transmit transfer size (MiB)>:\tThe size of the "
          "data transmit over the DMA on each transfer. Default is %0.2f "
          "MiB.\n",
          default_size);
  fprintf(stream,
          "\t-b <Tx transfer size (bytes)>:\tThe size of the "
          "data transmit over the DMA on each transfer. Default is %d "
          "bytes.\n",
          ((int)((1920 * 1080) * sizeof(int))));
  fprintf(stream,
          "\t-f <Tx frame size (height x width x depth)>:\tThe size "
          "of the frame to transmit over VDMA on each transfer, where the "
          "depth is in bytes.");
  fprintf(stream,
          "\t-o <Rx transfer size (MiB)>:\tThe size of the data "
          "to receive from the DMA on each transfer. Default is %0.2f MiB.\n",
          default_size);
  fprintf(stream,
          "\t-s <Rx transfer size (bytes)>:\tThe size of the "
          "data to receive from the DMA on each transfer. Default is %d "
          "bytes.\n",
          ((int)((1920 * 1080) * sizeof(int))));
  fprintf(stream,
          "\t-g <Rx frame size (height x width x depth)>:\tThe size "
          "of the frame to receive over VDMA on each transfer, where the "
          "depth is in bytes.");
  fprintf(stream,
          "\t-n <number transfers>:\t\t\tThe number of DMA transfers "
          "to perform to do the benchmark. Default is %d transfers.\n",
          1000);
  return;
}


x86 assembly (clang, -O0):
<print_usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1138 <print_usage+0x28>
mov    0x2eac(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1146 <print_usage+0x36>
mov    0x2ea1(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeaf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpl   $0x0,-0x4(%rbp)
jne    116f <print_usage+0x5f>
jmp    1249 <print_usage+0x139>
movsd  0xe89(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xf9f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xfda(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0x1035(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
lea    0x108e(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0x10f4(%rip),%rsi
mov    $0x7e9000,%edx
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0x1150(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
lea    0x11c2(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0x1224(%rip),%rsi
mov    $0x7e9000,%edx
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0x1282(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0x12f8(%rip),%rsi
mov    $0x3e8,%edx
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_usage>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
test   %edi,%edi
jne    1132 <print_usage+0x12>
mov    0x2eb0(%rip),%rax
jmp    1139 <print_usage+0x19>
mov    0x2e9f(%rip),%rax
mov    (%rax),%rbx
lea    0xec5(%rip),%rdi
mov    $0x11d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
test   %ebp,%ebp
je     1254 <print_usage+0x134>
lea    0xfc2(%rip),%rdi
mov    $0x4c,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
lea    0xff6(%rip),%rdi
mov    $0x6c,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
lea    0x104a(%rip),%rdi
mov    $0x6f,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
lea    0x10a1(%rip),%rsi
movsd  0xe49(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1030 <fprintf@plt>
lea    0x1100(%rip),%rsi
mov    %rbx,%rdi
mov    $0x7e9000,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0x115d(%rip),%rdi
mov    $0x88,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
lea    0x11cd(%rip),%rsi
mov    %rbx,%rdi
movsd  0xdfe(%rip),%xmm0
mov    $0x1,%al
call   1030 <fprintf@plt>
lea    0x1228(%rip),%rsi
mov    %rbx,%rdi
mov    $0x7e9000,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0x1287(%rip),%rdi
mov    $0x87,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
lea    0x12f6(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3e8,%edx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <fprintf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32* null
@stderr = global i32* null
@.str = [286 x i8] c"Usage: axidma_benchmark [-v] [-t <(V)DMA tx channel>] [-r <(V)DMA rx channel>] [-i <Tx transfer size (MiB)>] [-b <Tx transfer size (bytes)>] [-f <Tx frame size (HxWxD)>] [-o <Rx transfer size (MiB)>] [-s <Rx transfer size (bytes)>] [-g <Rx frame size (HxWxD)>] [-n <number transfers>]\0A\00"
@.str.1 = [77 x i8] c"\09-v:\09\09\09\09Use the AXI VDMA channels instead of AXI DMA ones for the transfer.\0A\00"
@.str.2 = [109 x i8] c"\09-t <DMA tx channel>:\09\09\09The device id of the DMA channel to use for transmitting the data to the PL fabric.\0A\00"
@.str.3 = [112 x i8] c"\09-r <DMA rx channel>:\09\09\09The device id of the DMA channel to use for receiving the the data from the PL fabric.\0A\00"
@.str.4 = [120 x i8] c"\09-i <transmit transfer size (MiB)>:\09The size of the data transmit over the DMA on each transfer. Default is %0.2f MiB.\0A\00"
@.str.5 = [115 x i8] c"\09-b <Tx transfer size (bytes)>:\09The size of the data transmit over the DMA on each transfer. Default is %d bytes.\0A\00"
@.str.6 = [137 x i8] c"\09-f <Tx frame size (height x width x depth)>:\09The size of the frame to transmit over VDMA on each transfer, where the depth is in bytes.\00"
@.str.7 = [116 x i8] c"\09-o <Rx transfer size (MiB)>:\09The size of the data to receive from the DMA on each transfer. Default is %0.2f MiB.\0A\00"
@.str.8 = [117 x i8] c"\09-s <Rx transfer size (bytes)>:\09The size of the data to receive from the DMA on each transfer. Default is %d bytes.\0A\00"
@.str.9 = [136 x i8] c"\09-g <Rx frame size (height x width x depth)>:\09The size of the frame to receive over VDMA on each transfer, where the depth is in bytes.\00"
@.str.10 = [112 x i8] c"\09-n <number transfers>:\09\09\09The number of DMA transfers to perform to do the benchmark. Default is %d transfers.\0A\00"
define void @print_usage(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca double
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = load i32*, i32** @stdout
br label %11
9: ; preds = %1
%10 = load i32*, i32** @stderr
br label %11
11: ; preds = %9, %7
%12 = phi i32* [ %8, %7 ], [ %10, %9 ]
store i32* %12, i32** %3
%13 = load i32*, i32** %3
%14 = call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([286 x i8], [286 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* %2
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %11
br label %41
18: ; preds = %11
store double 0x401FA40000000000, double* %4
%19 = load i32*, i32** %3
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32*, i32** %3
%22 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([109 x i8], [109 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32*, i32** %3
%24 = call i32 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([112 x i8], [112 x i8]* @.str.3, i64 0, i64 0))
%25 = load i32*, i32** %3
%26 = load double, double* %4
%27 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([120 x i8], [120 x i8]* @.str.4, i64 0, i64 0), double %26)
%28 = load i32*, i32** %3
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str.5, i64 0, i64 0), i32 8294400)
%30 = load i32*, i32** %3
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.6, i64 0, i64 0))
%32 = load i32*, i32** %3
%33 = load double, double* %4
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.7, i64 0, i64 0), double %33)
%35 = load i32*, i32** %3
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([117 x i8], [117 x i8]* @.str.8, i64 0, i64 0), i32 8294400)
%37 = load i32*, i32** %3
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.9, i64 0, i64 0))
%39 = load i32*, i32** %3
%40 = call i32 (i32*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([112 x i8], [112 x i8]* @.str.10, i64 0, i64 0), i32 1000)
br label %41
41: ; preds = %18, %17
ret void
}

LLVM IR (-O2):
@stdout = global i32* null
@stderr = global i32* null
@.str = [286 x i8] c"Usage: axidma_benchmark [-v] [-t <(V)DMA tx channel>] [-r <(V)DMA rx channel>] [-i <Tx transfer size (MiB)>] [-b <Tx transfer size (bytes)>] [-f <Tx frame size (HxWxD)>] [-o <Rx transfer size (MiB)>] [-s <Rx transfer size (bytes)>] [-g <Rx frame size (HxWxD)>] [-n <number transfers>]\0A\00"
@.str.1 = [77 x i8] c"\09-v:\09\09\09\09Use the AXI VDMA channels instead of AXI DMA ones for the transfer.\0A\00"
@.str.2 = [109 x i8] c"\09-t <DMA tx channel>:\09\09\09The device id of the DMA channel to use for transmitting the data to the PL fabric.\0A\00"
@.str.3 = [112 x i8] c"\09-r <DMA rx channel>:\09\09\09The device id of the DMA channel to use for receiving the the data from the PL fabric.\0A\00"
@.str.4 = [120 x i8] c"\09-i <transmit transfer size (MiB)>:\09The size of the data transmit over the DMA on each transfer. Default is %0.2f MiB.\0A\00"
@.str.5 = [115 x i8] c"\09-b <Tx transfer size (bytes)>:\09The size of the data transmit over the DMA on each transfer. Default is %d bytes.\0A\00"
@.str.6 = [137 x i8] c"\09-f <Tx frame size (height x width x depth)>:\09The size of the frame to transmit over VDMA on each transfer, where the depth is in bytes.\00"
@.str.7 = [116 x i8] c"\09-o <Rx transfer size (MiB)>:\09The size of the data to receive from the DMA on each transfer. Default is %0.2f MiB.\0A\00"
@.str.8 = [117 x i8] c"\09-s <Rx transfer size (bytes)>:\09The size of the data to receive from the DMA on each transfer. Default is %d bytes.\0A\00"
@.str.9 = [136 x i8] c"\09-g <Rx frame size (height x width x depth)>:\09The size of the frame to receive over VDMA on each transfer, where the depth is in bytes.\00"
@.str.10 = [112 x i8] c"\09-n <number transfers>:\09\09\09The number of DMA transfers to perform to do the benchmark. Default is %d transfers.\0A\00"
define void @print_usage(i32 %0) {
%2 = icmp eq i32 %0, 0
%3 = load i32*, i32** @stdout
%4 = load i32*, i32** @stderr
%5 = select i1 %2, i32* %4, i32* %3
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([286 x i8], [286 x i8]* @.str, i64 0, i64 0), i64 285, i64 1, i32* %5)
br i1 %2, label %18, label %7
7: ; preds = %1
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0), i64 76, i64 1, i32* %5)
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([109 x i8], [109 x i8]* @.str.2, i64 0, i64 0), i64 108, i64 1, i32* %5)
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([112 x i8], [112 x i8]* @.str.3, i64 0, i64 0), i64 111, i64 1, i32* %5)
%11 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([120 x i8], [120 x i8]* @.str.4, i64 0, i64 0), double 0x401FA40000000000)
%12 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str.5, i64 0, i64 0), i32 8294400)
%13 = tail call i64 @fwrite(i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.6, i64 0, i64 0), i64 136, i64 1, i32* %5)
%14 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.7, i64 0, i64 0), double 0x401FA40000000000)
%15 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([117 x i8], [117 x i8]* @.str.8, i64 0, i64 0), i32 8294400)
%16 = tail call i64 @fwrite(i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.9, i64 0, i64 0), i64 135, i64 1, i32* %5)
%17 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([112 x i8], [112 x i8]* @.str.10, i64 0, i64 0), i32 1000)
br label %18
18: ; preds = %1, %7
ret void
}