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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, ...);
void fprint_line(FILE *stream, uint16_t nb, int i, uint8_t *line) {
  int j;
  uint8_t ck = 0;
  fprintf(stream, ":%02X%04X00", i, nb);
  ck -= (uint8_t)i;
  ck -= nb & 0xFF;
  ck -= (nb >> 8) & 0xFF;
  for (j = 0; j < i; j++) {
    ck -= line[j];
    fprintf(stream, "%02X", line[j]);
  }
  fprintf(stream, "%02X\n", ck);
}


x86 assembly (clang, -O0):
<fprint_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xec2(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%ecx
mov    -0x20(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%ecx
and    $0xff,%ecx
mov    -0x20(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    -0x20(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11c6 <fprint_line+0xb6>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x20(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe5b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117c <fprint_line+0x6c>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xe3d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fprint_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %edx,%r15d
mov    %esi,%ebx
mov    %rdi,%r12
lea    0xed3(%rip),%rsi
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
movzbl %bl,%eax
add    %r15d,%eax
movzbl %bh,%ebp
add    %eax,%ebp
neg    %ebp
test   %r15d,%r15d
jle    117c <fprint_line+0x6c>
mov    %r15d,%r13d
lea    0xeba(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14,%rbx,4),%edx
sub    %edx,%ebp
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1160 <fprint_line+0x50>
lea    0xe8e(%rip),%rsi
mov    %r12,%rdi
mov    %ebp,%edx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>

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

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