#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 M_memSize();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stdout;
void primem(int np) {
  int memsize;
  memsize = M_memSize();
  if (memsize) {
    fprintf(stdout, "\n  -- MEMORY REQUIREMENTS\n");
    if (memsize > 1024 * 1024)
      fprintf(stdout, "  Total size :  %10Zd Mbytes",
              (long int)(memsize / (1024. * 1024.)));
    else if (memsize > 1024)
      fprintf(stdout, "  Total size :  %10Zd Kbytes",
              (long int)(memsize / 1024.));
    else
      fprintf(stdout, "  Total size :  %10Zd bytes ", (long int)memsize);
    fprintf(stdout, "    (i.e. %d bytes/point)\n", memsize / np);
  }
}


x86 assembly (clang, -O0):
<primem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1030 <M_memSize@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1214 <primem+0xf4>
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
lea    0xec1(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
cmpl   $0x100000,-0x8(%rbp)
jle    1195 <primem+0x75>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe8f(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdx
lea    0xea2(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11f4 <primem+0xd4>
cmpl   $0x400,-0x8(%rbp)
jle    11d4 <primem+0xb4>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe48(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdx
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11ef <primem+0xcf>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
movslq -0x8(%rbp),%rdx
lea    0xe7d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11f4 <primem+0xd4>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%eax
cltd
idivl  -0x4(%rbp)
mov    %eax,%edx
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<primem>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <M_memSize@plt>
test   %eax,%eax
je     1170 <primem+0x50>
mov    %eax,%ebp
mov    0x2ea6(%rip),%r14
mov    (%r14),%edi
lea    0xecc(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x100001,%ebp
jl     1175 <primem+0x55>
mov    (%r14),%edi
cvtsi2sd %ebp,%xmm0
mulsd  0xea6(%rip),%xmm0
cvttsd2si %xmm0,%rdx
lea    0xebd(%rip),%rsi
jmp    11a4 <primem+0x84>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    (%r14),%edi
cmp    $0x401,%ebp
jl     119a <primem+0x7a>
cvtsi2sd %ebp,%xmm0
mulsd  0xe74(%rip),%xmm0
cvttsd2si %xmm0,%rdx
lea    0xeb0(%rip),%rsi
jmp    11a4 <primem+0x84>
movslq %ebp,%rdx
lea    0xec1(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
mov    %ebp,%eax
cltd
idiv   %ebx
lea    0xec8(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [27 x i8] c"\0A -- MEMORY REQUIREMENTS\0A\00"
@.str.1 = [29 x i8] c" Total size : %10Zd Mbytes\00"
@.str.2 = [29 x i8] c" Total size : %10Zd Kbytes\00"
@.str.3 = [29 x i8] c" Total size : %10Zd bytes \00"
@.str.4 = [27 x i8] c" (i.e. %d bytes/point)\0A\00"
define void @primem(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 (...) @M_memSize()
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %41
7: ; preds = %1
%8 = load i32, i32* @stdout
%9 = call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 1048576
br i1 %11, label %12, label %19
12: ; preds = %7
%13 = load i32, i32* @stdout
%14 = load i32, i32* %3
%15 = sitofp i32 %14 to double
%16 = fdiv double %15, 0x4130000000000000
%17 = fptosi double %16 to i64
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i64 %17)
br label %35
19: ; preds = %7
%20 = load i32, i32* %3
%21 = icmp sgt i32 %20, 1024
br i1 %21, label %22, label %29
22: ; preds = %19
%23 = load i32, i32* @stdout
%24 = load i32, i32* %3
%25 = sitofp i32 %24 to double
%26 = fdiv double %25, 1.024000e+03
%27 = fptosi double %26 to i64
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i64 %27)
br label %34
29: ; preds = %19
%30 = load i32, i32* @stdout
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i64 %32)
br label %34
34: ; preds = %29, %22
br label %35
35: ; preds = %34, %12
%36 = load i32, i32* @stdout
%37 = load i32, i32* %3
%38 = load i32, i32* %2
%39 = sdiv i32 %37, %38
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %35, %1
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [27 x i8] c"\0A -- MEMORY REQUIREMENTS\0A\00"
@.str.1 = [29 x i8] c" Total size : %10Zd Mbytes\00"
@.str.2 = [29 x i8] c" Total size : %10Zd Kbytes\00"
@.str.3 = [29 x i8] c" Total size : %10Zd bytes \00"
@.str.4 = [27 x i8] c" (i.e. %d bytes/point)\0A\00"
define void @primem(i32 %0) {
%2 = tail call i32 (...) @M_memSize()
%3 = icmp eq i32 %2, 0
br i1 %3, label %29, label %4
4: ; preds = %1
%5 = load i32, i32* @stdout
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%7 = icmp sgt i32 %2, 1048576
br i1 %7, label %8, label %14
8: ; preds = %4
%9 = load i32, i32* @stdout
%10 = sitofp i32 %2 to double
%11 = fmul double %10, 0x3EB0000000000000
%12 = fptosi double %11 to i64
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i64 %12)
br label %25
14: ; preds = %4
%15 = icmp sgt i32 %2, 1024
%16 = load i32, i32* @stdout
br i1 %15, label %17, label %22
17: ; preds = %14
%18 = sitofp i32 %2 to double
%19 = fmul double %18, 0x3F50000000000000
%20 = fptosi double %19 to i64
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i64 %20)
br label %25
22: ; preds = %14
%23 = sext i32 %2 to i64
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i64 %23)
br label %25
25: ; preds = %17, %22, %8
%26 = load i32, i32* @stdout
%27 = sdiv i32 %2, %0
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %25, %1
ret void
}