#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 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;
  int rfs;
  rfs = fscanf(stdin, "##numIdsPerPattern: %9d\n", &numIdsPerPattern);
  rfs = 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++) {
    rfs = 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    %eax,-0x1c(%rbp)
mov    0x2e95(%rip),%rax
mov    (%rax),%edi
lea    0xebd(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <fscanf@plt>
mov    %eax,-0x1c(%rbp)
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,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jae    11d7 <readPatternSetsExtract+0xb7>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1030 <fscanf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x30(%rbp),%edx
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1191 <readPatternSetsExtract+0x71>
mov    -0x28(%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
%10 = alloca i32
store i32* %0, i32** %3
store i32** %1, i32*** %4
%11 = load i32, i32* @stdin
%12 = call i32 @fscanf(i32 %11, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32* %5)
store i32 %12, i32* %7
%13 = load i32, i32* @stdin
%14 = call i32 @fscanf(i32 %13, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32* %6)
store i32 %14, i32* %7
%15 = load i32, i32* %5
%16 = load i32, i32* %6
%17 = mul i32 %15, %16
%18 = load i32*, i32** %3
store i32 %17, i32* %18
%19 = load i32*, i32** %3
%20 = load i32, i32* %19
%21 = zext i32 %20 to i64
%22 = mul i64 4, %21
%23 = trunc i64 %22 to i32
%24 = call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to i32*
store i32* %25, i32** %8
store i32 0, i32* %9
br label %26
26: ; preds = %39, %2
%27 = load i32, i32* %9
%28 = load i32*, i32** %3
%29 = load i32, i32* %28
%30 = icmp ult i32 %27, %29
br i1 %30, label %31, label %42
31: ; preds = %26
%32 = load i32, i32* @stdin
%33 = call i32 @fscanf(i32 %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %10)
store i32 %33, i32* %7
%34 = load i32, i32* %10
%35 = load i32*, i32** %8
%36 = load i32, i32* %9
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
store i32 %34, i32* %38
br label %39
39: ; preds = %31
%40 = load i32, i32* %9
%41 = add i32 %40, 1
store i32 %41, i32* %9
br label %26
42: ; preds = %26
%43 = load i32*, i32** %8
%44 = load i32**, i32*** %4
store i32* %43, i32** %44
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
}