#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*/ fscanf(int /*<<< orphan*/, char *, unsigned int *);
scalar_t__ malloc(int);
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;
}


x86 assembly (clang, -O0):
<readPatternSetsExtract>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2eb1(%rip),%rax
mov    (%rax),%edi
lea    0xec0(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1030 <fscanf@plt>
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
lea    0xec0(%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   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jae    11ce <readPatternSetsExtract+0xae>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
lea    0xe81(%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    118b <readPatternSetsExtract+0x6b>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
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    0x2eab(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xeb9(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1030 <fscanf@plt>
mov    0x0(%rbp),%edi
lea    0xebe(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1030 <fscanf@plt>
mov    0x8(%rsp),%edi
imul   0xc(%rsp),%edi
mov    %edi,(%r15)
shl    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
cmpl   $0x0,(%r15)
je     11c2 <readPatternSetsExtract+0xa2>
xor    %r14d,%r14d
lea    0xe9f(%rip),%r12
lea    0x4(%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    0x4(%rsp),%eax
mov    %eax,(%rbx,%r14,4)
add    $0x1,%r14
mov    (%r15),%eax
cmp    %rax,%r14
jb     11a0 <readPatternSetsExtract+0x80>
mov    0x10(%rsp),%rax
mov    %rbx,(%rax)
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"
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
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"
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
ret void
}