#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 canfd_frame {
  int len;
  int /*<<< orphan*/ *data;
  int /*<<< orphan*/ can_id;
};

/* Variables and functions */
int /*<<< orphan*/ plog(char *, ...);
void print_pkt(struct canfd_frame frame) {
  int i;
  plog("Pkt: %02X#", frame.can_id);
  for (i = 0; i < frame.len; i++) {
    plog("%02X ", frame.data[i]);
  }
  plog("\n");
}


x86 assembly (clang, -O0):
<print_pkt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    0x10(%rax),%esi
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <plog@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rcx
mov    -0x4(%rbp),%eax
cmp    (%rcx),%eax
jge    1172 <print_pkt+0x62>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <plog@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1138 <print_pkt+0x28>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <plog@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_pkt>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x40(%rsp),%esi
lea    0xedd(%rip),%rdi
xor    %eax,%eax
call   1030 <plog@plt>
mov    0x30(%rsp),%r15d
test   %r15d,%r15d
jle    1167 <print_pkt+0x57>
lea    0x30(%rsp),%rax
mov    0x8(%rax),%r12
lea    0xec7(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%r12,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <plog@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1150 <print_pkt+0x40>
lea    0xea3(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <plog@plt>

LLVM IR (-O0):
%struct.canfd_frame = type { i32, i32*, i32 }
@.str = [11 x i8] c"Pkt: %02X#\00"
@.str.1 = [6 x i8] c"%02X \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @print_pkt(%struct.canfd_frame* byval(%struct.canfd_frame) align 8 %0) {
%2 = alloca i32
%3 = getelementptr inbounds %struct.canfd_frame, %struct.canfd_frame* %0, i32 0, i32 2
%4 = load i32, i32* %3
%5 = call i32 (i8*, ...) @plog(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %4)
store i32 0, i32* %2
br label %6
6: ; preds = %19, %1
%7 = load i32, i32* %2
%8 = getelementptr inbounds %struct.canfd_frame, %struct.canfd_frame* %0, i32 0, i32 0
%9 = load i32, i32* %8
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %22
11: ; preds = %6
%12 = getelementptr inbounds %struct.canfd_frame, %struct.canfd_frame* %0, i32 0, i32 1
%13 = load i32*, i32** %12
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
%17 = load i32, i32* %16
%18 = call i32 (i8*, ...) @plog(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %11
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %6
22: ; preds = %6
%23 = call i32 (i8*, ...) @plog(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.canfd_frame = type { i32, i32*, i32 }
@.str = [11 x i8] c"Pkt: %02X#\00"
@.str.1 = [6 x i8] c"%02X \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @print_pkt(%struct.canfd_frame* nocapture byval(%struct.canfd_frame) align 8 %0) {
%2 = getelementptr inbounds %struct.canfd_frame, %struct.canfd_frame* %0, i64 0, i32 2
%3 = load i32, i32* %2
%4 = tail call i32 (i8*, ...) @plog(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = getelementptr inbounds %struct.canfd_frame, %struct.canfd_frame* %0, i64 0, i32 0
%6 = load i32, i32* %5
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %19
8: ; preds = %1
%9 = getelementptr inbounds %struct.canfd_frame, %struct.canfd_frame* %0, i64 0, i32 1
%10 = load i32*, i32** %9
%11 = zext i32 %6 to i64
br label %12
12: ; preds = %8, %12
%13 = phi i64 [ 0, %8 ], [ %17, %12 ]
%14 = getelementptr inbounds i32, i32* %10, i64 %13
%15 = load i32, i32* %14
%16 = tail call i32 (i8*, ...) @plog(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = add nuw nsw i64 %13, 1
%18 = icmp eq i64 %17, %11
br i1 %18, label %19, label %12
19: ; preds = %12, %1
%20 = tail call i32 (i8*, ...) @plog(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}