#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 rtattr {
  int dummy;
};
struct link_util {
  int dummy;
};
struct can_device_stats {
  int restarts;
  int bus_error;
  int arbitration_lost;
  int error_warning;
  int error_passive;
  int bus_off;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
struct can_device_stats *RTA_DATA(struct rtattr *);
int RTA_PAYLOAD(struct rtattr *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void can_print_xstats(struct link_util *lu, FILE *f, struct rtattr *xstats) {
  struct can_device_stats *stats;
  if (xstats && RTA_PAYLOAD(xstats) == sizeof(*stats)) {
    stats = RTA_DATA(xstats);
    fprintf(f, "\n    "
               "re-started bus-errors arbit-lost "
               "error-warn error-pass bus-off");
    fprintf(f, "\n    %-10d %-10d %-10d %-10d %-10d %-10d", stats->restarts,
            stats->bus_error, stats->arbitration_lost, stats->error_warning,
            stats->error_passive, stats->bus_off);
  }
}


x86 assembly (clang, -O0):
<can_print_xstats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c9 <can_print_xstats+0x99>
mov    -0x18(%rbp),%rdi
call   1030 <RTA_PAYLOAD@plt>
cltq
cmp    $0x18,%rax
jne    11c9 <can_print_xstats+0x99>
mov    -0x18(%rbp),%rdi
call   1050 <RTA_DATA@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe84(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x20(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%r10d
mov    -0x20(%rbp),%rax
mov    0x14(%rax),%eax
lea    0xe8a(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<can_print_xstats>:
push   %r14
push   %rbx
push   %rax
test   %rdx,%rdx
je     11ae <can_print_xstats+0x6e>
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdx,%rdi
call   1030 <RTA_PAYLOAD@plt>
cmp    $0x18,%eax
jne    11ae <can_print_xstats+0x6e>
mov    %rbx,%rdi
call   1050 <RTA_DATA@plt>
mov    %rax,%rbx
lea    0xe92(%rip),%rdi
mov    $0x43,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1060 <fwrite@plt>
mov    (%rbx),%edx
mov    0x4(%rbx),%ecx
mov    0x8(%rbx),%r8d
mov    0xc(%rbx),%r9d
mov    0x10(%rbx),%r10d
mov    0x14(%rbx),%ebx
lea    0xea9(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
push   %rbx
push   %r10
call   1040 <fprintf@plt>
add    $0x18,%rsp
jmp    11b2 <can_print_xstats+0x72>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.link_util = type { i32 }
%struct.rtattr = type { i32 }
%struct.can_device_stats = type { i32, i32, i32, i32, i32, i32 }
@.str = [68 x i8] c"\0A re-started bus-errors arbit-lost error-warn error-pass bus-off\00"
@.str.1 = [41 x i8] c"\0A %-10d %-10d %-10d %-10d %-10d %-10d\00"
define void @can_print_xstats(%struct.link_util* %0, i32* %1, %struct.rtattr* %2) {
%4 = alloca %struct.link_util*
%5 = alloca i32*
%6 = alloca %struct.rtattr*
%7 = alloca %struct.can_device_stats*
store %struct.link_util* %0, %struct.link_util** %4
store i32* %1, i32** %5
store %struct.rtattr* %2, %struct.rtattr** %6
%8 = load %struct.rtattr*, %struct.rtattr** %6
%9 = icmp ne %struct.rtattr* %8, null
br i1 %9, label %10, label %40
10: ; preds = %3
%11 = load %struct.rtattr*, %struct.rtattr** %6
%12 = call i32 @RTA_PAYLOAD(%struct.rtattr* %11)
%13 = sext i32 %12 to i64
%14 = icmp eq i64 %13, 24
br i1 %14, label %15, label %40
15: ; preds = %10
%16 = load %struct.rtattr*, %struct.rtattr** %6
%17 = call %struct.can_device_stats* @RTA_DATA(%struct.rtattr* %16)
store %struct.can_device_stats* %17, %struct.can_device_stats** %7
%18 = load i32*, i32** %5
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0))
%20 = load i32*, i32** %5
%21 = load %struct.can_device_stats*, %struct.can_device_stats** %7
%22 = getelementptr inbounds %struct.can_device_stats, %struct.can_device_stats* %21, i32 0, i32 0
%23 = load i32, i32* %22
%24 = load %struct.can_device_stats*, %struct.can_device_stats** %7
%25 = getelementptr inbounds %struct.can_device_stats, %struct.can_device_stats* %24, i32 0, i32 1
%26 = load i32, i32* %25
%27 = load %struct.can_device_stats*, %struct.can_device_stats** %7
%28 = getelementptr inbounds %struct.can_device_stats, %struct.can_device_stats* %27, i32 0, i32 2
%29 = load i32, i32* %28
%30 = load %struct.can_device_stats*, %struct.can_device_stats** %7
%31 = getelementptr inbounds %struct.can_device_stats, %struct.can_device_stats* %30, i32 0, i32 3
%32 = load i32, i32* %31
%33 = load %struct.can_device_stats*, %struct.can_device_stats** %7
%34 = getelementptr inbounds %struct.can_device_stats, %struct.can_device_stats* %33, i32 0, i32 4
%35 = load i32, i32* %34
%36 = load %struct.can_device_stats*, %struct.can_device_stats** %7
%37 = getelementptr inbounds %struct.can_device_stats, %struct.can_device_stats* %36, i32 0, i32 5
%38 = load i32, i32* %37
%39 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 %26, i32 %29, i32 %32, i32 %35, i32 %38)
br label %40
40: ; preds = %15, %10, %3
ret void
}

LLVM IR (-O2):
%struct.link_util = type { i32 }
%struct.rtattr = type { i32 }
%struct.can_device_stats = type { i32, i32, i32, i32, i32, i32 }
@.str = [68 x i8] c"\0A re-started bus-errors arbit-lost error-warn error-pass bus-off\00"
@.str.1 = [41 x i8] c"\0A %-10d %-10d %-10d %-10d %-10d %-10d\00"
define void @can_print_xstats(%struct.link_util* nocapture readnone %0, i32* nocapture %1, %struct.rtattr* %2) {
%4 = icmp eq %struct.rtattr* %2, null
br i1 %4, label %24, label %5
5: ; preds = %3
%6 = tail call i32 @RTA_PAYLOAD(%struct.rtattr* %2)
%7 = icmp eq i32 %6, 24
br i1 %7, label %8, label %24
8: ; preds = %5
%9 = tail call %struct.can_device_stats* @RTA_DATA(%struct.rtattr* %2)
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i64 67, i64 1, i32* %1)
%11 = getelementptr inbounds %struct.can_device_stats, %struct.can_device_stats* %9, i64 0, i32 0
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.can_device_stats, %struct.can_device_stats* %9, i64 0, i32 1
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.can_device_stats, %struct.can_device_stats* %9, i64 0, i32 2
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.can_device_stats, %struct.can_device_stats* %9, i64 0, i32 3
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.can_device_stats, %struct.can_device_stats* %9, i64 0, i32 4
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.can_device_stats, %struct.can_device_stats* %9, i64 0, i32 5
%22 = load i32, i32* %21
%23 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %14, i32 %16, i32 %18, i32 %20, i32 %22)
br label %24
24: ; preds = %8, %5, %3
ret void
}