#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 *);
void cmd_help(int argc, char *argv[]) {
  printf(
      "Available commands:\n"
      "    help                            Show this help screen\n"
      "    fork                            Fork off another shelldemo process\n"
      "    exec <cmd>                      Execute <cmd>\n"
      "    system <cmd>                    Fork and execute <cmd> on "
      "std(in/out/err)\n"
      "    quit                            Exit the shell\n"
      "\n"
      "    open <path>                     Open a file and return the file "
      "descriptor\n"
      "    lseek <fd> <offset> <whence>    Reposition <fd>\n"
      "    read <fd> [bytes]               Read <bytes> from file descriptor\n"
      "    write <fd> [bytes]              Write [bytes] (or until \"EOF\") to "
      "<fd>\n"
      "    close <fd>                      Close specified file descriptor\n"
      "    dup <old_fd>                    Duplicate <old_fd> and return new "
      "reference\n"
      "    dup2 <old_fd> <new_fd>          Duplicate <old_fd> to <new_fd>\n"
      "\n"
      "    ls [path]                       Print information/contents about "
      "[path] (default: .)\n"
      "    getcwd                          Get current working directory\n"
      "    pwd                             Get current working directory\n"
      "    cd                              Set current working directory\n"
      "    chmod <permission> <path>       Change <path> permissions to "
      "<permission>\n"
      "    chown <user> <path>             Change <path> owner to <user>\n"
      "    chgrp <group> <path>            Change <path> group to <group>\n"
      "    chdir <path>                    Change working directory to <path>\n"
      "    mkdir <path> [permission]       Create <path> directory with "
      "[permission] (default: 755)\n"
      "    rmdir <path>                    Remove <path> directory\n"
      "    rename <old_file> <new_file>    Rename <old_file> to <new_file>\n"
      "    unlink <path>                   Remove <path> file\n"
      "    chroot <path>                   Change root directory to <path>\n"
      "    link <file> <reference>         Hard link <reference> to <file>\n"
      "    symlink <file> <reference>      Symbolically link <reference> to "
      "<file>\n"
      "    cp <file> <file>                Copy a file from one directory to "
      "another\n"
      "\n"
      "    getid                           Print information about [e][ug]id\n"
      "    setuid <uid>                    Set UID to <uid>\n"
      "    setgid <gid>                    Set GID to <gid>\n"
      "\n"
      "    kill <pid> [signal]             Send <pid> [signal] (default: 9)\n"
      "    getpid                          Print current process ID\n"
      "    getppid                         Print parent process ID\n"
      "    ps                              Print process list\n"
      "\n"
      "    time                            Display the current system time\n"
      "    uname                           Get kernel information\n"
      "    hostname [name]                 Print (or set) the hostname\n"
      "    reboot                          Reboot the computer\n"
      "    shutdown                        Shutdown the computer\n"
      "    halt                            Halt the computer\n"
      "\n"
      "    lsfd                            Show information about open file "
      "descriptors\n"
      "\n"
      "    download <url> <file>           Download a file to disk over HTTP\n"
      "\n"
      "Warning! Before using any of the following you are recommended to fork "
      "for your own safety!\n"
      "    fchdir_breakchroot <temp_dir>   Use <temp_dir> to attempt to break "
      "out of chroot\n");
}


x86 assembly (clang, -O0):
<cmd_help>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeda(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_help>:
lea    0xee9(%rip),%rdi
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [3071 x i8] c"Available commands:\0A help Show this help screen\0A fork Fork off another shelldemo process\0A exec <cmd> Execute <cmd>\0A system <cmd> Fork and execute <cmd> on std(in/out/err)\0A quit Exit the shell\0A\0A open <path> Open a file and return the file descriptor\0A lseek <fd> <offset> <whence> Reposition <fd>\0A read <fd> [bytes] Read <bytes> from file descriptor\0A write <fd> [bytes] Write [bytes] (or until \22EOF\22) to <fd>\0A close <fd> Close specified file descriptor\0A dup <old_fd> Duplicate <old_fd> and return new reference\0A dup2 <old_fd> <new_fd> Duplicate <old_fd> to <new_fd>\0A\0A ls [path] Print information/contents about [path] (default: .)\0A getcwd Get current working directory\0A pwd Get current working directory\0A cd Set current working directory\0A chmod <permission> <path> Change <path> permissions to <permission>\0A chown <user> <path> Change <path> owner to <user>\0A chgrp <group> <path> Change <path> group to <group>\0A chdir <path> Change working directory to <path>\0A mkdir <path> [permission] Create <path> directory with [permission] (default: 755)\0A rmdir <path> Remove <path> directory\0A rename <old_file> <new_file> Rename <old_file> to <new_file>\0A unlink <path> Remove <path> file\0A chroot <path> Change root directory to <path>\0A link <file> <reference> Hard link <reference> to <file>\0A symlink <file> <reference> Symbolically link <reference> to <file>\0A cp <file> <file> Copy a file from one directory to another\0A\0A getid Print information about [e][ug]id\0A setuid <uid> Set UID to <uid>\0A setgid <gid> Set GID to <gid>\0A\0A kill <pid> [signal] Send <pid> [signal] (default: 9)\0A getpid Print current process ID\0A getppid Print parent process ID\0A ps Print process list\0A\0A time Display the current system time\0A uname Get kernel information\0A hostname [name] Print (or set) the hostname\0A reboot Reboot the computer\0A shutdown Shutdown the computer\0A halt Halt the computer\0A\0A lsfd Show information about open file descriptors\0A\0A download <url> <file> Download a file to disk over HTTP\0A\0AWarning! Before using any of the following you are recommended to fork for your own safety!\0A fchdir_breakchroot <temp_dir> Use <temp_dir> to attempt to break out of chroot\0A\00"
define void @cmd_help(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
store i32 %0, i32* %3
store i8** %1, i8*** %4
%5 = call i32 @printf(i8* getelementptr inbounds ([3071 x i8], [3071 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [3070 x i8] c"Available commands:\0A help Show this help screen\0A fork Fork off another shelldemo process\0A exec <cmd> Execute <cmd>\0A system <cmd> Fork and execute <cmd> on std(in/out/err)\0A quit Exit the shell\0A\0A open <path> Open a file and return the file descriptor\0A lseek <fd> <offset> <whence> Reposition <fd>\0A read <fd> [bytes] Read <bytes> from file descriptor\0A write <fd> [bytes] Write [bytes] (or until \22EOF\22) to <fd>\0A close <fd> Close specified file descriptor\0A dup <old_fd> Duplicate <old_fd> and return new reference\0A dup2 <old_fd> <new_fd> Duplicate <old_fd> to <new_fd>\0A\0A ls [path] Print information/contents about [path] (default: .)\0A getcwd Get current working directory\0A pwd Get current working directory\0A cd Set current working directory\0A chmod <permission> <path> Change <path> permissions to <permission>\0A chown <user> <path> Change <path> owner to <user>\0A chgrp <group> <path> Change <path> group to <group>\0A chdir <path> Change working directory to <path>\0A mkdir <path> [permission] Create <path> directory with [permission] (default: 755)\0A rmdir <path> Remove <path> directory\0A rename <old_file> <new_file> Rename <old_file> to <new_file>\0A unlink <path> Remove <path> file\0A chroot <path> Change root directory to <path>\0A link <file> <reference> Hard link <reference> to <file>\0A symlink <file> <reference> Symbolically link <reference> to <file>\0A cp <file> <file> Copy a file from one directory to another\0A\0A getid Print information about [e][ug]id\0A setuid <uid> Set UID to <uid>\0A setgid <gid> Set GID to <gid>\0A\0A kill <pid> [signal] Send <pid> [signal] (default: 9)\0A getpid Print current process ID\0A getppid Print parent process ID\0A ps Print process list\0A\0A time Display the current system time\0A uname Get kernel information\0A hostname [name] Print (or set) the hostname\0A reboot Reboot the computer\0A shutdown Shutdown the computer\0A halt Halt the computer\0A\0A lsfd Show information about open file descriptors\0A\0A download <url> <file> Download a file to disk over HTTP\0A\0AWarning! Before using any of the following you are recommended to fork for your own safety!\0A fchdir_breakchroot <temp_dir> Use <temp_dir> to attempt to break out of chroot\00"
define void @cmd_help(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3070 x i8], [3070 x i8]* @str, i64 0, i64 0))
ret void
}