#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 /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, unsigned int, ...);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/, char *, unsigned int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
void readPatternSetsExtract(unsigned int *numOfIDs, unsigned int **IDs) {
  unsigned int numIdsPerPattern, numOfPatterns;
  fscanf(stdin, "##numIdsPerPattern: %9d\n", &numIdsPerPattern);
  fscanf(stdin, "##numOfPatterns : %9d\n", &numOfPatterns);
  *numOfIDs = numIdsPerPattern * numOfPatterns;
  unsigned int *V;
  unsigned int i, value;
  V = (unsigned int *)malloc(sizeof(unsigned int) * (*numOfIDs));
  for (i = 0; i < (*numOfIDs); i++) {
    fscanf(stdin, "%9d\n", &value);
    V[i] = value;
  }
  *IDs = V;
  fprintf(stderr, " !!!! numIdsPerPattern = %9d and numOfPatterns = %9d",
          numIdsPerPattern, numOfPatterns);
  fprintf(stderr, "##numOfIDS to extract: %9d\n", *numOfIDs);
  fflush(stderr);
}


x86 assembly (clang, -O0):
<readPatternSetsExtract>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1030 <fscanf@plt>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <fscanf@plt>
mov    -0x14(%rbp),%ecx
imul   -0x18(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jae    11ee <readPatternSetsExtract+0xae>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
lea    0xe61(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1030 <fscanf@plt>
mov    -0x28(%rbp),%edx
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ab <readPatternSetsExtract+0x6b>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe21(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
lea    0xe39(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readPatternSetsExtract>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x10(%rsp)
mov    %rdi,%r15
mov    0x2e8b(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xe99(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1030 <fscanf@plt>
mov    0x0(%rbp),%edi
lea    0xe9e(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1030 <fscanf@plt>
mov    0x4(%rsp),%edi
imul   0x8(%rsp),%edi
mov    %edi,(%r15)
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
cmpl   $0x0,(%r15)
je     11e2 <readPatternSetsExtract+0xa2>
xor    %r14d,%r14d
lea    0xe7f(%rip),%r12
lea    0xc(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp),%edi
mov    %r12,%rsi
mov    %r13,%rdx
call   1030 <fscanf@plt>
mov    0xc(%rsp),%eax
mov    %eax,(%rbx,%r14,4)
add    $0x1,%r14
mov    (%r15),%eax
cmp    %rax,%r14
jb     11c0 <readPatternSetsExtract+0x80>
mov    0x10(%rsp),%rax
mov    %rbx,(%rax)
mov    0x2de7(%rip),%rbx
mov    (%rbx),%edi
mov    0x8(%rsp),%edx
mov    0x4(%rsp),%ecx
lea    0xe2e(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
mov    (%r15),%edx
lea    0xe50(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
call   1060 <fflush@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [25 x i8] c"##numIdsPerPattern: %9d\0A\00"
@.str.1 = [23 x i8] c"##numOfPatterns : %9d\0A\00"
@.str.2 = [5 x i8] c"%9d\0A\00"
@stderr = global i32 0
@.str.3 = [53 x i8] c" !!!! numIdsPerPattern = %9d and numOfPatterns = %9d\00"
@.str.4 = [28 x i8] c"##numOfIDS to extract: %9d\0A\00"
define void @readPatternSetsExtract(i32* %0, i32** %1) {
%3 = alloca i32*
%4 = alloca i32**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %3
store i32** %1, i32*** %4
%10 = load i32, i32* @stdin
%11 = call i32 @fscanf(i32 %10, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32* %5)
%12 = load i32, i32* @stdin
%13 = call i32 @fscanf(i32 %12, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = mul i32 %14, %15
%17 = load i32*, i32** %3
store i32 %16, i32* %17
%18 = load i32*, i32** %3
%19 = load i32, i32* %18
%20 = zext i32 %19 to i64
%21 = mul i64 4, %20
%22 = trunc i64 %21 to i32
%23 = call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to i32*
store i32* %24, i32** %7
store i32 0, i32* %8
br label %25
25: ; preds = %38, %2
%26 = load i32, i32* %8
%27 = load i32*, i32** %3
%28 = load i32, i32* %27
%29 = icmp ult i32 %26, %28
br i1 %29, label %30, label %41
30: ; preds = %25
%31 = load i32, i32* @stdin
%32 = call i32 @fscanf(i32 %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %9)
%33 = load i32, i32* %9
%34 = load i32*, i32** %7
%35 = load i32, i32* %8
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
store i32 %33, i32* %37
br label %38
38: ; preds = %30
%39 = load i32, i32* %8
%40 = add i32 %39, 1
store i32 %40, i32* %8
br label %25
41: ; preds = %25
%42 = load i32*, i32** %7
%43 = load i32**, i32*** %4
store i32* %42, i32** %43
%44 = load i32, i32* @stderr
%45 = load i32, i32* %5
%46 = load i32, i32* %6
%47 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i32 %45, i32 %46)
%48 = load i32, i32* @stderr
%49 = load i32*, i32** %3
%50 = load i32, i32* %49
%51 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %50)
%52 = load i32, i32* @stderr
%53 = call i32 @fflush(i32 %52)
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [25 x i8] c"##numIdsPerPattern: %9d\0A\00"
@.str.1 = [23 x i8] c"##numOfPatterns : %9d\0A\00"
@.str.2 = [5 x i8] c"%9d\0A\00"
@stderr = global i32 0
@.str.3 = [53 x i8] c" !!!! numIdsPerPattern = %9d and numOfPatterns = %9d\00"
@.str.4 = [28 x i8] c"##numOfIDS to extract: %9d\0A\00"
define void @readPatternSetsExtract(i32* nocapture %0, i32** nocapture writeonly %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = load i32, i32* @stdin
%9 = call i32 @fscanf(i32 %8, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32* %3)
%10 = load i32, i32* @stdin
%11 = call i32 @fscanf(i32 %10, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = mul i32 %13, %12
store i32 %14, i32* %0
%15 = bitcast i32* %5 to i8*
%16 = shl i32 %14, 2
%17 = call i64 @malloc(i32 %16)
%18 = inttoptr i64 %17 to i32*
%19 = load i32, i32* %0
%20 = icmp eq i32 %19, 0
br i1 %20, label %31, label %21
21: ; preds = %2, %21
%22 = phi i64 [ %27, %21 ], [ 0, %2 ]
%23 = load i32, i32* @stdin
%24 = call i32 @fscanf(i32 %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%25 = load i32, i32* %5
%26 = getelementptr inbounds i32, i32* %18, i64 %22
store i32 %25, i32* %26
%27 = add nuw nsw i64 %22, 1
%28 = load i32, i32* %0
%29 = zext i32 %28 to i64
%30 = icmp ult i64 %27, %29
br i1 %30, label %21, label %31
31: ; preds = %21, %2
store i32* %18, i32** %1
%32 = load i32, i32* @stderr
%33 = load i32, i32* %3
%34 = load i32, i32* %4
%35 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i32 %33, i32 %34)
%36 = load i32, i32* @stderr
%37 = load i32, i32* %0
%38 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %37)
%39 = load i32, i32* @stderr
%40 = call i32 @fflush(i32 %39)
ret void
}