#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 */
typedef int /*<<< orphan*/ ****uint8_t;

/* Variables and functions */
int /*<<< orphan*/ free(int /*<<< orphan*/ ******);
scalar_t__ malloc(int);
double omp_get_wtime();
int sqrt(int);
double sliced_dtoh() {
  extern unsigned int datasize;
  double t1_start = 0;
  double t1_end = 0;
  int i = 0;
  int sqrtn = 0;
  uint8_t **a = NULL;
  uint8_t *aptr = NULL;
  unsigned int n = (unsigned int)(datasize / sizeof(uint8_t));
  sqrtn = sqrt((int)n);
  a = (uint8_t **)malloc(sqrtn * sizeof(uint8_t *));
  if (a == NULL) {
    return (-10000);
  }
  for (i = 0; i < sqrtn; i++) {
    a[i] = (uint8_t *)malloc(sqrtn * sizeof(uint8_t));
    if (a[i] == NULL) {
      return (-10000);
    }
  }
  aptr = a[1];
  t1_start = omp_get_wtime();
#pragma acc data copyout(aptr [0:sqrtn])
  {
    if (n == 0) {
      a[0]++;
    }
  }
  t1_end = omp_get_wtime();
  for (i = 0; i < sqrtn; i++) {
    free(a[i]);
  }
  free(a);
  return (t1_end - t1_start);
}


x86 assembly (clang, -O0):
<sliced_dtoh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    0x2e6b(%rip),%rax
mov    (%rax),%eax
shr    $0x3,%rax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
call   1060 <sqrt@plt>
mov    %eax,-0x20(%rbp)
movslq -0x20(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11c1 <sliced_dtoh+0x81>
movsd  0xe49(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12b0 <sliced_dtoh+0x170>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    122a <sliced_dtoh+0xea>
movslq -0x20(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    1217 <sliced_dtoh+0xd7>
movsd  0xdf3(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12b0 <sliced_dtoh+0x170>
jmp    121c <sliced_dtoh+0xdc>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c8 <sliced_dtoh+0x88>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1040 <omp_get_wtime@plt>
movsd  %xmm0,-0x10(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    125a <sliced_dtoh+0x11a>
mov    -0x28(%rbp),%rax
mov    (%rax),%rcx
add    $0x8,%rcx
mov    %rcx,(%rax)
mov    $0x0,%al
call   1040 <omp_get_wtime@plt>
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1298 <sliced_dtoh+0x158>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    126d <sliced_dtoh+0x12d>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sliced_dtoh>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2e93(%rip),%rax
mov    (%rax),%r12d
mov    %r12d,%edi
shr    $0x3,%edi
call   1060 <sqrt@plt>
mov    %eax,%r14d
lea    0x0(,%r14,8),%r15d
mov    %r15d,%edi
call   1050 <malloc@plt>
movsd  0xe82(%rip),%xmm0
test   %rax,%rax
je     1220 <sliced_dtoh+0xe0>
mov    %rax,%rbx
mov    %r14d,%r13d
test   %r14d,%r14d
jle    11ba <sliced_dtoh+0x7a>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15d,%edi
call   1050 <malloc@plt>
mov    %rax,(%rbx,%rbp,8)
test   %rax,%rax
je     1218 <sliced_dtoh+0xd8>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    11a0 <sliced_dtoh+0x60>
xor    %eax,%eax
call   1040 <omp_get_wtime@plt>
movsd  %xmm0,0x8(%rsp)
cmp    $0x7,%r12d
ja     11d1 <sliced_dtoh+0x91>
addq   $0x8,(%rbx)
xor    %eax,%eax
call   1040 <omp_get_wtime@plt>
movsd  %xmm0,0x10(%rsp)
test   %r14d,%r14d
jle    1202 <sliced_dtoh+0xc2>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rbx,%rbp,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    11f0 <sliced_dtoh+0xb0>
mov    %rbx,%rdi
call   1030 <free@plt>
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
jmp    1220 <sliced_dtoh+0xe0>
movsd  0xde0(%rip),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@datasize = external global i32
define double @sliced_dtoh() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32******
%7 = alloca i32*****
%8 = alloca i32
store double 0.000000e+00, double* %2
store double 0.000000e+00, double* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32****** null, i32******* %6
store i32***** null, i32****** %7
%9 = load i32, i32* @datasize
%10 = zext i32 %9 to i64
%11 = udiv i64 %10, 8
%12 = trunc i64 %11 to i32
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = call i32 @sqrt(i32 %13)
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = mul i64 %16, 8
%18 = trunc i64 %17 to i32
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i32******
store i32****** %20, i32******* %6
%21 = load i32******, i32******* %6
%22 = icmp eq i32****** %21, null
br i1 %22, label %23, label %24
23: ; preds = %0
store double -1.000000e+04, double* %1
br label %86
24: ; preds = %0
store i32 0, i32* %4
br label %25
25: ; preds = %48, %24
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %51
29: ; preds = %25
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = mul i64 %31, 8
%33 = trunc i64 %32 to i32
%34 = call i64 @malloc(i32 %33)
%35 = inttoptr i64 %34 to i32*****
%36 = load i32******, i32******* %6
%37 = load i32, i32* %4
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32*****, i32****** %36, i64 %38
store i32***** %35, i32****** %39
%40 = load i32******, i32******* %6
%41 = load i32, i32* %4
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32*****, i32****** %40, i64 %42
%44 = load i32*****, i32****** %43
%45 = icmp eq i32***** %44, null
br i1 %45, label %46, label %47
46: ; preds = %29
store double -1.000000e+04, double* %1
br label %86
47: ; preds = %29
br label %48
48: ; preds = %47
%49 = load i32, i32* %4
%50 = add nsw i32 %49, 1
store i32 %50, i32* %4
br label %25
51: ; preds = %25
%52 = load i32******, i32******* %6
%53 = getelementptr inbounds i32*****, i32****** %52, i64 1
%54 = load i32*****, i32****** %53
store i32***** %54, i32****** %7
%55 = call double (...) @omp_get_wtime()
store double %55, double* %2
%56 = load i32, i32* %8
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %63
58: ; preds = %51
%59 = load i32******, i32******* %6
%60 = getelementptr inbounds i32*****, i32****** %59, i64 0
%61 = load i32*****, i32****** %60
%62 = getelementptr inbounds i32****, i32***** %61, i32 1
store i32***** %62, i32****** %60
br label %63
63: ; preds = %58, %51
%64 = call double (...) @omp_get_wtime()
store double %64, double* %3
store i32 0, i32* %4
br label %65
65: ; preds = %77, %63
%66 = load i32, i32* %4
%67 = load i32, i32* %5
%68 = icmp slt i32 %66, %67
br i1 %68, label %69, label %80
69: ; preds = %65
%70 = load i32******, i32******* %6
%71 = load i32, i32* %4
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i32*****, i32****** %70, i64 %72
%74 = load i32*****, i32****** %73
%75 = bitcast i32***** %74 to i32******
%76 = call i32 @free(i32****** %75)
br label %77
77: ; preds = %69
%78 = load i32, i32* %4
%79 = add nsw i32 %78, 1
store i32 %79, i32* %4
br label %65
80: ; preds = %65
%81 = load i32******, i32******* %6
%82 = call i32 @free(i32****** %81)
%83 = load double, double* %3
%84 = load double, double* %2
%85 = fsub double %83, %84
store double %85, double* %1
br label %86
86: ; preds = %80, %46, %23
%87 = load double, double* %1
ret double %87
}

LLVM IR (-O2):
@datasize = external global i32
define double @sliced_dtoh() {
%1 = load i32, i32* @datasize
%2 = lshr i32 %1, 3
%3 = tail call i32 @sqrt(i32 %2)
%4 = shl i32 %3, 3
%5 = tail call i64 @malloc(i32 %4)
%6 = inttoptr i64 %5 to i32******
%7 = icmp eq i64 %5, 0
br i1 %7, label %42, label %8
8: ; preds = %0
%9 = icmp sgt i32 %3, 0
br i1 %9, label %10, label %21
10: ; preds = %8
%11 = zext i32 %3 to i64
br label %14
12: ; preds = %14
%13 = icmp eq i64 %20, %11
br i1 %13, label %21, label %14
14: ; preds = %10, %12
%15 = phi i64 [ 0, %10 ], [ %20, %12 ]
%16 = tail call i64 @malloc(i32 %4)
%17 = inttoptr i64 %16 to i32*****
%18 = getelementptr inbounds i32*****, i32****** %6, i64 %15
store i32***** %17, i32****** %18
%19 = icmp eq i64 %16, 0
%20 = add nuw nsw i64 %15, 1
br i1 %19, label %42, label %12
21: ; preds = %12, %8
%22 = tail call double (...) @omp_get_wtime()
%23 = icmp ult i32 %1, 8
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i32*****, i32****** %6
%26 = getelementptr inbounds i32****, i32***** %25, i64 1
store i32***** %26, i32****** %6
br label %27
27: ; preds = %24, %21
%28 = tail call double (...) @omp_get_wtime()
br i1 %9, label %29, label %39
29: ; preds = %27
%30 = zext i32 %3 to i64
br label %31
31: ; preds = %29, %31
%32 = phi i64 [ 0, %29 ], [ %37, %31 ]
%33 = getelementptr inbounds i32*****, i32****** %6, i64 %32
%34 = bitcast i32****** %33 to i32*******
%35 = load i32******, i32******* %34
%36 = tail call i32 @free(i32****** %35)
%37 = add nuw nsw i64 %32, 1
%38 = icmp eq i64 %37, %30
br i1 %38, label %39, label %31
39: ; preds = %31, %27
%40 = tail call i32 @free(i32****** %6)
%41 = fsub double %28, %22
br label %42
42: ; preds = %14, %0, %39
%43 = phi double [ %41, %39 ], [ -1.000000e+04, %0 ], [ -1.000000e+04, %14 ]
ret double %43
}