#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 Log2(int);
double upcrt_s2p_speed(double profile[10][10], int NMSG, int V) {
  if (V > 1 << 10)
    return 2.0;
  if (NMSG > 1 << 10)
    NMSG = 1 << 10;
  return profile[Log2(V)][Log2(NMSG) - 1];
}


x86 assembly (clang, -O0):
<upcrt_s2p_speed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
cmpl   $0x400,-0x18(%rbp)
jle    1141 <upcrt_s2p_speed+0x31>
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1197 <upcrt_s2p_speed+0x87>
cmpl   $0x400,-0x14(%rbp)
jle    1155 <upcrt_s2p_speed+0x45>
movl   $0x400,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <Log2@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
imul   $0x50,%rcx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <Log2@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<upcrt_s2p_speed>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x400,%edx
jle    1126 <upcrt_s2p_speed+0x16>
movsd  0xedc(%rip),%xmm0
jmp    115b <upcrt_s2p_speed+0x4b>
mov    %rdi,%rbx
cmp    $0x400,%esi
mov    $0x400,%ebp
cmovl  %esi,%ebp
mov    %edx,%edi
call   1030 <Log2@plt>
movslq %eax,%r14
mov    %ebp,%edi
call   1030 <Log2@plt>
cltq
lea    (%r14,%r14,4),%rcx
shl    $0x4,%rcx
add    %rcx,%rbx
movsd  -0x8(%rbx,%rax,8),%xmm0
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @upcrt_s2p_speed([10 x double]* %0, i32 %1, i32 %2) {
%4 = alloca double
%5 = alloca [10 x double]*
%6 = alloca i32
%7 = alloca i32
store [10 x double]* %0, [10 x double]** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i32, i32* %7
%9 = icmp sgt i32 %8, 1024
br i1 %9, label %10, label %11
10: ; preds = %3
store double 2.000000e+00, double* %4
br label %27
11: ; preds = %3
%12 = load i32, i32* %6
%13 = icmp sgt i32 %12, 1024
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 1024, i32* %6
br label %15
15: ; preds = %14, %11
%16 = load [10 x double]*, [10 x double]** %5
%17 = load i32, i32* %7
%18 = call i32 @Log2(i32 %17)
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [10 x double], [10 x double]* %16, i64 %19
%21 = load i32, i32* %6
%22 = call i32 @Log2(i32 %21)
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [10 x double], [10 x double]* %20, i64 0, i64 %24
%26 = load double, double* %25
store double %26, double* %4
br label %27
27: ; preds = %15, %10
%28 = load double, double* %4
ret double %28
}

LLVM IR (-O2):
define double @upcrt_s2p_speed([10 x double]* nocapture %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %2, 1024
br i1 %4, label %15, label %5
5: ; preds = %3
%6 = icmp slt i32 %1, 1024
%7 = select i1 %6, i32 %1, i32 1024
%8 = tail call i32 @Log2(i32 %2)
%9 = sext i32 %8 to i64
%10 = tail call i32 @Log2(i32 %7)
%11 = add nsw i32 %10, -1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [10 x double], [10 x double]* %0, i64 %9, i64 %12
%14 = load double, double* %13
br label %15
15: ; preds = %3, %5
%16 = phi double [ %14, %5 ], [ 2.000000e+00, %3 ]
ret double %16
}