#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int omp_get_max_threads();
scalar_t__ ompx_calloc(int);
int /*<<< orphan*/ ompx_free(void **);
int main(int argc, char *argv[]) {
  int n = (argc > 1) ? atoi(argv[1]) : 1 << 20;
  int np = omp_get_max_threads();
  if (np < 2)
    exit(1);
  int **A = (int **)ompx_calloc(n * sizeof(int));
#pragma omp parallel shared(A)
  {}
  ompx_free((void **)A);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1185 <main+0x35>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x24(%rbp)
jmp    1192 <main+0x42>
mov    $0x100000,%eax
mov    %eax,-0x24(%rbp)
jmp    1192 <main+0x42>
mov    -0x24(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1040 <omp_get_max_threads@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x2,-0x18(%rbp)
jge    11b6 <main+0x66>
mov    $0x1,%edi
call   1070 <exit@plt>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <ompx_calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <ompx_free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x400000,%ebx
cmp    $0x2,%edi
jl     1169 <main+0x19>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
shl    $0x2,%ebx
xor    %eax,%eax
call   1040 <omp_get_max_threads@plt>
cmp    $0x1,%eax
jle    1188 <main+0x38>
mov    %ebx,%edi
call   1050 <ompx_calloc@plt>
mov    %rax,%rdi
call   1030 <ompx_free@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
br label %17
16: ; preds = %2
br label %17
17: ; preds = %16, %11
%18 = phi i32 [ %15, %11 ], [ 1048576, %16 ]
store i32 %18, i32* %6
%19 = call i32 (...) @omp_get_max_threads()
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = icmp slt i32 %20, 2
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %17
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = mul i64 %26, 4
%28 = trunc i64 %27 to i32
%29 = call i64 @ompx_calloc(i32 %28)
%30 = inttoptr i64 %29 to i32**
store i32** %30, i32*** %8
%31 = load i32**, i32*** %8
%32 = bitcast i32** %31 to i8**
%33 = call i32 @ompx_free(i8** %32)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = shl i32 %7, 2
br label %9
9: ; preds = %2, %4
%10 = phi i32 [ %8, %4 ], [ 4194304, %2 ]
%11 = tail call i32 (...) @omp_get_max_threads()
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %9
%16 = tail call i64 @ompx_calloc(i32 %10)
%17 = inttoptr i64 %16 to i8**
%18 = tail call i32 @ompx_free(i8** %17)
ret i32 0
}