#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_iv(FILE *fp, unsigned char iv[4][4]) {
  unsigned char buff[32];
  unsigned char tmp;
  int i, j;
  fprintf(fp, "@%08x\n", 0x00000008);
  for (i = 0; i < 4; i++)
    for (j = 0; j < 4; j++) {
      tmp = iv[3 - j][i];
      sprintf(buff, "%02x\n", tmp);
      fwrite(buff, 1, 3, fp);
    }
}


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

x86 assembly (clang, -O2):
<w_iv>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xeb6(%rip),%rsi
mov    $0x8,%edx
call   1030 <fprintf@plt>
mov    $0xfffffffffffffffc,%rbx
lea    0xea5(%rip),%r15
mov    %rsp,%r13
cs nopw 0x0(%rax,%rax,1)
nop
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 0xc(%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>
movzbl 0x4(%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_iv+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_iv(i32* %0, [4 x i8]* %1) {
%3 = alloca i32*
%4 = alloca [4 x i8]*
%5 = alloca [32 x i8]
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %3
store [4 x i8]* %1, [4 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 8)
store i32 0, i32* %7
br label %11
11: ; preds = %38, %2
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 4
br i1 %13, label %14, label %41
14: ; preds = %11
store i32 0, i32* %8
br label %15
15: ; preds = %34, %14
%16 = load i32, i32* %8
%17 = icmp slt i32 %16, 4
br i1 %17, label %18, label %37
18: ; preds = %15
%19 = load [4 x i8]*, [4 x i8]** %4
%20 = load i32, i32* %8
%21 = sub nsw i32 3, %20
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %19, i64 %22
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [4 x i8], [4 x i8]* %23, i64 0, i64 %25
%27 = load i8, i8* %26
store i8 %27, i8* %6
%28 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%29 = load i8, i8* %6
%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]* %5, 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* %8
%36 = add nsw i32 %35, 1
store i32 %36, i32* %8
br label %15
37: ; preds = %15
br label %38
38: ; preds = %37
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
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_iv(i32* nocapture %0, [4 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 8)
br label %6
6: ; preds = %2, %6
%7 = phi i64 [ 0, %2 ], [ %24, %6 ]
%8 = getelementptr inbounds [4 x i8], [4 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 [4 x i8], [4 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 [4 x i8], [4 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 [4 x i8], [4 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, 4
br i1 %25, label %26, label %6
26: ; preds = %6
ret void
}