#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 */

/* Variables and functions */
int /*<<< orphan*/ enable_irq_eff();
int /*<<< orphan*/ init_can(char *, char *);
int /*<<< orphan*/ kill_time(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read_receive_buffer_extended();
int /*<<< orphan*/ release_receive_buffer();
main() {
  int i;
  unsigned char frame_basic0[10] = {0xEA, 0x28, 0x12, 0x34, 0x56,
                                    0x78, 0x9A, 0xBC, 0xDE, 0xF0};
  unsigned char frame_basic1[10] = {0xEB, 0x28, 0x12, 0x34, 0x56,
                                    0x78, 0x9A, 0xBC, 0xDE, 0xF0};
  unsigned char frame_basic2[10] = {0xEC, 0x28, 0x12, 0x34, 0x56,
                                    0x78, 0x9A, 0xBC, 0xDE, 0xF0};
  unsigned char frame_basic3[10] = {0xED, 0x28, 0x12, 0x34, 0x56,
                                    0x78, 0x9A, 0xBC, 0xDE, 0xF0};
  unsigned char frame_extended[13] = {0x88, 0xA6, 0xB0, 0x12, 0x30, 0x12, 0x34,
                                      0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0};
  unsigned char r_val;
  init_can("Extended", "normal");
  enable_irq_eff();
  release_receive_buffer();
  release_receive_buffer();
  release_receive_buffer();
  release_receive_buffer();
  release_receive_buffer();
  release_receive_buffer();
  release_receive_buffer();
  release_receive_buffer();
  release_receive_buffer();
  release_receive_buffer();
  release_receive_buffer();
  release_receive_buffer();
  release_receive_buffer();
  release_receive_buffer();
  release_receive_buffer();
  release_receive_buffer();
  printf("interrupt register 0x%X \n", *((unsigned char *)(0xfffc0003)));
  while (1) {
    if ((*((unsigned char *)(0xfffc0003)) & 0x01) == 0) {
      kill_time(4000000);
      printf("No data!\n");
    } else {
      read_receive_buffer_extended();
      release_receive_buffer();
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe8a(%rip),%rax
mov    %rax,-0x12(%rbp)
mov    0xe87(%rip),%ax
mov    %ax,-0xa(%rbp)
mov    0xe7e(%rip),%rax
mov    %rax,-0x1c(%rbp)
mov    0xe7b(%rip),%ax
mov    %ax,-0x14(%rbp)
mov    0xe72(%rip),%rax
mov    %rax,-0x26(%rbp)
mov    0xe6f(%rip),%ax
mov    %ax,-0x1e(%rbp)
mov    0xe66(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe63(%rip),%ax
mov    %ax,-0x28(%rbp)
mov    0xe5a(%rip),%rax
mov    %rax,-0x3d(%rbp)
mov    0xe58(%rip),%eax
mov    %eax,-0x35(%rbp)
mov    0xe53(%rip),%al
mov    %al,-0x31(%rbp)
lea    0xe4a(%rip),%rdi
lea    0xe4c(%rip),%rsi
call   1080 <init_can@plt>
mov    $0x0,%al
call   1050 <enable_irq_eff@plt>
mov    $0x0,%al
call   1070 <release_receive_buffer@plt>
mov    $0x0,%al
call   1070 <release_receive_buffer@plt>
mov    $0x0,%al
call   1070 <release_receive_buffer@plt>
mov    $0x0,%al
call   1070 <release_receive_buffer@plt>
mov    $0x0,%al
call   1070 <release_receive_buffer@plt>
mov    $0x0,%al
call   1070 <release_receive_buffer@plt>
mov    $0x0,%al
call   1070 <release_receive_buffer@plt>
mov    $0x0,%al
call   1070 <release_receive_buffer@plt>
mov    $0x0,%al
call   1070 <release_receive_buffer@plt>
mov    $0x0,%al
call   1070 <release_receive_buffer@plt>
mov    $0x0,%al
call   1070 <release_receive_buffer@plt>
mov    $0x0,%al
call   1070 <release_receive_buffer@plt>
mov    $0x0,%al
call   1070 <release_receive_buffer@plt>
mov    $0x0,%al
call   1070 <release_receive_buffer@plt>
mov    $0x0,%al
call   1070 <release_receive_buffer@plt>
mov    $0x0,%al
call   1070 <release_receive_buffer@plt>
mov    $0xfffc0003,%eax
movzbl (%rax),%esi
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xfffc0003,%eax
movzbl (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    12b5 <main+0x155>
mov    $0x3d0900,%edi
call   1030 <kill_time@plt>
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12c3 <main+0x163>
mov    $0x0,%al
call   1060 <read_receive_buffer_extended@plt>
mov    $0x0,%al
call   1070 <release_receive_buffer@plt>
jmp    1284 <main+0x124>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0xfffc0003,%r14d
lea    0xe7f(%rip),%rdi
lea    0xe81(%rip),%rsi
call   1090 <init_can@plt>
xor    %eax,%eax
call   1060 <enable_irq_eff@plt>
xor    %eax,%eax
call   1080 <release_receive_buffer@plt>
xor    %eax,%eax
call   1080 <release_receive_buffer@plt>
xor    %eax,%eax
call   1080 <release_receive_buffer@plt>
xor    %eax,%eax
call   1080 <release_receive_buffer@plt>
xor    %eax,%eax
call   1080 <release_receive_buffer@plt>
xor    %eax,%eax
call   1080 <release_receive_buffer@plt>
xor    %eax,%eax
call   1080 <release_receive_buffer@plt>
xor    %eax,%eax
call   1080 <release_receive_buffer@plt>
xor    %eax,%eax
call   1080 <release_receive_buffer@plt>
xor    %eax,%eax
call   1080 <release_receive_buffer@plt>
xor    %eax,%eax
call   1080 <release_receive_buffer@plt>
xor    %eax,%eax
call   1080 <release_receive_buffer@plt>
xor    %eax,%eax
call   1080 <release_receive_buffer@plt>
xor    %eax,%eax
call   1080 <release_receive_buffer@plt>
xor    %eax,%eax
call   1080 <release_receive_buffer@plt>
xor    %eax,%eax
call   1080 <release_receive_buffer@plt>
movzbl (%r14),%esi
lea    0xe01(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe0d(%rip),%rbx
testb  $0x1,(%r14)
je     1244 <main+0xd4>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1070 <read_receive_buffer_extended@plt>
xor    %eax,%eax
call   1080 <release_receive_buffer@plt>
testb  $0x1,(%r14)
jne    1230 <main+0xc0>
mov    $0x3d0900,%edi
call   1030 <kill_time@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
testb  $0x1,(%r14)
je     1244 <main+0xd4>
jmp    1230 <main+0xc0>

LLVM IR (-O0):
@__const.main.frame_basic0 = [10 x i8] c"\EA(\124Vx\9A\BC\DE\F0"
@__const.main.frame_basic1 = [10 x i8] c"\EB(\124Vx\9A\BC\DE\F0"
@__const.main.frame_basic2 = [10 x i8] c"\EC(\124Vx\9A\BC\DE\F0"
@__const.main.frame_basic3 = [10 x i8] c"\ED(\124Vx\9A\BC\DE\F0"
@__const.main.frame_extended = [13 x i8] c"\88\A6\B0\120\124Vx\9A\BC\DE\F0"
@.str = [9 x i8] c"Extended\00"
@.str.1 = [7 x i8] c"normal\00"
@.str.2 = [26 x i8] c"interrupt register 0x%X \0A\00"
@.str.3 = [10 x i8] c"No data!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x i8]
%4 = alloca [10 x i8]
%5 = alloca [10 x i8]
%6 = alloca [10 x i8]
%7 = alloca [13 x i8]
%8 = alloca i8
store i32 0, i32* %1
%9 = bitcast [10 x i8]* %3 to i8*
%10 = bitcast [10 x i8]* %4 to i8*
%11 = bitcast [10 x i8]* %5 to i8*
%12 = bitcast [10 x i8]* %6 to i8*
%13 = bitcast [13 x i8]* %7 to i8*
%14 = call i32 @init_can(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 (...) @enable_irq_eff()
%16 = call i32 (...) @release_receive_buffer()
%17 = call i32 (...) @release_receive_buffer()
%18 = call i32 (...) @release_receive_buffer()
%19 = call i32 (...) @release_receive_buffer()
%20 = call i32 (...) @release_receive_buffer()
%21 = call i32 (...) @release_receive_buffer()
%22 = call i32 (...) @release_receive_buffer()
%23 = call i32 (...) @release_receive_buffer()
%24 = call i32 (...) @release_receive_buffer()
%25 = call i32 (...) @release_receive_buffer()
%26 = call i32 (...) @release_receive_buffer()
%27 = call i32 (...) @release_receive_buffer()
%28 = call i32 (...) @release_receive_buffer()
%29 = call i32 (...) @release_receive_buffer()
%30 = call i32 (...) @release_receive_buffer()
%31 = call i32 (...) @release_receive_buffer()
%32 = load i8, i8* inttoptr (i64 4294705155 to i8*)
%33 = zext i8 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %0, %46
%36 = load i8, i8* inttoptr (i64 4294705155 to i8*)
%37 = zext i8 %36 to i32
%38 = and i32 %37, 1
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %35
%41 = call i32 @kill_time(i32 4000000)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %46
43: ; preds = %35
%44 = call i32 (...) @read_receive_buffer_extended()
%45 = call i32 (...) @release_receive_buffer()
br label %46
46: ; preds = %43, %40
br label %35
}

LLVM IR (-O2):
@.str = [9 x i8] c"Extended\00"
@.str.1 = [7 x i8] c"normal\00"
@.str.2 = [26 x i8] c"interrupt register 0x%X \0A\00"
@str = [9 x i8] c"No data!\00"
define i32 @main() {
%1 = tail call i32 @init_can(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 (...) @enable_irq_eff()
%3 = tail call i32 (...) @release_receive_buffer()
%4 = tail call i32 (...) @release_receive_buffer()
%5 = tail call i32 (...) @release_receive_buffer()
%6 = tail call i32 (...) @release_receive_buffer()
%7 = tail call i32 (...) @release_receive_buffer()
%8 = tail call i32 (...) @release_receive_buffer()
%9 = tail call i32 (...) @release_receive_buffer()
%10 = tail call i32 (...) @release_receive_buffer()
%11 = tail call i32 (...) @release_receive_buffer()
%12 = tail call i32 (...) @release_receive_buffer()
%13 = tail call i32 (...) @release_receive_buffer()
%14 = tail call i32 (...) @release_receive_buffer()
%15 = tail call i32 (...) @release_receive_buffer()
%16 = tail call i32 (...) @release_receive_buffer()
%17 = tail call i32 (...) @release_receive_buffer()
%18 = tail call i32 (...) @release_receive_buffer()
%19 = load i8, i8* inttoptr (i64 4294705155 to i8*)
%20 = zext i8 %19 to i32
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %32, %0
%23 = load i8, i8* inttoptr (i64 4294705155 to i8*)
%24 = and i8 %23, 1
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = tail call i32 @kill_time(i32 4000000)
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %32
29: ; preds = %22
%30 = tail call i32 (...) @read_receive_buffer_extended()
%31 = tail call i32 (...) @release_receive_buffer()
br label %32
32: ; preds = %29, %26
br label %22
}