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


x86 assembly (clang, -O0):
<readPatternSetsIntersect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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    %eax,-0x1c(%rbp)
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xeb5(%rip),%rsi
call   1030 <fscanf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jae    121d <readPatternSetsIntersect+0xfd>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jae    120a <readPatternSetsIntersect+0xea>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
lea    0xe4f(%rip),%rsi
lea    -0x34(%rbp),%rdx
call   1030 <fscanf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x34(%rbp),%edx
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x30(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11bd <readPatternSetsIntersect+0x9d>
jmp    120f <readPatternSetsIntersect+0xef>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1188 <readPatternSetsIntersect+0x68>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
add    $0x40,%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
%11 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32*** %2, i32**** %6
%12 = load i32, i32* @stdin
%13 = load i32*, i32** %4
%14 = call i32 @fscanf(i32 %12, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32* %13)
store i32 %14, i32* %7
%15 = load i32, i32* @stdin
%16 = load i32*, i32** %5
%17 = call i32 @fscanf(i32 %15, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32* %16)
store i32 %17, i32* %7
%18 = load i32*, i32** %5
%19 = load i32, i32* %18
%20 = zext i32 %19 to i64
%21 = mul i64 8, %20
%22 = trunc i64 %21 to i32
%23 = call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to i32**
store i32** %24, i32*** %8
store i32 0, i32* %9
br label %25
25: ; preds = %63, %3
%26 = load i32, i32* %9
%27 = load i32*, i32** %5
%28 = load i32, i32* %27
%29 = icmp ult i32 %26, %28
br i1 %29, label %30, label %66
30: ; preds = %25
%31 = load i32*, i32** %4
%32 = load i32, i32* %31
%33 = zext i32 %32 to i64
%34 = mul i64 4, %33
%35 = trunc i64 %34 to i32
%36 = call i64 @malloc(i32 %35)
%37 = inttoptr i64 %36 to i32*
%38 = load i32**, i32*** %8
%39 = load i32, i32* %9
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds i32*, i32** %38, i64 %40
store i32* %37, i32** %41
store i32 0, i32* %10
br label %42
42: ; preds = %59, %30
%43 = load i32, i32* %10
%44 = load i32*, i32** %4
%45 = load i32, i32* %44
%46 = icmp ult i32 %43, %45
br i1 %46, label %47, label %62
47: ; preds = %42
%48 = load i32, i32* @stdin
%49 = call i32 @fscanf(i32 %48, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %11)
store i32 %49, i32* %7
%50 = load i32, i32* %11
%51 = load i32**, i32*** %8
%52 = load i32, i32* %9
%53 = zext i32 %52 to i64
%54 = getelementptr inbounds i32*, i32** %51, i64 %53
%55 = load i32*, i32** %54
%56 = load i32, i32* %10
%57 = zext i32 %56 to i64
%58 = getelementptr inbounds i32, i32* %55, i64 %57
store i32 %50, i32* %58
br label %59
59: ; preds = %47
%60 = load i32, i32* %10
%61 = add i32 %60, 1
store i32 %61, i32* %10
br label %42
62: ; preds = %42
br label %63
63: ; preds = %62
%64 = load i32, i32* %9
%65 = add i32 %64, 1
store i32 %65, i32* %9
br label %25
66: ; preds = %25
%67 = load i32**, i32*** %8
%68 = load i32***, i32**** %6
store i32** %67, i32*** %68
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
}