#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*/ _SC_PAGESIZE;
int /*<<< orphan*/ _SC_PHYS_PAGES;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ prep_exit();
int /*<<< orphan*/ progressbar_error(char *);
long long sysconf(int /*<<< orphan*/);
int get_physical_memory() {
  long long num_pages = sysconf(_SC_PHYS_PAGES);
  long long page_size = sysconf(_SC_PAGESIZE);
  int phys_mem = num_pages * page_size >> 20;
  if (phys_mem < 64)
    do {
      progressbar_error("FATAL ERROR:"
                        "Mksquashfs requires more physical memory than is "
                        "available!\n");
      do {
        prep_exit();
        exit(1);
      } while (0);
    } while (0);
  return phys_mem;
}


x86 assembly (clang, -O0):
<get_physical_memory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
call   1040 <sysconf@plt>
mov    %rax,-0x8(%rbp)
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
call   1040 <sysconf@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
imul   -0x10(%rbp),%rax
sar    $0x14,%rax
mov    %eax,-0x14(%rbp)
cmpl   $0x40,-0x14(%rbp)
jge    11a8 <get_physical_memory+0x68>
jmp    118b <get_physical_memory+0x4b>
lea    0xe6e(%rip),%rdi
call   1050 <progressbar_error@plt>
mov    $0x0,%al
call   1030 <prep_exit@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_physical_memory>:
push   %rbx
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
call   1040 <sysconf@plt>
mov    %rax,%rbx
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
call   1040 <sysconf@plt>
imul   %rbx,%rax
shr    $0x14,%rax
cmp    $0x3f,%eax
jle    116f <get_physical_memory+0x2f>
pop    %rbx
ret
lea    0xe8a(%rip),%rdi
call   1050 <progressbar_error@plt>
xor    %eax,%eax
call   1030 <prep_exit@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@_SC_PHYS_PAGES = global i32 0
@_SC_PAGESIZE = global i32 0
@.str = [73 x i8] c"FATAL ERROR:Mksquashfs requires more physical memory than is available!\0A\00"
define i32 @get_physical_memory() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i32
%4 = load i32, i32* @_SC_PHYS_PAGES
%5 = call i64 @sysconf(i32 %4)
store i64 %5, i64* %1
%6 = load i32, i32* @_SC_PAGESIZE
%7 = call i64 @sysconf(i32 %6)
store i64 %7, i64* %2
%8 = load i64, i64* %1
%9 = load i64, i64* %2
%10 = mul nsw i64 %8, %9
%11 = ashr i64 %10, 20
%12 = trunc i64 %11 to i32
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 64
br i1 %14, label %15, label %23
15: ; preds = %0
br label %16
16: ; preds = %15
%17 = call i32 @progressbar_error(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16
%19 = call i32 (...) @prep_exit()
%20 = call i32 @exit(i32 1)
unreachable
21: ; No predecessors!
br label %22
22: ; preds = %21
br label %23
23: ; preds = %22, %0
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@_SC_PHYS_PAGES = global i32 0
@_SC_PAGESIZE = global i32 0
@.str = [73 x i8] c"FATAL ERROR:Mksquashfs requires more physical memory than is available!\0A\00"
define i32 @get_physical_memory() {
%1 = load i32, i32* @_SC_PHYS_PAGES
%2 = tail call i64 @sysconf(i32 %1)
%3 = load i32, i32* @_SC_PAGESIZE
%4 = tail call i64 @sysconf(i32 %3)
%5 = mul nsw i64 %4, %2
%6 = lshr i64 %5, 20
%7 = trunc i64 %6 to i32
%8 = icmp slt i32 %7, 64
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = tail call i32 @progressbar_error(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 (...) @prep_exit()
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %0
ret i32 %7
}