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

/* Variables and functions */
struct mallinfo mallinfo();
int /*<<< orphan*/ printf(char *, ...);
void mymemstat() {
  struct mallinfo mi;
  mi = mallinfo();
  printf("arena: %d\n", mi.arena);
  printf("uordblks: %d\n", mi.uordblks);
  printf("fordblks: %d\n", mi.fordblks);
  printf("\n");
}


x86 assembly (clang, -O0):
<mymemstat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
xor    %eax,%eax
call   1040 <mallinfo@plt>
mov    %edx,-0x28(%rbp)
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%esi
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mymemstat>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <mallinfo@plt>
mov    %edx,%ebp
mov    %rax,%rbx
shr    $0x20,%rbx
lea    0xeb6(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeaf(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
%struct.mallinfo = type { i32, i32, i32 }
@.str = [11 x i8] c"arena: %d\0A\00"
@.str.1 = [14 x i8] c"uordblks: %d\0A\00"
@.str.2 = [14 x i8] c"fordblks: %d\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @mymemstat() {
%1 = alloca %struct.mallinfo
%2 = alloca %struct.mallinfo
%3 = alloca { i64, i32 }
%4 = call { i64, i32 } (...) @mallinfo()
store { i64, i32 } %4, { i64, i32 }* %3
%5 = bitcast %struct.mallinfo* %2 to i8*
%6 = bitcast { i64, i32 }* %3 to i8*
%7 = bitcast %struct.mallinfo* %1 to i8*
%8 = bitcast %struct.mallinfo* %2 to i8*
%9 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %1, i32 0, i32 0
%10 = load i32, i32* %9
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %1, i32 0, i32 1
%13 = load i32, i32* %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %1, i32 0, i32 2
%16 = load i32, i32* %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"arena: %d\0A\00"
@.str.1 = [14 x i8] c"uordblks: %d\0A\00"
@.str.2 = [14 x i8] c"fordblks: %d\0A\00"
define void @mymemstat() {
%1 = tail call { i64, i32 } (...) @mallinfo()
%2 = extractvalue { i64, i32 } %1, 0
%3 = extractvalue { i64, i32 } %1, 1
%4 = trunc i64 %2 to i32
%5 = lshr i64 %2, 32
%6 = trunc i64 %5 to i32
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %4)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %3)
%10 = tail call i32 @putchar(i32 10)
ret void
}