#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
void usage(const char *name, const char *option, const char *error) {
  fprintf(stderr, "\nERROR in option '%s': %s!\n\n", option, error);
  fprintf(stderr, "usage: %s [options] < allocs\n\n", name);
  fprintf(stderr,
          "options:\n"
          "\t-s\t\tData contains only single run (allocs marked differently)\n"
          "\t-t <heap-top>\tTop of the heap\n"
          "\t-k <keepcost>\tHow much could be trimmed off the heap top\n"
          "\t-h <address>\tHighest allocated address in the use-case\n"
          "\t\t\t(doesn't take into account size of the allocation)\n"
          "\t-l <address>\tLowest allocated address the use-case\n"
          "\t-b <heap-base>\tBottom address of the heap\n"
          "\t-p <page size>\tPage size to use in output in KB (1,2,4...)\n");
  fprintf(stderr,
          "Alloc format is \"hex-address dec-size\", for example:\n"
          "%s -t 0x08443215 -k 131072\n"
          "0x0834aa90 22\n0x0834ab70 15\n\n",
          name);
  fprintf(
      stderr,
      "Heap base and top are given as hexadecimal and trim offset (keepcost)\n"
      "as decimal. They can also be given before the allocs in the input "
      "file:\n"
      "# base=0x08100000\n# top=0x0854aa90\n# keepcost=131072\n\n"
      "Input file overrides the command line options (it's parsed later)\n"
      "Base should be set before anything else. Program doesn't check this,\n"
      "the results will just be funny...\n");
  exit(1);
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xeb4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xeb6(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
lea    0xebe(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0x104e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0x10a5(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<usage>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rcx
mov    %rsi,%rdx
mov    %rdi,%rbx
mov    0x2eac(%rip),%r14
mov    (%r14),%edi
lea    0xec2(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%edi
lea    0xece(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%edi
lea    0xed9(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%edi
lea    0x1073(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%edi
lea    0x10cd(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"\0AERROR in option '%s': %s!\0A\0A\00"
@.str.1 = [31 x i8] c"usage: %s [options] < allocs\0A\0A\00"
@.str.2 = [427 x i8] c"options:\0A\09-s\09\09Data contains only single run (allocs marked differently)\0A\09-t <heap-top>\09Top of the heap\0A\09-k <keepcost>\09How much could be trimmed off the heap top\0A\09-h <address>\09Highest allocated address in the use-case\0A\09\09\09(doesn't take into account size of the allocation)\0A\09-l <address>\09Lowest allocated address the use-case\0A\09-b <heap-base>\09Bottom address of the heap\0A\09-p <page size>\09Page size to use in output in KB (1,2,4...)\0A\00"
@.str.3 = [110 x i8] c"Alloc format is \22hex-address dec-size\22, for example:\0A%s -t 0x08443215 -k 131072\0A0x0834aa90 22\0A0x0834ab70 15\0A\0A\00"
@.str.4 = [366 x i8] c"Heap base and top are given as hexadecimal and trim offset (keepcost)\0Aas decimal. They can also be given before the allocs in the input file:\0A# base=0x08100000\0A# top=0x0854aa90\0A# keepcost=131072\0A\0AInput file overrides the command line options (it's parsed later)\0ABase should be set before anything else. Program doesn't check this,\0Athe results will just be funny...\0A\00"
define void @usage(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %5
%9 = load i8*, i8** %6
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %9)
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %4
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([427 x i8], [427 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %4
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([110 x i8], [110 x i8]* @.str.3, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([366 x i8], [366 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"\0AERROR in option '%s': %s!\0A\0A\00"
@.str.1 = [31 x i8] c"usage: %s [options] < allocs\0A\0A\00"
@.str.2 = [427 x i8] c"options:\0A\09-s\09\09Data contains only single run (allocs marked differently)\0A\09-t <heap-top>\09Top of the heap\0A\09-k <keepcost>\09How much could be trimmed off the heap top\0A\09-h <address>\09Highest allocated address in the use-case\0A\09\09\09(doesn't take into account size of the allocation)\0A\09-l <address>\09Lowest allocated address the use-case\0A\09-b <heap-base>\09Bottom address of the heap\0A\09-p <page size>\09Page size to use in output in KB (1,2,4...)\0A\00"
@.str.3 = [110 x i8] c"Alloc format is \22hex-address dec-size\22, for example:\0A%s -t 0x08443215 -k 131072\0A0x0834aa90 22\0A0x0834ab70 15\0A\0A\00"
@.str.4 = [366 x i8] c"Heap base and top are given as hexadecimal and trim offset (keepcost)\0Aas decimal. They can also be given before the allocs in the input file:\0A# base=0x08100000\0A# top=0x0854aa90\0A# keepcost=131072\0A\0AInput file overrides the command line options (it's parsed later)\0ABase should be set before anything else. Program doesn't check this,\0Athe results will just be funny...\0A\00"
define void @usage(i8* %0, i8* %1, i8* %2) {
%4 = load i32, i32* @stderr
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([427 x i8], [427 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([110 x i8], [110 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([366 x i8], [366 x i8]* @.str.4, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
}