#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 */
struct pattern3s {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ patterns_gen(struct pattern3s *, char **, int);
int /*<<< orphan*/ patterns_load(char **, int, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void pattern3s_init(struct pattern3s *p, char src[][11], int src_n) {
  char nsrc[src_n][11];
  if (!patterns_load(nsrc, src_n, "moggy.patterns")) {
    for (int i = 0; i < src_n; i++)
      strcpy(nsrc[i], src[i]);
  }
  patterns_gen(p, nsrc, src_n);
}


x86 assembly (clang, -O0):
<pattern3s_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    (%rax,%rax,4),%rcx
lea    0xf(%rax,%rcx,2),%rcx
movabs $0x1ffffffff0,%rdx
and    %rdx,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe82(%rip),%rdx
call   1040 <patterns_load@plt>
cmp    $0x0,%eax
jne    11d5 <pattern3s_init+0xa5>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d0 <pattern3s_init+0xa0>
mov    -0x38(%rbp),%rdi
movslq -0x2c(%rbp),%rax
imul   $0xb,%rax,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
movslq -0x2c(%rbp),%rax
imul   $0xb,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1193 <pattern3s_init+0x63>
jmp    11d5 <pattern3s_init+0xa5>
mov    -0x38(%rbp),%rsi
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
call   1050 <patterns_gen@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pattern3s_init>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%r13
mov    %rdi,-0x30(%rbp)
mov    %edx,%r14d
lea    (%r14,%r14,4),%rax
lea    (%r14,%rax,2),%rax
add    $0xf,%rax
movabs $0x1ffffffff0,%rcx
and    %rax,%rcx
mov    %rsp,%r12
sub    %rcx,%r12
mov    %r12,%rsp
lea    0xe8c(%rip),%rdx
mov    %r12,%rdi
mov    %r15d,%esi
call   1040 <patterns_load@plt>
test   %eax,%eax
jne    11a9 <pattern3s_init+0x79>
test   %r15d,%r15d
jle    11a9 <pattern3s_init+0x79>
mov    %r12,%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
add    $0xb,%rbx
add    $0xb,%r13
add    $0xffffffffffffffff,%r14
jne    1190 <pattern3s_init+0x60>
mov    -0x30(%rbp),%rdi
mov    %r12,%rsi
mov    %r15d,%edx
call   1050 <patterns_gen@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.pattern3s = type { i32 }
@.str = [15 x i8] c"moggy.patterns\00"
define void @pattern3s_init(%struct.pattern3s* %0, [11 x i8]* %1, i32 %2) {
%4 = alloca %struct.pattern3s*
%5 = alloca [11 x i8]*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
store %struct.pattern3s* %0, %struct.pattern3s** %4
store [11 x i8]* %1, [11 x i8]** %5
store i32 %2, i32* %6
%10 = load i32, i32* %6
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %7
%13 = alloca [11 x i8], i64 %11
store i64 %11, i64* %8
%14 = bitcast [11 x i8]* %13 to i8**
%15 = load i32, i32* %6
%16 = call i32 @patterns_load(i8** %14, i32 %15, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %38, label %18
18: ; preds = %3
store i32 0, i32* %9
br label %19
19: ; preds = %34, %18
%20 = load i32, i32* %9
%21 = load i32, i32* %6
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %37
23: ; preds = %19
%24 = load i32, i32* %9
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [11 x i8], [11 x i8]* %13, i64 %25
%27 = getelementptr inbounds [11 x i8], [11 x i8]* %26, i64 0, i64 0
%28 = load [11 x i8]*, [11 x i8]** %5
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [11 x i8], [11 x i8]* %28, i64 %30
%32 = getelementptr inbounds [11 x i8], [11 x i8]* %31, i64 0, i64 0
%33 = call i32 @strcpy(i8* %27, i8* %32)
br label %34
34: ; preds = %23
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
store i32 %36, i32* %9
br label %19
37: ; preds = %19
br label %38
38: ; preds = %37, %3
%39 = load %struct.pattern3s*, %struct.pattern3s** %4
%40 = bitcast [11 x i8]* %13 to i8**
%41 = load i32, i32* %6
%42 = call i32 @patterns_gen(%struct.pattern3s* %39, i8** %40, i32 %41)
%43 = load i8*, i8** %7
ret void
}

LLVM IR (-O2):
%struct.pattern3s = type { i32 }
@.str = [15 x i8] c"moggy.patterns\00"
define void @pattern3s_init(%struct.pattern3s* %0, [11 x i8]* %1, i32 %2) {
%4 = zext i32 %2 to i64
%5 = alloca [11 x i8], i64 %4
%6 = bitcast [11 x i8]* %5 to i8**
%7 = call i32 @patterns_load(i8** %6, i32 %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
%9 = icmp sgt i32 %2, 0
%10 = and i1 %8, %9
br i1 %10, label %11, label %18
11: ; preds = %3, %11
%12 = phi i64 [ %16, %11 ], [ 0, %3 ]
%13 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 %12, i64 0
%14 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 %12, i64 0
%15 = call i32 @strcpy(i8* %13, i8* %14)
%16 = add nuw nsw i64 %12, 1
%17 = icmp eq i64 %16, %4
br i1 %17, label %18, label %11
18: ; preds = %11, %3
%19 = call i32 @patterns_gen(%struct.pattern3s* %0, i8** %6, i32 %2)
ret void
}