#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 can_frame {
  int can_id;
};
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int CAN_ERR_FLAG;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ snprintf_can_error_frame(char *, int, struct can_frame *,
                                            char *);
int /*<<< orphan*/ sprint_long_canframe(char *, struct can_frame *, int);
void fprint_long_canframe(FILE *stream, struct can_frame *cf, char *eol,
                          int view) {
  char buf[256];
  sprint_long_canframe(buf, cf, view);
  fprintf(stream, "%s", buf);
  if ((view & 0x8) && (cf->can_id & CAN_ERR_FLAG)) {
    snprintf_can_error_frame(buf, sizeof(buf), cf, "\n\t");
    fprintf(stream, "\n\t%s", buf);
  }
  if (eol)
    fprintf(stream, "%s", eol);
}


x86 assembly (clang, -O0):
<fprint_long_canframe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <sprint_long_canframe@plt>
mov    -0x8(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xe96(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x1c(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     11ce <fprint_long_canframe+0x9e>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2e58(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11ce <fprint_long_canframe+0x9e>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x100,%esi
lea    0xe4e(%rip),%rcx
call   1030 <snprintf_can_error_frame@plt>
mov    -0x8(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xe3a(%rip),%rsi
call   1050 <fprintf@plt>
cmpq   $0x0,-0x18(%rbp)
je     11ed <fprint_long_canframe+0xbd>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe1d(%rip),%rsi
call   1050 <fprintf@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fprint_long_canframe>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsp,%r12
mov    %r12,%rdi
mov    %ecx,%edx
call   1050 <sprint_long_canframe@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <fputs@plt>
test   $0x8,%bpl
je     11b1 <fprint_long_canframe+0x71>
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
test   %eax,(%rbx)
je     11b1 <fprint_long_canframe+0x71>
lea    0xe74(%rip),%rcx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1040 <snprintf_can_error_frame@plt>
lea    0xe5d(%rip),%rsi
mov    %r15,%rdi
mov    %rbp,%rdx
call   1060 <fprintf@plt>
test   %r14,%r14
je     11c1 <fprint_long_canframe+0x81>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <fputs@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.can_frame = type { i32 }
@.str = [3 x i8] c"%s\00"
@CAN_ERR_FLAG = global i32 0
@.str.1 = [3 x i8] c"\0A\09\00"
@.str.2 = [5 x i8] c"\0A\09%s\00"
define void @fprint_long_canframe(i32* %0, %struct.can_frame* %1, i8* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca %struct.can_frame*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [256 x i8]
store i32* %0, i32** %5
store %struct.can_frame* %1, %struct.can_frame** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%11 = load %struct.can_frame*, %struct.can_frame** %6
%12 = load i32, i32* %8
%13 = call i32 @sprint_long_canframe(i8* %10, %struct.can_frame* %11, i32 %12)
%14 = load i32*, i32** %5
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%16 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i32, i32* %8
%18 = and i32 %17, 8
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %34
20: ; preds = %4
%21 = load %struct.can_frame*, %struct.can_frame** %6
%22 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %21, i32 0, i32 0
%23 = load i32, i32* %22
%24 = load i32, i32* @CAN_ERR_FLAG
%25 = and i32 %23, %24
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %34
27: ; preds = %20
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%29 = load %struct.can_frame*, %struct.can_frame** %6
%30 = call i32 @snprintf_can_error_frame(i8* %28, i32 256, %struct.can_frame* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%31 = load i32*, i32** %5
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%33 = call i32 @fprintf(i32* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %27, %20, %4
%35 = load i8*, i8** %7
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %41
37: ; preds = %34
%38 = load i32*, i32** %5
%39 = load i8*, i8** %7
%40 = call i32 @fprintf(i32* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %39)
br label %41
41: ; preds = %37, %34
ret void
}

LLVM IR (-O2):
%struct.can_frame = type { i32 }
@CAN_ERR_FLAG = global i32 0
@.str.1 = [3 x i8] c"\0A\09\00"
@.str.2 = [5 x i8] c"\0A\09%s\00"
define void @fprint_long_canframe(i32* nocapture %0, %struct.can_frame* %1, i8* %2, i32 %3) {
%5 = alloca [256 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%7 = call i32 @sprint_long_canframe(i8* %6, %struct.can_frame* %1, i32 %3)
%8 = call i32 @fputs(i8* %6, i32* %0)
%9 = and i32 %3, 8
%10 = icmp eq i32 %9, 0
br i1 %10, label %20, label %11
11: ; preds = %4
%12 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %1, i64 0, i32 0
%13 = load i32, i32* %12
%14 = load i32, i32* @CAN_ERR_FLAG
%15 = and i32 %14, %13
%16 = icmp eq i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %11
%18 = call i32 @snprintf_can_error_frame(i8* %6, i32 256, %struct.can_frame* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %6)
br label %20
20: ; preds = %17, %11, %4
%21 = icmp eq i8* %2, null
br i1 %21, label %24, label %22
22: ; preds = %20
%23 = call i32 @fputs(i8* %2, i32* %0)
br label %24
24: ; preds = %22, %20
ret void
}