#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void print_key_iv(uint8_t *key, uint32_t keylen, uint8_t *iv) {
  uint8_t i;
  printf("Key:    ");
  for (i = 0; i < (keylen / 8); i++) {
    if ((i > 0) && (0 == (i % 8))) {
      printf("\n        ");
    }
    printf("0x%02x ", key[i]);
  }
  printf("\n");
  printf("IV:     ");
  for (i = 0; i < 8; i++) {
    printf("0x%02x ", iv[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_key_iv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    11aa <print_key_iv+0x9a>
cmpl   $0x0,-0x1c(%rbp)
jle    1183 <print_key_iv+0x73>
mov    -0x1c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
xor    %eax,%eax
cmp    %edx,%eax
jne    1183 <print_key_iv+0x73>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1138 <print_key_iv+0x28>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x8,-0x1c(%rbp)
jge    11fe <print_key_iv+0xee>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11cd <print_key_iv+0xbd>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_key_iv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%ebx
mov    %rdi,%r15
lea    0xec6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x8,%ebx
jl     1192 <print_key_iv+0x72>
shr    $0x3,%ebx
lea    0xeb9(%rip),%r12
lea    0xebc(%rip),%r13
xor    %ebp,%ebp
jmp    1177 <print_key_iv+0x57>
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbp,4),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
je     1192 <print_key_iv+0x72>
test   %rbp,%rbp
je     1160 <print_key_iv+0x40>
mov    %ebp,%eax
and    $0x7,%eax
test   %rax,%rax
jne    1160 <print_key_iv+0x40>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1160 <print_key_iv+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe78(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r14),%esi
lea    0xe5f(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%r14),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%r14),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%r14),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%r14),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%r14),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%r14),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%r14),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"Key: \00"
@.str.1 = [10 x i8] c"\0A \00"
@.str.2 = [8 x i8] c"0x%02x \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [9 x i8] c"IV: \00"
define void @print_key_iv(i32* %0, i32 %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %9
9: ; preds = %30, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %5
%12 = sdiv i32 %11, 8
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %33
14: ; preds = %9
%15 = load i32, i32* %7
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %14
%18 = load i32, i32* %7
%19 = srem i32 %18, 8
%20 = icmp eq i32 0, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %21, %17, %14
%24 = load i32*, i32** %4
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %23
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %9
33: ; preds = %9
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %7
br label %36
36: ; preds = %46, %33
%37 = load i32, i32* %7
%38 = icmp slt i32 %37, 8
br i1 %38, label %39, label %49
39: ; preds = %36
%40 = load i32*, i32** %6
%41 = load i32, i32* %7
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %40, i64 %42
%44 = load i32, i32* %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %39
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
br label %36
49: ; preds = %36
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"Key: \00"
@.str.1 = [10 x i8] c"\0A \00"
@.str.2 = [8 x i8] c"0x%02x \00"
@.str.4 = [9 x i8] c"IV: \00"
define void @print_key_iv(i32* nocapture %0, i32 %1, i32* nocapture %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%5 = icmp sgt i32 %1, 7
br i1 %5, label %6, label %23
6: ; preds = %3
%7 = lshr i32 %1, 3
%8 = zext i32 %7 to i64
br label %9
9: ; preds = %6, %17
%10 = phi i64 [ 0, %6 ], [ %21, %17 ]
%11 = icmp ne i64 %10, 0
%12 = and i64 %10, 7
%13 = icmp eq i64 %12, 0
%14 = and i1 %11, %13
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %9
%18 = getelementptr inbounds i32, i32* %0, i64 %10
%19 = load i32, i32* %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = add nuw nsw i64 %10, 1
%22 = icmp eq i64 %21, %8
br i1 %22, label %23, label %9
23: ; preds = %17, %3
%24 = tail call i32 @putchar(i32 10)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%26 = load i32, i32* %2
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds i32, i32* %2, i64 1
%29 = load i32, i32* %28
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds i32, i32* %2, i64 2
%32 = load i32, i32* %31
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds i32, i32* %2, i64 3
%35 = load i32, i32* %34
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = getelementptr inbounds i32, i32* %2, i64 4
%38 = load i32, i32* %37
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = getelementptr inbounds i32, i32* %2, i64 5
%41 = load i32, i32* %40
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %41)
%43 = getelementptr inbounds i32, i32* %2, i64 6
%44 = load i32, i32* %43
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %44)
%46 = getelementptr inbounds i32, i32* %2, i64 7
%47 = load i32, i32* %46
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %47)
%49 = tail call i32 @putchar(i32 10)
ret void
}