#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(unsigned char *, char *, unsigned char);
void w_key256(FILE *fp, unsigned char key[4][8]) {
  int i, j;
  unsigned char tmp;
  unsigned char buff[32];
  fprintf(fp, "@%08x\n", 0x00000018);
  for (i = 0; i < 8; i++)
    for (j = 0; j < 4; j++) {
      tmp = key[3 - j][i];
      sprintf(buff, "%02x\n", tmp);
      fwrite(buff, 1, 3, fp);
    }
}


x86 assembly (clang, -O0):
<w_key256>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb5(%rip),%rsi
mov    $0x18,%edx
call   1030 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    11e3 <w_key256+0xb3>
movl   $0x0,-0x18(%rbp)
cmpl   $0x4,-0x18(%rbp)
jge    11d0 <w_key256+0xa0>
mov    -0x10(%rbp),%rax
mov    $0x3,%ecx
sub    -0x18(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe65(%rip),%rsi
movzbl -0x19(%rbp),%edx
call   1040 <sprintf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x3,%edx
call   1050 <fwrite@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116d <w_key256+0x3d>
jmp    11d5 <w_key256+0xa5>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115c <w_key256+0x2c>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<w_key256>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xeb6(%rip),%rsi
mov    $0x18,%edx
call   1030 <fprintf@plt>
mov    $0xfffffffffffffff8,%rbx
lea    0xea5(%rip),%r15
mov    %rsp,%r13
cs nopw 0x0(%rax,%rax,1)
nop
movzbl 0x20(%r14,%rbx,1),%edx
mov    %r13,%rdi
mov    %r15,%rsi
call   1040 <sprintf@plt>
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    %r12,%rcx
call   1050 <fwrite@plt>
movzbl 0x18(%r14,%rbx,1),%edx
mov    %r13,%rdi
mov    %r15,%rsi
call   1040 <sprintf@plt>
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    %r12,%rcx
call   1050 <fwrite@plt>
movzbl 0x10(%r14,%rbx,1),%edx
mov    %r13,%rdi
mov    %r15,%rsi
call   1040 <sprintf@plt>
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    %r12,%rcx
call   1050 <fwrite@plt>
movzbl 0x8(%r14,%rbx,1),%edx
mov    %r13,%rdi
mov    %r15,%rsi
call   1040 <sprintf@plt>
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    %r12,%rcx
call   1050 <fwrite@plt>
inc    %rbx
jne    1170 <w_key256+0x40>
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"@%08x\0A\00"
@.str.1 = [6 x i8] c"%02x\0A\00"
define void @w_key256(i32* %0, [8 x i8]* %1) {
%3 = alloca i32*
%4 = alloca [8 x i8]*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
%8 = alloca [32 x i8]
store i32* %0, i32** %3
store [8 x i8]* %1, [8 x i8]** %4
%9 = load i32*, i32** %3
%10 = call i32 @fprintf(i32* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 24)
store i32 0, i32* %5
br label %11
11: ; preds = %38, %2
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 8
br i1 %13, label %14, label %41
14: ; preds = %11
store i32 0, i32* %6
br label %15
15: ; preds = %34, %14
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 4
br i1 %17, label %18, label %37
18: ; preds = %15
%19 = load [8 x i8]*, [8 x i8]** %4
%20 = load i32, i32* %6
%21 = sub nsw i32 3, %20
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %19, i64 %22
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [8 x i8], [8 x i8]* %23, i64 0, i64 %25
%27 = load i8, i8* %26
store i8 %27, i8* %7
%28 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%29 = load i8, i8* %7
%30 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %29)
%31 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%32 = load i32*, i32** %3
%33 = call i32 @fwrite(i8* %31, i32 1, i32 3, i32* %32)
br label %34
34: ; preds = %18
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %15
37: ; preds = %15
br label %38
38: ; preds = %37
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %11
41: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"@%08x\0A\00"
@.str.1 = [6 x i8] c"%02x\0A\00"
define void @w_key256(i32* nocapture %0, [8 x i8]* nocapture %1) {
%3 = alloca [32 x i8]
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 24)
br label %6
6: ; preds = %2, %6
%7 = phi i64 [ 0, %2 ], [ %24, %6 ]
%8 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 3, i64 %7
%9 = load i8, i8* %8
%10 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %9)
%11 = call i32 @fwrite(i8* %4, i32 1, i32 3, i32* %0)
%12 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 2, i64 %7
%13 = load i8, i8* %12
%14 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %13)
%15 = call i32 @fwrite(i8* %4, i32 1, i32 3, i32* %0)
%16 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 1, i64 %7
%17 = load i8, i8* %16
%18 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %17)
%19 = call i32 @fwrite(i8* %4, i32 1, i32 3, i32* %0)
%20 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 %7
%21 = load i8, i8* %20
%22 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %21)
%23 = call i32 @fwrite(i8* %4, i32 1, i32 3, i32* %0)
%24 = add nuw nsw i64 %7, 1
%25 = icmp eq i64 %24, 8
br i1 %25, label %26, label %6
26: ; preds = %6
ret void
}