#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 hblkhd;
  int arena;
  int uordblks;
  int fordblks;
};

/* Variables and functions */
int /*<<< orphan*/ free(void *);
struct mallinfo mallinfo();
void *malloc(int);
int /*<<< orphan*/ printf(char *, int, int, int, int);
int main(void) {
  struct mallinfo m;
  void *p, *q;
  m = mallinfo();
  printf("%8d  %d = %d + %d\n", m.hblkhd, m.arena, m.uordblks, m.fordblks);
  q = malloc(16 * 1024);
  m = mallinfo();
  printf("%8d  %d = %d + %d\n", m.hblkhd, m.arena, m.uordblks, m.fordblks);
  p = malloc(1024 * 1024);
  m = mallinfo();
  printf("%8d  %d = %d + %d\n", m.hblkhd, m.arena, m.uordblks, m.fordblks);
  free(q);
  m = mallinfo();
  printf("%8d  %d = %d + %d\n", m.hblkhd, m.arena, m.uordblks, m.fordblks);
  free(p);
  m = mallinfo();
  printf("%8d  %d = %d + %d\n", m.hblkhd, m.arena, m.uordblks, m.fordblks);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <mallinfo@plt>
mov    %rax,-0x38(%rbp)
mov    %rdx,-0x30(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%r8d
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
mov    $0x4000,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1050 <mallinfo@plt>
mov    %rax,-0x48(%rbp)
mov    %rdx,-0x40(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%r8d
lea    0xe35(%rip),%rdi
call   1040 <printf@plt>
mov    $0x100000,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1050 <mallinfo@plt>
mov    %rax,-0x58(%rbp)
mov    %rdx,-0x50(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%r8d
lea    0xdef(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1050 <mallinfo@plt>
mov    %rax,-0x68(%rbp)
mov    %rdx,-0x60(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%r8d
lea    0xdae(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1050 <mallinfo@plt>
mov    %rax,-0x78(%rbp)
mov    %rdx,-0x70(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%r8d
lea    0xd6d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1050 <mallinfo@plt>
mov    %rdx,%rcx
mov    %rax,%rdx
shr    $0x20,%rdx
mov    %rcx,%r8
shr    $0x20,%r8
lea    0xe9c(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x4000,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1050 <mallinfo@plt>
mov    %rdx,%rcx
mov    %rax,%rdx
shr    $0x20,%rdx
mov    %rcx,%r8
shr    $0x20,%r8
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x100000,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <mallinfo@plt>
mov    %rdx,%rcx
mov    %rax,%rdx
shr    $0x20,%rdx
mov    %rcx,%r8
shr    $0x20,%r8
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1050 <mallinfo@plt>
mov    %rdx,%rcx
mov    %rax,%rdx
shr    $0x20,%rdx
mov    %rcx,%r8
shr    $0x20,%r8
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1050 <mallinfo@plt>
mov    %rdx,%rcx
mov    %rax,%rdx
shr    $0x20,%rdx
mov    %rcx,%r8
shr    $0x20,%r8
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.mallinfo = type { i32, i32, i32, i32 }
@.str = [19 x i8] c"%8d %d = %d + %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.mallinfo
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca %struct.mallinfo
%6 = alloca %struct.mallinfo
%7 = alloca %struct.mallinfo
%8 = alloca %struct.mallinfo
%9 = alloca %struct.mallinfo
store i32 0, i32* %1
%10 = call { i64, i64 } (...) @mallinfo()
%11 = bitcast %struct.mallinfo* %5 to { i64, i64 }*
%12 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %11, i32 0, i32 0
%13 = extractvalue { i64, i64 } %10, 0
store i64 %13, i64* %12
%14 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %11, i32 0, i32 1
%15 = extractvalue { i64, i64 } %10, 1
store i64 %15, i64* %14
%16 = bitcast %struct.mallinfo* %2 to i8*
%17 = bitcast %struct.mallinfo* %5 to i8*
%18 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %2, i32 0, i32 0
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %2, i32 0, i32 1
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %2, i32 0, i32 2
%23 = load i32, i32* %22
%24 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %2, i32 0, i32 3
%25 = load i32, i32* %24
%26 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %19, i32 %21, i32 %23, i32 %25)
%27 = call i8* @malloc(i32 16384)
store i8* %27, i8** %4
%28 = call { i64, i64 } (...) @mallinfo()
%29 = bitcast %struct.mallinfo* %6 to { i64, i64 }*
%30 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %29, i32 0, i32 0
%31 = extractvalue { i64, i64 } %28, 0
store i64 %31, i64* %30
%32 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %29, i32 0, i32 1
%33 = extractvalue { i64, i64 } %28, 1
store i64 %33, i64* %32
%34 = bitcast %struct.mallinfo* %2 to i8*
%35 = bitcast %struct.mallinfo* %6 to i8*
%36 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %2, i32 0, i32 0
%37 = load i32, i32* %36
%38 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %2, i32 0, i32 1
%39 = load i32, i32* %38
%40 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %2, i32 0, i32 2
%41 = load i32, i32* %40
%42 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %2, i32 0, i32 3
%43 = load i32, i32* %42
%44 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %37, i32 %39, i32 %41, i32 %43)
%45 = call i8* @malloc(i32 1048576)
store i8* %45, i8** %3
%46 = call { i64, i64 } (...) @mallinfo()
%47 = bitcast %struct.mallinfo* %7 to { i64, i64 }*
%48 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %47, i32 0, i32 0
%49 = extractvalue { i64, i64 } %46, 0
store i64 %49, i64* %48
%50 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %47, i32 0, i32 1
%51 = extractvalue { i64, i64 } %46, 1
store i64 %51, i64* %50
%52 = bitcast %struct.mallinfo* %2 to i8*
%53 = bitcast %struct.mallinfo* %7 to i8*
%54 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %2, i32 0, i32 0
%55 = load i32, i32* %54
%56 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %2, i32 0, i32 1
%57 = load i32, i32* %56
%58 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %2, i32 0, i32 2
%59 = load i32, i32* %58
%60 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %2, i32 0, i32 3
%61 = load i32, i32* %60
%62 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %55, i32 %57, i32 %59, i32 %61)
%63 = load i8*, i8** %4
%64 = call i32 @free(i8* %63)
%65 = call { i64, i64 } (...) @mallinfo()
%66 = bitcast %struct.mallinfo* %8 to { i64, i64 }*
%67 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %66, i32 0, i32 0
%68 = extractvalue { i64, i64 } %65, 0
store i64 %68, i64* %67
%69 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %66, i32 0, i32 1
%70 = extractvalue { i64, i64 } %65, 1
store i64 %70, i64* %69
%71 = bitcast %struct.mallinfo* %2 to i8*
%72 = bitcast %struct.mallinfo* %8 to i8*
%73 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %2, i32 0, i32 0
%74 = load i32, i32* %73
%75 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %2, i32 0, i32 1
%76 = load i32, i32* %75
%77 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %2, i32 0, i32 2
%78 = load i32, i32* %77
%79 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %2, i32 0, i32 3
%80 = load i32, i32* %79
%81 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %74, i32 %76, i32 %78, i32 %80)
%82 = load i8*, i8** %3
%83 = call i32 @free(i8* %82)
%84 = call { i64, i64 } (...) @mallinfo()
%85 = bitcast %struct.mallinfo* %9 to { i64, i64 }*
%86 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %85, i32 0, i32 0
%87 = extractvalue { i64, i64 } %84, 0
store i64 %87, i64* %86
%88 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %85, i32 0, i32 1
%89 = extractvalue { i64, i64 } %84, 1
store i64 %89, i64* %88
%90 = bitcast %struct.mallinfo* %2 to i8*
%91 = bitcast %struct.mallinfo* %9 to i8*
%92 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %2, i32 0, i32 0
%93 = load i32, i32* %92
%94 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %2, i32 0, i32 1
%95 = load i32, i32* %94
%96 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %2, i32 0, i32 2
%97 = load i32, i32* %96
%98 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %2, i32 0, i32 3
%99 = load i32, i32* %98
%100 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %93, i32 %95, i32 %97, i32 %99)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"%8d %d = %d + %d\0A\00"
define i32 @main() {
%1 = tail call { i64, i64 } (...) @mallinfo()
%2 = extractvalue { i64, i64 } %1, 0
%3 = extractvalue { i64, i64 } %1, 1
%4 = trunc i64 %2 to i32
%5 = lshr i64 %2, 32
%6 = trunc i64 %5 to i32
%7 = trunc i64 %3 to i32
%8 = lshr i64 %3, 32
%9 = trunc i64 %8 to i32
%10 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %6, i32 %7, i32 %9)
%11 = tail call dereferenceable_or_null(16384) i8* @malloc(i32 16384)
%12 = tail call { i64, i64 } (...) @mallinfo()
%13 = extractvalue { i64, i64 } %12, 0
%14 = extractvalue { i64, i64 } %12, 1
%15 = trunc i64 %13 to i32
%16 = lshr i64 %13, 32
%17 = trunc i64 %16 to i32
%18 = trunc i64 %14 to i32
%19 = lshr i64 %14, 32
%20 = trunc i64 %19 to i32
%21 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %17, i32 %18, i32 %20)
%22 = tail call dereferenceable_or_null(1048576) i8* @malloc(i32 1048576)
%23 = tail call { i64, i64 } (...) @mallinfo()
%24 = extractvalue { i64, i64 } %23, 0
%25 = extractvalue { i64, i64 } %23, 1
%26 = trunc i64 %24 to i32
%27 = lshr i64 %24, 32
%28 = trunc i64 %27 to i32
%29 = trunc i64 %25 to i32
%30 = lshr i64 %25, 32
%31 = trunc i64 %30 to i32
%32 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %26, i32 %28, i32 %29, i32 %31)
%33 = tail call i32 @free(i8* %11)
%34 = tail call { i64, i64 } (...) @mallinfo()
%35 = extractvalue { i64, i64 } %34, 0
%36 = extractvalue { i64, i64 } %34, 1
%37 = trunc i64 %35 to i32
%38 = lshr i64 %35, 32
%39 = trunc i64 %38 to i32
%40 = trunc i64 %36 to i32
%41 = lshr i64 %36, 32
%42 = trunc i64 %41 to i32
%43 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %37, i32 %39, i32 %40, i32 %42)
%44 = tail call i32 @free(i8* %22)
%45 = tail call { i64, i64 } (...) @mallinfo()
%46 = extractvalue { i64, i64 } %45, 0
%47 = extractvalue { i64, i64 } %45, 1
%48 = trunc i64 %46 to i32
%49 = lshr i64 %46, 32
%50 = trunc i64 %49 to i32
%51 = trunc i64 %47 to i32
%52 = lshr i64 %47, 32
%53 = trunc i64 %52 to i32
%54 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %48, i32 %50, i32 %51, i32 %53)
ret i32 0
}