#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*/ fprintf(int /*<<< orphan*/, char *, unsigned int,
                           unsigned int);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/, char *, unsigned int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ stderr;
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);
  fprintf(stderr, " numIdsPerPattern = %9d and numOfPatterns = %9d",
          *numIdsPerPattern, *numOfPatterns);
  unsigned int **V;
  unsigned int i, j, value;
  V = (unsigned int **)malloc(sizeof(unsigned int **) * 1);
  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    0x2e9d(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xea8(%rip),%rsi
call   1030 <fscanf@plt>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xea8(%rip),%rsi
call   1030 <fscanf@plt>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
lea    0xe9e(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jae    123e <readPatternSetsIntersect+0x10e>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <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    122b <readPatternSetsIntersect+0xfb>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
lea    0xe2b(%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    11e1 <readPatternSetsIntersect+0xb1>
jmp    1230 <readPatternSetsIntersect+0x100>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ac <readPatternSetsIntersect+0x7c>
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    0x2e98(%rip),%r14
mov    (%r14),%edi
lea    0xea6(%rip),%rsi
mov    %r13,%rdx
call   1030 <fscanf@plt>
mov    (%r14),%edi
lea    0xead(%rip),%rsi
mov    %rbp,%rdx
call   1030 <fscanf@plt>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
mov    0x0(%r13),%edx
mov    0x0(%rbp),%ecx
lea    0xea5(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %rbp,0x20(%rsp)
cmpl   $0x0,0x0(%rbp)
je     1238 <readPatternSetsIntersect+0x108>
mov    0x0(%r13),%edi
xor    %ebx,%ebx
lea    0xe72(%rip),%rbp
lea    0xc(%rsp),%r12
jmp    11d0 <readPatternSetsIntersect+0xa0>
add    $0x1,%rbx
mov    0x20(%rsp),%rax
mov    (%rax),%eax
cmp    %rax,%rbx
jae    1238 <readPatternSetsIntersect+0x108>
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,(%r15,%rbx,8)
cmpl   $0x0,0x0(%r13)
mov    $0x0,%edi
je     11c0 <readPatternSetsIntersect+0x90>
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     1200 <readPatternSetsIntersect+0xd0>
mov    %r13,%r14
mov    %rbx,%r13
mov    0x10(%rsp),%rbx
jmp    11c0 <readPatternSetsIntersect+0x90>
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"
@stderr = global i32 0
@.str.2 = [48 x i8] c" numIdsPerPattern = %9d and numOfPatterns = %9d\00"
@.str.3 = [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* @stderr
%18 = load i32*, i32** %4
%19 = load i32, i32* %18
%20 = load i32*, i32** %5
%21 = load i32, i32* %20
%22 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %21)
%23 = call i64 @malloc(i32 8)
%24 = inttoptr i64 %23 to i32**
store i32** %24, i32*** %7
store i32 0, i32* %8
br label %25
25: ; preds = %63, %3
%26 = load i32, i32* %8
%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*** %7
%39 = load i32, i32* %8
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds i32*, i32** %38, i64 %40
store i32* %37, i32** %41
store i32 0, i32* %9
br label %42
42: ; preds = %59, %30
%43 = load i32, i32* %9
%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.3, i64 0, i64 0), i32* %10)
%50 = load i32, i32* %10
%51 = load i32**, i32*** %7
%52 = load i32, i32* %8
%53 = zext i32 %52 to i64
%54 = getelementptr inbounds i32*, i32** %51, i64 %53
%55 = load i32*, i32** %54
%56 = load i32, i32* %9
%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* %9
%61 = add i32 %60, 1
store i32 %61, i32* %9
br label %42
62: ; preds = %42
br label %63
63: ; preds = %62
%64 = load i32, i32* %8
%65 = add i32 %64, 1
store i32 %65, i32* %8
br label %25
66: ; preds = %25
%67 = load i32**, i32*** %7
%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"
@stderr = global i32 0
@.str.2 = [48 x i8] c" numIdsPerPattern = %9d and numOfPatterns = %9d\00"
@.str.3 = [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 = load i32, i32* @stderr
%10 = load i32, i32* %0
%11 = load i32, i32* %1
%12 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %10, i32 %11)
%13 = bitcast i32* %4 to i8*
%14 = tail call i64 @malloc(i32 8)
%15 = inttoptr i64 %14 to i32**
%16 = load i32, i32* %1
%17 = icmp eq i32 %16, 0
br i1 %17, label %46, label %18
18: ; preds = %3
%19 = load i32, i32* %0
br label %20
20: ; preds = %18, %40
%21 = phi i32 [ %19, %18 ], [ %41, %40 ]
%22 = phi i64 [ 0, %18 ], [ %42, %40 ]
%23 = shl i32 %21, 2
%24 = call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to i32*
%26 = getelementptr inbounds i32*, i32** %15, i64 %22
store i32* %25, i32** %26
%27 = load i32, i32* %0
%28 = icmp eq i32 %27, 0
br i1 %28, label %40, label %29
29: ; preds = %20, %29
%30 = phi i64 [ %36, %29 ], [ 0, %20 ]
%31 = load i32, i32* @stdin
%32 = call i32 @fscanf(i32 %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%33 = load i32, i32* %4
%34 = load i32*, i32** %26
%35 = getelementptr inbounds i32, i32* %34, i64 %30
store i32 %33, i32* %35
%36 = add nuw nsw i64 %30, 1
%37 = load i32, i32* %0
%38 = zext i32 %37 to i64
%39 = icmp ult i64 %36, %38
br i1 %39, label %29, label %40
40: ; preds = %29, %20
%41 = phi i32 [ 0, %20 ], [ %37, %29 ]
%42 = add nuw nsw i64 %22, 1
%43 = load i32, i32* %1
%44 = zext i32 %43 to i64
%45 = icmp ult i64 %42, %44
br i1 %45, label %20, label %46
46: ; preds = %40, %3
store i32** %15, i32*** %2
ret void
}