#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 memory_type_list {
  int dummy;
};

/* Variables and functions */
scalar_t__ memstat_kvm_malloc(struct memory_type_list *, void *);
scalar_t__ memstat_kvm_uma(struct memory_type_list *, void *);
int memstat_kvm_all(struct memory_type_list *mtlp, void *kvm_handle) {
  if (memstat_kvm_malloc(mtlp, kvm_handle) < 0)
    return (-1);
  if (memstat_kvm_uma(mtlp, kvm_handle) < 0)
    return (-1);
  return (0);
}


x86 assembly (clang, -O0):
<memstat_kvm_all>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <memstat_kvm_malloc@plt>
cmp    $0x0,%rax
jge    1153 <memstat_kvm_all+0x33>
movl   $0xffffffff,-0x4(%rbp)
jmp    117d <memstat_kvm_all+0x5d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <memstat_kvm_uma@plt>
cmp    $0x0,%rax
jge    1176 <memstat_kvm_all+0x56>
movl   $0xffffffff,-0x4(%rbp)
jmp    117d <memstat_kvm_all+0x5d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memstat_kvm_all>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <memstat_kvm_malloc@plt>
test   %rax,%rax
js     1145 <memstat_kvm_all+0x25>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <memstat_kvm_uma@plt>
sar    $0x3f,%rax
jmp    114a <memstat_kvm_all+0x2a>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.memory_type_list = type { i32 }
define i32 @memstat_kvm_all(%struct.memory_type_list* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.memory_type_list*
%5 = alloca i8*
store %struct.memory_type_list* %0, %struct.memory_type_list** %4
store i8* %1, i8** %5
%6 = load %struct.memory_type_list*, %struct.memory_type_list** %4
%7 = load i8*, i8** %5
%8 = call i64 @memstat_kvm_malloc(%struct.memory_type_list* %6, i8* %7)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 -1, i32* %3
br label %18
11: ; preds = %2
%12 = load %struct.memory_type_list*, %struct.memory_type_list** %4
%13 = load i8*, i8** %5
%14 = call i64 @memstat_kvm_uma(%struct.memory_type_list* %12, i8* %13)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %11
store i32 -1, i32* %3
br label %18
17: ; preds = %11
store i32 0, i32* %3
br label %18
18: ; preds = %17, %16, %10
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
%struct.memory_type_list = type { i32 }
define i32 @memstat_kvm_all(%struct.memory_type_list* %0, i8* %1) {
%3 = tail call i64 @memstat_kvm_malloc(%struct.memory_type_list* %0, i8* %1)
%4 = icmp slt i64 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = tail call i64 @memstat_kvm_uma(%struct.memory_type_list* %0, i8* %1)
%7 = ashr i64 %6, 63
%8 = trunc i64 %7 to i32
br label %9
9: ; preds = %5, %2
%10 = phi i32 [ -1, %2 ], [ %8, %5 ]
ret i32 %10
}