#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 */
struct mallinfo {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ M_MMAP_THRESHOLD;
int /*<<< orphan*/ cfree(void *);
int /*<<< orphan*/ free(void *);
struct mallinfo mallinfo();
void *malloc(int);
void *malloc_get_state();
int /*<<< orphan*/ malloc_stats();
int /*<<< orphan*/ malloc_trim(int);
int /*<<< orphan*/ mallopt(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int main() {
  void *p;
  struct mallinfo info;
  p = malloc(37);
  cfree(p);
  mallopt(M_MMAP_THRESHOLD, 32 * 1024);
  info = mallinfo();
  malloc_trim(16);
  malloc_stats();
  p = malloc_get_state();
  free(p);
  printf("success\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x25,%edi
call   1080 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   10b0 <cfree@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
mov    $0x8000,%esi
call   1040 <mallopt@plt>
mov    $0x0,%al
call   1070 <mallinfo@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x10,%edi
call   1090 <malloc_trim@plt>
mov    $0x0,%al
call   10a0 <malloc_stats@plt>
mov    $0x0,%al
call   1050 <malloc_get_state@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
lea    0xdfb(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x25,%edi
call   1080 <malloc@plt>
mov    %rax,%rdi
call   10b0 <cfree@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
mov    $0x8000,%esi
call   1050 <mallopt@plt>
xor    %eax,%eax
call   1070 <mallinfo@plt>
mov    $0x10,%edi
call   1090 <malloc_trim@plt>
xor    %eax,%eax
call   10a0 <malloc_stats@plt>
xor    %eax,%eax
call   1060 <malloc_get_state@plt>
mov    %rax,%rdi
call   1030 <free@plt>
lea    0xe1c(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.mallinfo = type { i32 }
@M_MMAP_THRESHOLD = global i32 0
@.str = [9 x i8] c"success\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca %struct.mallinfo
%4 = alloca %struct.mallinfo
store i32 0, i32* %1
%5 = call i8* @malloc(i32 37)
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @cfree(i8* %6)
%8 = load i32, i32* @M_MMAP_THRESHOLD
%9 = call i32 @mallopt(i32 %8, i32 32768)
%10 = call i32 (...) @mallinfo()
%11 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %4, i32 0, i32 0
store i32 %10, i32* %11
%12 = bitcast %struct.mallinfo* %3 to i8*
%13 = bitcast %struct.mallinfo* %4 to i8*
%14 = call i32 @malloc_trim(i32 16)
%15 = call i32 (...) @malloc_stats()
%16 = call i8* (...) @malloc_get_state()
store i8* %16, i8** %2
%17 = load i8*, i8** %2
%18 = call i32 @free(i8* %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@M_MMAP_THRESHOLD = global i32 0
@str = [8 x i8] c"success\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(37) i8* @malloc(i32 37)
%2 = tail call i32 @cfree(i8* %1)
%3 = load i32, i32* @M_MMAP_THRESHOLD
%4 = tail call i32 @mallopt(i32 %3, i32 32768)
%5 = tail call i32 (...) @mallinfo()
%6 = tail call i32 @malloc_trim(i32 16)
%7 = tail call i32 (...) @malloc_stats()
%8 = tail call i8* (...) @malloc_get_state()
%9 = tail call i32 @free(i8* %8)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
ret i32 0
}