#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;
  fprintf(stream,
          "Usage: axidma_transfer <input path> <output path> "
          "[-t <DMA tx channel>] [-r <DMA rx channel>] [-s <Output file size>"
          " | -o <Output file size>].\n");
  if (!help) {
    return;
  }
  fprintf(stream,
          "\t<input path>:\t\tThe path to file to send out over AXI "
          "DMA to the PL fabric. Can be a relative or absolute path.\n");
  fprintf(stream,
          "\t<output path>:\t\tThe path to place the received data "
          "from the PL fabric into. Can be a relative or absolute path.\n");
  fprintf(stream,
          "\t-t <DMA tx channel>:\tThe device id of the DMA channel "
          "to use for transmitting the file. Default is to use the lowest "
          "numbered channel available.\n");
  fprintf(stream,
          "\t-r <DMA rx channel>:\tThe device id of the DMA channel "
          "to use for receiving the data from the PL fabric. Default is to "
          "use the lowest numbered channel available.\n");
  fprintf(stream,
          "\t-s <Output file size>:\tThe size of the output file in "
          "bytes. This is an integer value that must be at least the number "
          "of bytes received back. By default, this is the same as the size "
          "of the input file.\n");
  fprintf(stream,
          "\t-o <Output file size>:\tThe size of the output file in "
          "Mibs. This is a floating-point value that must be at least the "
          "number of bytes received back. By default, this is the same "
          "the size of the input file.\n");
  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,-0x18(%rbp)
jmp    1146 <print_usage+0x36>
mov    0x2ea1(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1030 <fprintf@plt>
cmpl   $0x0,-0x4(%rbp)
jne    116d <print_usage+0x5d>
jmp    11cd <print_usage+0xbd>
mov    -0x10(%rbp),%rdi
lea    0xf18(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xf79(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xfdc(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0x105f(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0x10f2(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0x11af(%rip),%rsi
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    1122 <print_usage+0x12>
mov    0x2ec0(%rip),%rax
jmp    1129 <print_usage+0x19>
mov    0x2eaf(%rip),%rax
mov    (%rax),%rbx
lea    0xecd(%rip),%rdi
mov    $0x8f,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fwrite@plt>
test   %ebp,%ebp
je     11e9 <print_usage+0xd9>
lea    0xf3c(%rip),%rdi
mov    $0x70,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fwrite@plt>
lea    0xf94(%rip),%rdi
mov    $0x72,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fwrite@plt>
lea    0xfee(%rip),%rdi
mov    $0x92,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fwrite@plt>
lea    0x1068(%rip),%rdi
mov    $0xa2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fwrite@plt>
lea    0x10f2(%rip),%rdi
mov    $0xcc,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fwrite@plt>
lea    0x11a6(%rip),%rdi
mov    $0xce,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <fwrite@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32* null
@stderr = global i32* null
@.str = [144 x i8] c"Usage: axidma_transfer <input path> <output path> [-t <DMA tx channel>] [-r <DMA rx channel>] [-s <Output file size> | -o <Output file size>].\0A\00"
@.str.1 = [113 x i8] c"\09<input path>:\09\09The path to file to send out over AXI DMA to the PL fabric. Can be a relative or absolute path.\0A\00"
@.str.2 = [115 x i8] c"\09<output path>:\09\09The path to place the received data from the PL fabric into. Can be a relative or absolute path.\0A\00"
@.str.3 = [147 x i8] c"\09-t <DMA tx channel>:\09The device id of the DMA channel to use for transmitting the file. Default is to use the lowest numbered channel available.\0A\00"
@.str.4 = [163 x i8] c"\09-r <DMA rx channel>:\09The device id of the DMA channel to use for receiving the data from the PL fabric. Default is to use the lowest numbered channel available.\0A\00"
@.str.5 = [205 x i8] c"\09-s <Output file size>:\09The size of the output file in bytes. This is an integer value that must be at least the number of bytes received back. By default, this is the same as the size of the input file.\0A\00"
@.str.6 = [207 x i8] c"\09-o <Output file size>:\09The size of the output file in Mibs. This is a floating-point value that must be at least the number of bytes received back. By default, this is the same the size of the input file.\0A\00"
define void @print_usage(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = load i32*, i32** @stdout
br label %10
8: ; preds = %1
%9 = load i32*, i32** @stderr
br label %10
10: ; preds = %8, %6
%11 = phi i32* [ %7, %6 ], [ %9, %8 ]
store i32* %11, i32** %3
%12 = load i32*, i32** %3
%13 = call i32 @fprintf(i32* %12, i8* getelementptr inbounds ([144 x i8], [144 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* %2
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %10
br label %30
17: ; preds = %10
%18 = load i32*, i32** %3
%19 = call i32 @fprintf(i32* %18, i8* getelementptr inbounds ([113 x i8], [113 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32*, i32** %3
%21 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32*, i32** %3
%23 = call i32 @fprintf(i32* %22, i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str.3, i64 0, i64 0))
%24 = load i32*, i32** %3
%25 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.4, i64 0, i64 0))
%26 = load i32*, i32** %3
%27 = call i32 @fprintf(i32* %26, i8* getelementptr inbounds ([205 x i8], [205 x i8]* @.str.5, i64 0, i64 0))
%28 = load i32*, i32** %3
%29 = call i32 @fprintf(i32* %28, i8* getelementptr inbounds ([207 x i8], [207 x i8]* @.str.6, i64 0, i64 0))
br label %30
30: ; preds = %17, %16
ret void
}

LLVM IR (-O2):
@stdout = global i32* null
@stderr = global i32* null
@.str = [144 x i8] c"Usage: axidma_transfer <input path> <output path> [-t <DMA tx channel>] [-r <DMA rx channel>] [-s <Output file size> | -o <Output file size>].\0A\00"
@.str.1 = [113 x i8] c"\09<input path>:\09\09The path to file to send out over AXI DMA to the PL fabric. Can be a relative or absolute path.\0A\00"
@.str.2 = [115 x i8] c"\09<output path>:\09\09The path to place the received data from the PL fabric into. Can be a relative or absolute path.\0A\00"
@.str.3 = [147 x i8] c"\09-t <DMA tx channel>:\09The device id of the DMA channel to use for transmitting the file. Default is to use the lowest numbered channel available.\0A\00"
@.str.4 = [163 x i8] c"\09-r <DMA rx channel>:\09The device id of the DMA channel to use for receiving the data from the PL fabric. Default is to use the lowest numbered channel available.\0A\00"
@.str.5 = [205 x i8] c"\09-s <Output file size>:\09The size of the output file in bytes. This is an integer value that must be at least the number of bytes received back. By default, this is the same as the size of the input file.\0A\00"
@.str.6 = [207 x i8] c"\09-o <Output file size>:\09The size of the output file in Mibs. This is a floating-point value that must be at least the number of bytes received back. By default, this is the same the size of the input file.\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 ([144 x i8], [144 x i8]* @.str, i64 0, i64 0), i64 143, i64 1, i32* %5)
br i1 %2, label %14, label %7
7: ; preds = %1
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([113 x i8], [113 x i8]* @.str.1, i64 0, i64 0), i64 112, i64 1, i32* %5)
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str.2, i64 0, i64 0), i64 114, i64 1, i32* %5)
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str.3, i64 0, i64 0), i64 146, i64 1, i32* %5)
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.4, i64 0, i64 0), i64 162, i64 1, i32* %5)
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([205 x i8], [205 x i8]* @.str.5, i64 0, i64 0), i64 204, i64 1, i32* %5)
%13 = tail call i64 @fwrite(i8* getelementptr inbounds ([207 x i8], [207 x i8]* @.str.6, i64 0, i64 0), i64 206, i64 1, i32* %5)
br label %14
14: ; preds = %1, %7
ret void
}