#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;
  int can_dlc;
  int *data;
};

/* Variables and functions */
int CAN_RTR_FLAG;
int /*<<< orphan*/ printf(char *, ...);
void print_frame(struct can_frame *frame) {
  int i;
  printf("%04x: ", frame->can_id);
  if (frame->can_id & CAN_RTR_FLAG) {
    printf("remote request");
  } else {
    printf("[%d]", frame->can_dlc);
    for (i = 0; i < frame->can_dlc; i++)
      printf(" %02x", frame->data[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_frame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    0x2ea3(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     115b <print_frame+0x4b>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b7 <print_frame+0xa7>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    0x4(%rcx),%eax
jge    11b2 <print_frame+0xa2>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1177 <print_frame+0x67>
jmp    11b7 <print_frame+0xa7>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_frame>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
mov    (%rdi),%esi
lea    0xecf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2ea1(%rip),%rax
mov    (%rax),%eax
test   %eax,(%r15)
je     1156 <print_frame+0x36>
lea    0xeba(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    119e <print_frame+0x7e>
mov    0x4(%r15),%esi
lea    0xeb5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0x4(%r15)
jle    119e <print_frame+0x7e>
lea    0xea5(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    0x8(%r15),%rax
mov    (%rax,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
movslq 0x4(%r15),%rax
cmp    %rax,%rbx
jl     1180 <print_frame+0x60>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

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

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