#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*/ M_MMAP_THRESHOLD;
int atoi(char *);
int /*<<< orphan*/ doit(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int);
int mallopt(int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int thresh, rc;
  if (argc > 1) {
    thresh = atoi(argv[1]);
    rc = mallopt(M_MMAP_THRESHOLD, thresh);
    fprintf(stderr,
            "rc=%d from requesting mmap"
            " for more than thresh=%d bytes\n",
            rc, thresh);
  }
  doit(13);
  doit(13 * 1024);
  doit(13 * 1024 * 1024);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11af <main+0x5f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%esi
call   1030 <mallopt@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe56(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xd,%edi
call   1050 <doit@plt>
mov    $0x3400,%edi
call   1050 <doit@plt>
mov    $0xd00000,%edi
call   1050 <doit@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jl     118a <main+0x3a>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
mov    %ebx,%esi
call   1030 <mallopt@plt>
mov    0x2e68(%rip),%rcx
mov    (%rcx),%edi
lea    0xe7f(%rip),%rsi
mov    %eax,%edx
mov    %ebx,%ecx
call   1040 <fprintf@plt>
mov    $0xd,%edi
call   1050 <doit@plt>
mov    $0x3400,%edi
call   1050 <doit@plt>
mov    $0xd00000,%edi
call   1050 <doit@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@M_MMAP_THRESHOLD = global i32 0
@stderr = global i32 0
@.str = [58 x i8] c"rc=%d from requesting mmap for more than thresh=%d bytes\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %22
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @atoi(i8* %13)
store i32 %14, i32* %6
%15 = load i32, i32* @M_MMAP_THRESHOLD
%16 = load i32, i32* %6
%17 = call i32 @mallopt(i32 %15, i32 %16)
store i32 %17, i32* %7
%18 = load i32, i32* @stderr
%19 = load i32, i32* %7
%20 = load i32, i32* %6
%21 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %19, i32 %20)
br label %22
22: ; preds = %10, %2
%23 = call i32 @doit(i32 13)
%24 = call i32 @doit(i32 13312)
%25 = call i32 @doit(i32 13631488)
%26 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@M_MMAP_THRESHOLD = global i32 0
@stderr = global i32 0
@.str = [58 x i8] c"rc=%d from requesting mmap for more than thresh=%d bytes\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %12
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = load i32, i32* @M_MMAP_THRESHOLD
%9 = tail call i32 @mallopt(i32 %8, i32 %7)
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %7)
br label %12
12: ; preds = %4, %2
%13 = tail call i32 @doit(i32 13)
%14 = tail call i32 @doit(i32 13312)
%15 = tail call i32 @doit(i32 13631488)
%16 = tail call i32 @exit(i32 0)
unreachable
}