#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 */
size_t log(size_t);
int const pow(size_t, double);
int round(int const);
int security_level(size_t prime_size) {
  int level;
  const int COMPL_COEFF = 2.27;
  switch (prime_size) {
  case 512:
    level = 80;
    break;
  case 1024:
    level = 112;
    break;
  case 1536:
    level = 128;
    break;
  default:
    level = round(COMPL_COEFF * pow(prime_size / 2.0, 1.0 / 3.0) *
                  pow(log(prime_size / 2.0), 2.0 / 3.0));
    break;
  }
  return level;
}


x86 assembly (clang, -O0):
<security_level>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x2,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
sub    $0x200,%rax
je     1186 <security_level+0x56>
jmp    115c <security_level+0x2c>
mov    -0x18(%rbp),%rax
sub    $0x400,%rax
je     1192 <security_level+0x62>
jmp    1171 <security_level+0x41>
mov    -0x18(%rbp),%rax
sub    $0x600,%rax
je     119e <security_level+0x6e>
jmp    11aa <security_level+0x7a>
movl   $0x50,-0xc(%rbp)
jmp    1296 <security_level+0x166>
movl   $0x70,-0xc(%rbp)
jmp    1296 <security_level+0x166>
movl   $0x80,-0xc(%rbp)
jmp    1296 <security_level+0x166>
movq   -0x8(%rbp),%xmm0
movaps 0xe6a(%rip),%xmm1
movaps %xmm1,-0x50(%rbp)
punpckldq %xmm1,%xmm0
movapd 0xe6a(%rip),%xmm1
movaps %xmm1,-0x40(%rbp)
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe27(%rip),%xmm1
movsd  %xmm1,-0x30(%rbp)
divsd  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
mov    %rdi,%rcx
sar    $0x3f,%rcx
movsd  0xe0f(%rip),%xmm1
movsd  %xmm1,-0x28(%rbp)
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
and    %rcx,%rax
or     %rax,%rdi
movsd  0xdfb(%rip),%xmm0
call   1040 <pow@plt>
movaps -0x50(%rbp),%xmm4
movaps -0x40(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
add    %eax,%eax
mov    %eax,-0x1c(%rbp)
movq   -0x8(%rbp),%xmm0
punpckldq %xmm4,%xmm0
subpd  %xmm3,%xmm0
movaps %xmm0,%xmm3
unpckhpd %xmm0,%xmm0
addsd  %xmm3,%xmm0
divsd  %xmm2,%xmm0
movaps %xmm0,%xmm2
cvttsd2si %xmm2,%rdi
mov    %rdi,%rcx
sar    $0x3f,%rcx
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
and    %rcx,%rax
or     %rax,%rdi
call   1030 <log@plt>
mov    %rax,%rdi
movsd  0xd7d(%rip),%xmm0
call   1040 <pow@plt>
mov    -0x1c(%rbp),%edi
imul   %eax,%edi
call   1050 <round@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<security_level>:
cmp    $0x200,%rdi
je     1151 <security_level+0x21>
cmp    $0x600,%rdi
je     1157 <security_level+0x27>
cmp    $0x400,%rdi
jne    115d <security_level+0x2d>
mov    $0x70,%eax
ret
mov    $0x50,%eax
ret
mov    $0x80,%eax
ret
push   %rbp
push   %rbx
push   %rax
movq   %rdi,%xmm0
punpckldq 0xe93(%rip),%xmm0
subpd  0xe9b(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
mulsd  0xe97(%rip),%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,%rcx
sar    $0x3f,%rcx
subsd  0xe8b(%rip),%xmm1
cvttsd2si %xmm1,%rbx
and    %rcx,%rbx
or     %rax,%rbx
movsd  0xe80(%rip),%xmm0
mov    %rbx,%rdi
call   1040 <pow@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <log@plt>
movsd  0xe6e(%rip),%xmm0
mov    %rax,%rdi
call   1040 <pow@plt>
imul   %eax,%ebp
add    %ebp,%ebp
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <round@plt>

LLVM IR (-O0):
define i32 @security_level(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
store i64 %0, i64* %2
store i32 2, i32* %4
%5 = load i64, i64* %2
switch i64 %5, label %9 [
i64 512, label %6
i64 1024, label %7
i64 1536, label %8
]
6: ; preds = %1
store i32 80, i32* %3
br label %24
7: ; preds = %1
store i32 112, i32* %3
br label %24
8: ; preds = %1
store i32 128, i32* %3
br label %24
9: ; preds = %1
%10 = load i64, i64* %2
%11 = uitofp i64 %10 to double
%12 = fdiv double %11, 2.000000e+00
%13 = fptoui double %12 to i64
%14 = call i32 @pow(i64 %13, double 0x3FD5555555555555)
%15 = mul nsw i32 2, %14
%16 = load i64, i64* %2
%17 = uitofp i64 %16 to double
%18 = fdiv double %17, 2.000000e+00
%19 = fptoui double %18 to i64
%20 = call i64 @log(i64 %19)
%21 = call i32 @pow(i64 %20, double 0x3FE5555555555555)
%22 = mul nsw i32 %15, %21
%23 = call i32 @round(i32 %22)
store i32 %23, i32* %3
br label %24
24: ; preds = %9, %8, %7, %6
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
define i32 @security_level(i64 %0) {
switch i64 %0, label %4 [
i64 512, label %14
i64 1024, label %2
i64 1536, label %3
]
2: ; preds = %1
br label %14
3: ; preds = %1
br label %14
4: ; preds = %1
%5 = uitofp i64 %0 to double
%6 = fmul double %5, 5.000000e-01
%7 = fptoui double %6 to i64
%8 = tail call i32 @pow(i64 %7, double 0x3FD5555555555555)
%9 = shl nsw i32 %8, 1
%10 = tail call i64 @log(i64 %7)
%11 = tail call i32 @pow(i64 %10, double 0x3FE5555555555555)
%12 = mul nsw i32 %9, %11
%13 = tail call i32 @round(i32 %12)
br label %14
14: ; preds = %1, %4, %3, %2
%15 = phi i32 [ %13, %4 ], [ 128, %3 ], [ 112, %2 ], [ 80, %1 ]
ret i32 %15
}