#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 */
struct cgw_csum_crc8 {
  int from_idx;
  int to_idx;
  int result_idx;
  int init_crc_val;
  int final_xor_val;
  int *crctab;
  scalar_t__ profile;
};

/* Variables and functions */
scalar_t__ CGW_CRC8PRF_UNSPEC;
int /*<<< orphan*/ print_cs_crc8_profile(struct cgw_csum_crc8 *);
int /*<<< orphan*/ printf(char *, ...);
void print_cs_crc8(struct cgw_csum_crc8 *cs_crc8) {
  int i;
  printf("-c %d:%d:%d:%02X:%02X:", cs_crc8->from_idx, cs_crc8->to_idx,
         cs_crc8->result_idx, cs_crc8->init_crc_val, cs_crc8->final_xor_val);
  for (i = 0; i < 256; i++)
    printf("%02X", cs_crc8->crctab[i]);
  printf(" ");
  if (cs_crc8->profile != CGW_CRC8PRF_UNSPEC)
    print_cs_crc8_profile(cs_crc8);
}


x86 assembly (clang, -O0):
<print_cs_crc8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%r8d
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%r9d
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x100,-0xc(%rbp)
jge    119d <print_cs_crc8+0x7d>
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1165 <print_cs_crc8+0x45>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x20(%rax),%rax
mov    0x2e2e(%rip),%rcx
cmp    (%rcx),%rax
je     11cc <print_cs_crc8+0xac>
mov    -0x8(%rbp),%rdi
call   1030 <print_cs_crc8_profile@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_cs_crc8>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
mov    (%rdi),%esi
mov    0x4(%rdi),%edx
mov    0x8(%rdi),%ecx
mov    0xc(%rdi),%r8d
mov    0x10(%rdi),%r9d
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeba(%rip),%r14
xor    %ebx,%ebx
nop
mov    0x18(%r15),%rax
mov    (%rax,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    1160 <print_cs_crc8+0x30>
mov    $0x20,%edi
call   1040 <putchar@plt>
mov    0x20(%r15),%rax
mov    0x2e55(%rip),%rcx
cmp    (%rcx),%rax
jne    119e <print_cs_crc8+0x6e>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <print_cs_crc8_profile@plt>

LLVM IR (-O0):
%struct.cgw_csum_crc8 = type { i32, i32, i32, i32, i32, i32*, i64 }
@.str = [23 x i8] c"-c %d:%d:%d:%02X:%02X:\00"
@.str.1 = [5 x i8] c"%02X\00"
@.str.2 = [2 x i8] c" \00"
@CGW_CRC8PRF_UNSPEC = global i64 0
define void @print_cs_crc8(%struct.cgw_csum_crc8* %0) {
%2 = alloca %struct.cgw_csum_crc8*
%3 = alloca i32
store %struct.cgw_csum_crc8* %0, %struct.cgw_csum_crc8** %2
%4 = load %struct.cgw_csum_crc8*, %struct.cgw_csum_crc8** %2
%5 = getelementptr inbounds %struct.cgw_csum_crc8, %struct.cgw_csum_crc8* %4, i32 0, i32 0
%6 = load i32, i32* %5
%7 = load %struct.cgw_csum_crc8*, %struct.cgw_csum_crc8** %2
%8 = getelementptr inbounds %struct.cgw_csum_crc8, %struct.cgw_csum_crc8* %7, i32 0, i32 1
%9 = load i32, i32* %8
%10 = load %struct.cgw_csum_crc8*, %struct.cgw_csum_crc8** %2
%11 = getelementptr inbounds %struct.cgw_csum_crc8, %struct.cgw_csum_crc8* %10, i32 0, i32 2
%12 = load i32, i32* %11
%13 = load %struct.cgw_csum_crc8*, %struct.cgw_csum_crc8** %2
%14 = getelementptr inbounds %struct.cgw_csum_crc8, %struct.cgw_csum_crc8* %13, i32 0, i32 3
%15 = load i32, i32* %14
%16 = load %struct.cgw_csum_crc8*, %struct.cgw_csum_crc8** %2
%17 = getelementptr inbounds %struct.cgw_csum_crc8, %struct.cgw_csum_crc8* %16, i32 0, i32 4
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %9, i32 %12, i32 %15, i32 %18)
store i32 0, i32* %3
br label %20
20: ; preds = %32, %1
%21 = load i32, i32* %3
%22 = icmp slt i32 %21, 256
br i1 %22, label %23, label %35
23: ; preds = %20
%24 = load %struct.cgw_csum_crc8*, %struct.cgw_csum_crc8** %2
%25 = getelementptr inbounds %struct.cgw_csum_crc8, %struct.cgw_csum_crc8* %24, i32 0, i32 5
%26 = load i32*, i32** %25
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %23
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %20
35: ; preds = %20
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%37 = load %struct.cgw_csum_crc8*, %struct.cgw_csum_crc8** %2
%38 = getelementptr inbounds %struct.cgw_csum_crc8, %struct.cgw_csum_crc8* %37, i32 0, i32 6
%39 = load i64, i64* %38
%40 = load i64, i64* @CGW_CRC8PRF_UNSPEC
%41 = icmp ne i64 %39, %40
br i1 %41, label %42, label %45
42: ; preds = %35
%43 = load %struct.cgw_csum_crc8*, %struct.cgw_csum_crc8** %2
%44 = call i32 @print_cs_crc8_profile(%struct.cgw_csum_crc8* %43)
br label %45
45: ; preds = %42, %35
ret void
}

LLVM IR (-O2):
%struct.cgw_csum_crc8 = type { i32, i32, i32, i32, i32, i32*, i64 }
@.str = [23 x i8] c"-c %d:%d:%d:%02X:%02X:\00"
@.str.1 = [5 x i8] c"%02X\00"
@CGW_CRC8PRF_UNSPEC = global i64 0
define void @print_cs_crc8(%struct.cgw_csum_crc8* %0) {
%2 = getelementptr inbounds %struct.cgw_csum_crc8, %struct.cgw_csum_crc8* %0, i64 0, i32 0
%3 = load i32, i32* %2
%4 = getelementptr inbounds %struct.cgw_csum_crc8, %struct.cgw_csum_crc8* %0, i64 0, i32 1
%5 = load i32, i32* %4
%6 = getelementptr inbounds %struct.cgw_csum_crc8, %struct.cgw_csum_crc8* %0, i64 0, i32 2
%7 = load i32, i32* %6
%8 = getelementptr inbounds %struct.cgw_csum_crc8, %struct.cgw_csum_crc8* %0, i64 0, i32 3
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.cgw_csum_crc8, %struct.cgw_csum_crc8* %0, i64 0, i32 4
%11 = load i32, i32* %10
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %5, i32 %7, i32 %9, i32 %11)
%13 = getelementptr inbounds %struct.cgw_csum_crc8, %struct.cgw_csum_crc8* %0, i64 0, i32 5
br label %14
14: ; preds = %1, %14
%15 = phi i64 [ 0, %1 ], [ %20, %14 ]
%16 = load i32*, i32** %13
%17 = getelementptr inbounds i32, i32* %16, i64 %15
%18 = load i32, i32* %17
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = add nuw nsw i64 %15, 1
%21 = icmp eq i64 %20, 256
br i1 %21, label %22, label %14
22: ; preds = %14
%23 = tail call i32 @putchar(i32 32)
%24 = getelementptr inbounds %struct.cgw_csum_crc8, %struct.cgw_csum_crc8* %0, i64 0, i32 6
%25 = load i64, i64* %24
%26 = load i64, i64* @CGW_CRC8PRF_UNSPEC
%27 = icmp eq i64 %25, %26
br i1 %27, label %30, label %28
28: ; preds = %22
%29 = tail call i32 @print_cs_crc8_profile(%struct.cgw_csum_crc8* %0)
br label %30
30: ; preds = %28, %22
ret void
}