#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 errio;
  errio = fscanf(stdin, "##numIdsPerPattern: %9d\n", &numIdsPerPattern);
  errio = 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++) {
    int errio = fscanf(stdin, "%9d\n", &value);
    V[i] = value;
  }
  *IDs = V;
}


x86 assembly (clang, -O0):
<readPatternSetsExtract>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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,-0x34(%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    $0x40,%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
%11 = alloca i32
store i32* %0, i32** %3
store i32** %1, i32*** %4
%12 = load i32, i32* @stdin
%13 = call i32 @fscanf(i32 %12, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32* %5)
store i32 %13, i32* %7
%14 = load i32, i32* @stdin
%15 = call i32 @fscanf(i32 %14, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32* %6)
store i32 %15, i32* %7
%16 = load i32, i32* %5
%17 = load i32, i32* %6
%18 = mul i32 %16, %17
%19 = load i32*, i32** %3
store i32 %18, i32* %19
%20 = load i32*, i32** %3
%21 = load i32, i32* %20
%22 = zext i32 %21 to i64
%23 = mul i64 4, %22
%24 = trunc i64 %23 to i32
%25 = call i64 @malloc(i32 %24)
%26 = inttoptr i64 %25 to i32*
store i32* %26, i32** %8
store i32 0, i32* %9
br label %27
27: ; preds = %40, %2
%28 = load i32, i32* %9
%29 = load i32*, i32** %3
%30 = load i32, i32* %29
%31 = icmp ult i32 %28, %30
br i1 %31, label %32, label %43
32: ; preds = %27
%33 = load i32, i32* @stdin
%34 = call i32 @fscanf(i32 %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %10)
store i32 %34, i32* %11
%35 = load i32, i32* %10
%36 = load i32*, i32** %8
%37 = load i32, i32* %9
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
store i32 %35, i32* %39
br label %40
40: ; preds = %32
%41 = load i32, i32* %9
%42 = add i32 %41, 1
store i32 %42, i32* %9
br label %27
43: ; preds = %27
%44 = load i32*, i32** %8
%45 = load i32**, i32*** %4
store i32* %44, i32** %45
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
}