#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 /*<<< orphan*/ write_hex(long long, unsigned char *, int /*<<< orphan*/ *);
void write_rsp(long long inlength, unsigned char *input, unsigned char *output,
               long long outlength, FILE *frsp) {
  fprintf(frsp, "Len = %lu\nMsg = ", inlength);
  write_hex(inlength, input, frsp);
  fprintf(frsp, "\nMD = ");
  write_hex(outlength, output, frsp);
  fprintf(frsp, "\n\n");
}


x86 assembly (clang, -O0):
<write_rsp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xeb5(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <write_hex@plt>
mov    -0x28(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <write_hex@plt>
mov    -0x28(%rbp),%rdi
lea    0xe87(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_rsp>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r8,%rbx
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r13
lea    0xeb1(%rip),%rsi
mov    %r8,%rdi
mov    %r13,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1030 <write_hex@plt>
lea    0xea0(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fwrite@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <write_hex@plt>
lea    0xe80(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1050 <fwrite@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"Len = %lu\0AMsg = \00"
@.str.1 = [7 x i8] c"\0AMD = \00"
@.str.2 = [3 x i8] c"\0A\0A\00"
define void @write_rsp(i64 %0, i8* %1, i8* %2, i64 %3, i32* %4) {
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32*
store i64 %0, i64* %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i64 %3, i64* %9
store i32* %4, i32** %10
%11 = load i32*, i32** %10
%12 = load i64, i64* %6
%13 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %12)
%14 = load i64, i64* %6
%15 = load i8*, i8** %7
%16 = load i32*, i32** %10
%17 = call i32 @write_hex(i64 %14, i8* %15, i32* %16)
%18 = load i32*, i32** %10
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%20 = load i64, i64* %9
%21 = load i8*, i8** %8
%22 = load i32*, i32** %10
%23 = call i32 @write_hex(i64 %20, i8* %21, i32* %22)
%24 = load i32*, i32** %10
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"Len = %lu\0AMsg = \00"
@.str.1 = [7 x i8] c"\0AMD = \00"
@.str.2 = [3 x i8] c"\0A\0A\00"
define void @write_rsp(i64 %0, i8* %1, i8* %2, i64 %3, i32* %4) {
%6 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %0)
%7 = tail call i32 @write_hex(i64 %0, i8* %1, i32* %4)
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 6, i64 1, i32* %4)
%9 = tail call i32 @write_hex(i64 %3, i8* %2, i32* %4)
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i64 2, i64 1, i32* %4)
ret void
}