#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 */
typedef int uint8_t;
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ K_perm_64_128(int /*<<< orphan*/ *, int);
void key_schedule(uint16_t subkeys[][2 * 3], uint16_t *master_key) {
  uint8_t c, i;
  for (c = 0; c < (2 * 8 + 1); c++) {
    for (i = 0; i < 2 * 3; i++) {
      subkeys[c][i] = master_key[i];
    }
    K_perm_64_128(master_key, c + 1);
  }
}


x86 assembly (clang, -O0):
<key_schedule>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x11,-0x14(%rbp)
jge    118e <key_schedule+0x7e>
movl   $0x0,-0x18(%rbp)
cmpl   $0x6,-0x18(%rbp)
jge    1171 <key_schedule+0x61>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1138 <key_schedule+0x28>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
call   1030 <K_perm_64_128@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <key_schedule+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<key_schedule>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
mov    $0x14,%ebx
mov    $0x1,%ebp
nopw   0x0(%rax,%rax,1)
mov    (%r15),%eax
mov    %eax,-0x14(%r14,%rbx,1)
mov    0x4(%r15),%eax
mov    %eax,-0x10(%r14,%rbx,1)
mov    0x8(%r15),%eax
mov    %eax,-0xc(%r14,%rbx,1)
mov    0xc(%r15),%eax
mov    %eax,-0x8(%r14,%rbx,1)
mov    0x10(%r15),%eax
mov    %eax,-0x4(%r14,%rbx,1)
mov    0x14(%r15),%eax
mov    %eax,(%r14,%rbx,1)
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <K_perm_64_128@plt>
add    $0x18,%rbx
add    $0x1,%ebp
cmp    $0x1ac,%rbx
jne    1130 <key_schedule+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @key_schedule([6 x i32]* %0, i32* %1) {
%3 = alloca [6 x i32]*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store [6 x i32]* %0, [6 x i32]** %3
store i32* %1, i32** %4
store i32 0, i32* %5
br label %7
7: ; preds = %35, %2
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 17
br i1 %9, label %10, label %38
10: ; preds = %7
store i32 0, i32* %6
br label %11
11: ; preds = %27, %10
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 6
br i1 %13, label %14, label %30
14: ; preds = %11
%15 = load i32*, i32** %4
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = load i32, i32* %18
%20 = load [6 x i32]*, [6 x i32]** %3
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [6 x i32], [6 x i32]* %20, i64 %22
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [6 x i32], [6 x i32]* %23, i64 0, i64 %25
store i32 %19, i32* %26
br label %27
27: ; preds = %14
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %11
30: ; preds = %11
%31 = load i32*, i32** %4
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
%34 = call i32 @K_perm_64_128(i32* %31, i32 %33)
br label %35
35: ; preds = %30
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %7
38: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @key_schedule([6 x i32]* nocapture writeonly %0, i32* %1) {
%3 = getelementptr inbounds i32, i32* %1, i64 1
%4 = getelementptr inbounds i32, i32* %1, i64 2
%5 = getelementptr inbounds i32, i32* %1, i64 3
%6 = getelementptr inbounds i32, i32* %1, i64 4
%7 = getelementptr inbounds i32, i32* %1, i64 5
br label %8
8: ; preds = %2, %8
%9 = phi i64 [ 0, %2 ], [ %22, %8 ]
%10 = load i32, i32* %1
%11 = getelementptr inbounds [6 x i32], [6 x i32]* %0, i64 %9, i64 0
store i32 %10, i32* %11
%12 = load i32, i32* %3
%13 = getelementptr inbounds [6 x i32], [6 x i32]* %0, i64 %9, i64 1
store i32 %12, i32* %13
%14 = load i32, i32* %4
%15 = getelementptr inbounds [6 x i32], [6 x i32]* %0, i64 %9, i64 2
store i32 %14, i32* %15
%16 = load i32, i32* %5
%17 = getelementptr inbounds [6 x i32], [6 x i32]* %0, i64 %9, i64 3
store i32 %16, i32* %17
%18 = load i32, i32* %6
%19 = getelementptr inbounds [6 x i32], [6 x i32]* %0, i64 %9, i64 4
store i32 %18, i32* %19
%20 = load i32, i32* %7
%21 = getelementptr inbounds [6 x i32], [6 x i32]* %0, i64 %9, i64 5
store i32 %20, i32* %21
%22 = add nuw nsw i64 %9, 1
%23 = trunc i64 %22 to i32
%24 = tail call i32 @K_perm_64_128(i32* %1, i32 %23)
%25 = icmp eq i64 %22, 17
br i1 %25, label %26, label %8
26: ; preds = %8
ret void
}