#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 readPatternSetsIntersect(unsigned int *numIdsPerPattern,
                              unsigned int *numOfPatterns,
                              unsigned int ***patternSets) {
  fscanf(stdin, "##numIdsPerPattern: %9d\n", numIdsPerPattern);
  fscanf(stdin, "##numOfPatterns : %9d\n", numOfPatterns);
  unsigned int **V;
  unsigned int i, j, value;
  V = (unsigned int **)malloc(sizeof(unsigned int *) * (*numOfPatterns));
  for (i = 0; i < *numOfPatterns; i++) {
    V[i] = (unsigned int *)malloc(sizeof(unsigned int) * (*numIdsPerPattern));
    for (j = 0; j < (*numIdsPerPattern); j++) {
      fscanf(stdin, "%9d\n", &value);
      V[i][j] = value;
    }
  }
  *patternSets = V;
}


x86 assembly (clang, -O0):
<readPatternSetsIntersect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2ead(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xeb8(%rip),%rsi
call   1030 <fscanf@plt>
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xeb8(%rip),%rsi
call   1030 <fscanf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jae    1214 <readPatternSetsIntersect+0xf4>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jae    1201 <readPatternSetsIntersect+0xe1>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
lea    0xe55(%rip),%rsi
lea    -0x2c(%rbp),%rdx
call   1030 <fscanf@plt>
mov    -0x2c(%rbp),%edx
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x28(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11b7 <readPatternSetsIntersect+0x97>
jmp    1206 <readPatternSetsIntersect+0xe6>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1182 <readPatternSetsIntersect+0x62>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readPatternSetsIntersect>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,0x18(%rsp)
mov    %rsi,%rbp
mov    %rdi,%r13
mov    0x2ea8(%rip),%r14
mov    (%r14),%edi
lea    0xeb6(%rip),%rsi
mov    %r13,%rdx
call   1030 <fscanf@plt>
mov    (%r14),%edi
lea    0xebd(%rip),%rsi
mov    %rbp,%rdx
call   1030 <fscanf@plt>
mov    0x0(%rbp),%edi
shl    $0x3,%edi
call   1040 <malloc@plt>
mov    %rax,%r15
mov    %rbp,0x20(%rsp)
cmpl   $0x0,0x0(%rbp)
je     1218 <readPatternSetsIntersect+0xf8>
mov    0x0(%r13),%edi
xor    %ebx,%ebx
lea    0xe9d(%rip),%rbp
lea    0xc(%rsp),%r12
jmp    11b0 <readPatternSetsIntersect+0x90>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
mov    0x20(%rsp),%rax
mov    (%rax),%eax
cmp    %rax,%rbx
jae    1218 <readPatternSetsIntersect+0xf8>
shl    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,(%r15,%rbx,8)
cmpl   $0x0,0x0(%r13)
mov    $0x0,%edi
je     11a0 <readPatternSetsIntersect+0x80>
mov    %rbx,0x10(%rsp)
mov    %r13,%rbx
mov    %r14,%r13
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
mov    0x0(%r13),%edi
mov    %rbp,%rsi
mov    %r12,%rdx
call   1030 <fscanf@plt>
mov    0xc(%rsp),%eax
mov    0x10(%rsp),%rcx
mov    (%r15,%rcx,8),%rcx
mov    %eax,(%rcx,%r14,4)
add    $0x1,%r14
mov    (%rbx),%edi
cmp    %rdi,%r14
jb     11e0 <readPatternSetsIntersect+0xc0>
mov    %r13,%r14
mov    %rbx,%r13
mov    0x10(%rsp),%rbx
jmp    11a0 <readPatternSetsIntersect+0x80>
mov    0x18(%rsp),%rax
mov    %r15,(%rax)
add    $0x28,%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 @readPatternSetsIntersect(i32* %0, i32* %1, i32*** %2) {
%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** %4
store i32* %1, i32** %5
store i32*** %2, i32**** %6
%11 = load i32, i32* @stdin
%12 = load i32*, i32** %4
%13 = call i32 @fscanf(i32 %11, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32* %12)
%14 = load i32, i32* @stdin
%15 = load i32*, i32** %5
%16 = call i32 @fscanf(i32 %14, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32* %15)
%17 = load i32*, i32** %5
%18 = load i32, i32* %17
%19 = zext i32 %18 to i64
%20 = mul i64 8, %19
%21 = trunc i64 %20 to i32
%22 = call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to i32**
store i32** %23, i32*** %7
store i32 0, i32* %8
br label %24
24: ; preds = %62, %3
%25 = load i32, i32* %8
%26 = load i32*, i32** %5
%27 = load i32, i32* %26
%28 = icmp ult i32 %25, %27
br i1 %28, label %29, label %65
29: ; preds = %24
%30 = load i32*, i32** %4
%31 = load i32, i32* %30
%32 = zext i32 %31 to i64
%33 = mul i64 4, %32
%34 = trunc i64 %33 to i32
%35 = call i64 @malloc(i32 %34)
%36 = inttoptr i64 %35 to i32*
%37 = load i32**, i32*** %7
%38 = load i32, i32* %8
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds i32*, i32** %37, i64 %39
store i32* %36, i32** %40
store i32 0, i32* %9
br label %41
41: ; preds = %58, %29
%42 = load i32, i32* %9
%43 = load i32*, i32** %4
%44 = load i32, i32* %43
%45 = icmp ult i32 %42, %44
br i1 %45, label %46, label %61
46: ; preds = %41
%47 = load i32, i32* @stdin
%48 = call i32 @fscanf(i32 %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %10)
%49 = load i32, i32* %10
%50 = load i32**, i32*** %7
%51 = load i32, i32* %8
%52 = zext i32 %51 to i64
%53 = getelementptr inbounds i32*, i32** %50, i64 %52
%54 = load i32*, i32** %53
%55 = load i32, i32* %9
%56 = zext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %54, i64 %56
store i32 %49, i32* %57
br label %58
58: ; preds = %46
%59 = load i32, i32* %9
%60 = add i32 %59, 1
store i32 %60, i32* %9
br label %41
61: ; preds = %41
br label %62
62: ; preds = %61
%63 = load i32, i32* %8
%64 = add i32 %63, 1
store i32 %64, i32* %8
br label %24
65: ; preds = %24
%66 = load i32**, i32*** %7
%67 = load i32***, i32**** %6
store i32** %66, i32*** %67
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 @readPatternSetsIntersect(i32* %0, i32* %1, i32*** nocapture writeonly %2) {
%4 = alloca i32
%5 = load i32, i32* @stdin
%6 = tail call i32 @fscanf(i32 %5, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32* %0)
%7 = load i32, i32* @stdin
%8 = tail call i32 @fscanf(i32 %7, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = bitcast i32* %4 to i8*
%10 = load i32, i32* %1
%11 = shl i32 %10, 3
%12 = tail call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i32**
%14 = load i32, i32* %1
%15 = icmp eq i32 %14, 0
br i1 %15, label %44, label %16
16: ; preds = %3
%17 = load i32, i32* %0
br label %18
18: ; preds = %16, %38
%19 = phi i32 [ %17, %16 ], [ %39, %38 ]
%20 = phi i64 [ 0, %16 ], [ %40, %38 ]
%21 = shl i32 %19, 2
%22 = call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to i32*
%24 = getelementptr inbounds i32*, i32** %13, i64 %20
store i32* %23, i32** %24
%25 = load i32, i32* %0
%26 = icmp eq i32 %25, 0
br i1 %26, label %38, label %27
27: ; preds = %18, %27
%28 = phi i64 [ %34, %27 ], [ 0, %18 ]
%29 = load i32, i32* @stdin
%30 = call i32 @fscanf(i32 %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%31 = load i32, i32* %4
%32 = load i32*, i32** %24
%33 = getelementptr inbounds i32, i32* %32, i64 %28
store i32 %31, i32* %33
%34 = add nuw nsw i64 %28, 1
%35 = load i32, i32* %0
%36 = zext i32 %35 to i64
%37 = icmp ult i64 %34, %36
br i1 %37, label %27, label %38
38: ; preds = %27, %18
%39 = phi i32 [ 0, %18 ], [ %35, %27 ]
%40 = add nuw nsw i64 %20, 1
%41 = load i32, i32* %1
%42 = zext i32 %41 to i64
%43 = icmp ult i64 %40, %42
br i1 %43, label %18, label %44
44: ; preds = %38, %3
store i32** %13, i32*** %2
ret void
}