#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*/ enable_irq_sff();
int /*<<< orphan*/ init_can(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ read_receive_buffer_extended();
int /*<<< orphan*/ reset_all_irqs();
int /*<<< orphan*/ self_reception_request();
int test_read_frame_extended(unsigned char *);
int /*<<< orphan*/ tx_request_command();
int /*<<< orphan*/ write_frame_basic(unsigned char *);
int /*<<< orphan*/ write_frame_extended(unsigned char *);
main() {
  unsigned char frame_basic[10] = {0xEA, 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;
  printf("************************************\n");
  printf("****** Test 1 **********************\n");
  printf("************************************\n");
  printf("****** Send frame basic ************\n");
  printf("************************************\n");
  printf("************************************\n\n");
  init_can("Basic", "normal");
  enable_irq_sff();
  write_frame_basic(frame_basic);
  tx_request_command();
  reset_all_irqs();
  printf("************************************\n");
  printf("****** Test 1 **********************\n");
  printf("************************************\n");
  printf("****** Send frame extended *********\n");
  printf("************************************\n");
  printf("************************************\n\n");
  init_can("Extended", "no_self_test");
  enable_irq_eff();
  write_frame_extended(frame_extended);
  tx_request_command();
  read_receive_buffer_extended();
  reset_all_irqs();
  printf("************************************\n");
  printf("****** Test 1 **********************\n");
  printf("************************************\n");
  printf("****** Self test mode **************\n");
  printf("****** extended ********************\n");
  printf("************************************\n\n");
  init_can("Extended", "self_test");
  enable_irq_eff();
  write_frame_extended(frame_extended);
  self_reception_request();
  read_receive_buffer_extended();
  if (test_read_frame_extended(frame_extended) == 1) {
    printf("Test Passed !!!\n");
  } else {
    printf("Test failed !!!\n");
  }
  reset_all_irqs();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe3a(%rip),%rax
mov    %rax,-0xe(%rbp)
mov    0xe37(%rip),%ax
mov    %ax,-0x6(%rbp)
mov    0xe2e(%rip),%rax
mov    %rax,-0x1b(%rbp)
mov    0xe2c(%rip),%eax
mov    %eax,-0x13(%rbp)
mov    0xe27(%rip),%al
mov    %al,-0xf(%rbp)
lea    0xe1e(%rip),%rdi
call   1030 <printf@plt>
lea    0xe38(%rip),%rdi
call   1030 <printf@plt>
lea    0xe06(%rip),%rdi
call   1030 <printf@plt>
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
lea    0xdee(%rip),%rdi
call   1030 <printf@plt>
lea    0xe54(%rip),%rdi
call   1030 <printf@plt>
lea    0xe6f(%rip),%rdi
lea    0xe6e(%rip),%rsi
call   10d0 <init_can@plt>
mov    $0x0,%al
call   1040 <enable_irq_sff@plt>
lea    -0xe(%rbp),%rdi
call   10b0 <write_frame_basic@plt>
mov    $0x0,%al
call   1080 <tx_request_command@plt>
mov    $0x0,%al
call   1050 <reset_all_irqs@plt>
lea    0xda5(%rip),%rdi
call   1030 <printf@plt>
lea    0xdbf(%rip),%rdi
call   1030 <printf@plt>
lea    0xd8d(%rip),%rdi
call   1030 <printf@plt>
lea    0xe27(%rip),%rdi
call   1030 <printf@plt>
lea    0xd75(%rip),%rdi
call   1030 <printf@plt>
lea    0xddb(%rip),%rdi
call   1030 <printf@plt>
lea    0xe29(%rip),%rdi
lea    0xe2b(%rip),%rsi
call   10d0 <init_can@plt>
mov    $0x0,%al
call   1090 <enable_irq_eff@plt>
lea    -0x1b(%rbp),%rdi
call   10c0 <write_frame_extended@plt>
mov    $0x0,%al
call   1080 <tx_request_command@plt>
mov    $0x0,%al
call   10a0 <read_receive_buffer_extended@plt>
mov    $0x0,%al
call   1050 <reset_all_irqs@plt>
lea    0xd25(%rip),%rdi
call   1030 <printf@plt>
lea    0xd3f(%rip),%rdi
call   1030 <printf@plt>
lea    0xd0d(%rip),%rdi
call   1030 <printf@plt>
lea    0xde3(%rip),%rdi
call   1030 <printf@plt>
lea    0xdfd(%rip),%rdi
call   1030 <printf@plt>
lea    0xd5b(%rip),%rdi
call   1030 <printf@plt>
lea    0xda9(%rip),%rdi
lea    0xdae(%rip),%rsi
call   10d0 <init_can@plt>
mov    $0x0,%al
call   1090 <enable_irq_eff@plt>
lea    -0x1b(%rbp),%rdi
call   10c0 <write_frame_extended@plt>
mov    $0x0,%al
call   1070 <self_reception_request@plt>
mov    $0x0,%al
call   10a0 <read_receive_buffer_extended@plt>
lea    -0x1b(%rbp),%rdi
call   1060 <test_read_frame_extended@plt>
cmp    $0x1,%eax
jne    1387 <main+0x1d7>
lea    0xdc8(%rip),%rdi
call   1030 <printf@plt>
jmp    1393 <main+0x1e3>
lea    0xdc8(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <reset_all_irqs@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
movabs $0xbc9a7856341228ea,%rax
78 9a bc
mov    %rax,(%rsp)
movw   $0xf0de,0x8(%rsp)
movabs $0xf0debc9a78563412,%rax
bc de f0
mov    %rax,0x15(%rsp)
movabs $0x5634123012b0a688,%rax
12 34 56
mov    %rax,0x10(%rsp)
lea    0xeb2(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xe7e(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xe1d(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xee7(%rip),%r15
mov    %r15,%rdi
call   1030 <puts@plt>
lea    0xdd7(%rip),%rdi
lea    0xdd6(%rip),%rsi
call   10d0 <init_can@plt>
xor    %eax,%eax
call   1040 <enable_irq_sff@plt>
mov    %rsp,%rdi
call   10b0 <write_frame_basic@plt>
xor    %eax,%eax
call   1080 <tx_request_command@plt>
xor    %eax,%eax
call   1050 <reset_all_irqs@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xdd7(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
lea    0xd80(%rip),%r13
lea    0xd82(%rip),%rsi
mov    %r13,%rdi
call   10d0 <init_can@plt>
xor    %eax,%eax
call   1090 <enable_irq_eff@plt>
lea    0x10(%rsp),%r12
mov    %r12,%rdi
call   10c0 <write_frame_extended@plt>
xor    %eax,%eax
call   1080 <tx_request_command@plt>
xor    %eax,%eax
call   10a0 <read_receive_buffer_extended@plt>
xor    %eax,%eax
call   1050 <reset_all_irqs@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xdd3(%rip),%rdi
call   1030 <puts@plt>
lea    0xdec(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
lea    0xd15(%rip),%rsi
mov    %r13,%rdi
call   10d0 <init_can@plt>
xor    %eax,%eax
call   1090 <enable_irq_eff@plt>
mov    %r12,%rdi
call   10c0 <write_frame_extended@plt>
xor    %eax,%eax
call   1070 <self_reception_request@plt>
xor    %eax,%eax
call   10a0 <read_receive_buffer_extended@plt>
mov    %r12,%rdi
call   1060 <test_read_frame_extended@plt>
cmp    $0x1,%eax
lea    0xdfc(%rip),%rax
lea    0xde5(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <reset_all_irqs@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.frame_basic = [10 x i8] c"\EA(\124Vx\9A\BC\DE\F0"
@__const.main.frame_extended = [13 x i8] c"\88\A6\B0\120\124Vx\9A\BC\DE\F0"
@.str = [38 x i8] c"************************************\0A\00"
@.str.1 = [38 x i8] c"****** Test 1 **********************\0A\00"
@.str.2 = [38 x i8] c"****** Send frame basic ************\0A\00"
@.str.3 = [39 x i8] c"************************************\0A\0A\00"
@.str.4 = [6 x i8] c"Basic\00"
@.str.5 = [7 x i8] c"normal\00"
@.str.6 = [38 x i8] c"****** Send frame extended *********\0A\00"
@.str.7 = [9 x i8] c"Extended\00"
@.str.8 = [13 x i8] c"no_self_test\00"
@.str.9 = [38 x i8] c"****** Self test mode **************\0A\00"
@.str.10 = [38 x i8] c"****** extended ********************\0A\00"
@.str.11 = [10 x i8] c"self_test\00"
@.str.12 = [17 x i8] c"Test Passed !!!\0A\00"
@.str.13 = [17 x i8] c"Test failed !!!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca [13 x i8]
%4 = alloca i8
store i32 0, i32* %1
%5 = bitcast [10 x i8]* %2 to i8*
%6 = bitcast [13 x i8]* %3 to i8*
%7 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @init_can(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 (...) @enable_irq_sff()
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%16 = call i32 @write_frame_basic(i8* %15)
%17 = call i32 (...) @tx_request_command()
%18 = call i32 (...) @reset_all_irqs()
%19 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%24 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 @init_can(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%26 = call i32 (...) @enable_irq_eff()
%27 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%28 = call i32 @write_frame_extended(i8* %27)
%29 = call i32 (...) @tx_request_command()
%30 = call i32 (...) @read_receive_buffer_extended()
%31 = call i32 (...) @reset_all_irqs()
%32 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%33 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%34 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%35 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0))
%36 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0))
%37 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%38 = call i32 @init_can(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
%39 = call i32 (...) @enable_irq_eff()
%40 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%41 = call i32 @write_frame_extended(i8* %40)
%42 = call i32 (...) @self_reception_request()
%43 = call i32 (...) @read_receive_buffer_extended()
%44 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%45 = call i32 @test_read_frame_extended(i8* %44)
%46 = icmp eq i32 %45, 1
br i1 %46, label %47, label %49
47: ; preds = %0
%48 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0))
br label %51
49: ; preds = %0
%50 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0))
br label %51
51: ; preds = %49, %47
%52 = call i32 (...) @reset_all_irqs()
%53 = load i32, i32* %1
ret i32 %53
}

LLVM IR (-O2):
@__const.main.frame_basic = [10 x i8] c"\EA(\124Vx\9A\BC\DE\F0"
@__const.main.frame_extended = [13 x i8] c"\88\A6\B0\120\124Vx\9A\BC\DE\F0"
@.str.4 = [6 x i8] c"Basic\00"
@.str.5 = [7 x i8] c"normal\00"
@.str.7 = [9 x i8] c"Extended\00"
@.str.8 = [13 x i8] c"no_self_test\00"
@.str.11 = [10 x i8] c"self_test\00"
@str.16 = [37 x i8] c"****** Send frame basic ************\00"
@str.22 = [37 x i8] c"****** Send frame extended *********\00"
@str.26 = [37 x i8] c"****** Test 1 **********************\00"
@str.27 = [37 x i8] c"************************************\00"
@str.28 = [37 x i8] c"****** Self test mode **************\00"
@str.29 = [37 x i8] c"****** extended ********************\00"
@str.30 = [38 x i8] c"************************************\0A\00"
@str.31 = [16 x i8] c"Test failed !!!\00"
@str.32 = [16 x i8] c"Test Passed !!!\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [13 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.27, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.26, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.27, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.16, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.27, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.30, i64 0, i64 0))
%11 = tail call i32 @init_can(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%12 = tail call i32 (...) @enable_irq_sff()
%13 = call i32 @write_frame_basic(i8* %3)
%14 = call i32 (...) @tx_request_command()
%15 = call i32 (...) @reset_all_irqs()
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.27, i64 0, i64 0))
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.26, i64 0, i64 0))
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.27, i64 0, i64 0))
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.22, i64 0, i64 0))
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.27, i64 0, i64 0))
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.30, i64 0, i64 0))
%22 = call i32 @init_can(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%23 = call i32 (...) @enable_irq_eff()
%24 = call i32 @write_frame_extended(i8* %4)
%25 = call i32 (...) @tx_request_command()
%26 = call i32 (...) @read_receive_buffer_extended()
%27 = call i32 (...) @reset_all_irqs()
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.27, i64 0, i64 0))
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.26, i64 0, i64 0))
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.27, i64 0, i64 0))
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.28, i64 0, i64 0))
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.29, i64 0, i64 0))
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.30, i64 0, i64 0))
%34 = call i32 @init_can(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
%35 = call i32 (...) @enable_irq_eff()
%36 = call i32 @write_frame_extended(i8* %4)
%37 = call i32 (...) @self_reception_request()
%38 = call i32 (...) @read_receive_buffer_extended()
%39 = call i32 @test_read_frame_extended(i8* %4)
%40 = icmp eq i32 %39, 1
%41 = select i1 %40, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @str.32, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @str.31, i64 0, i64 0)
%42 = call i32 @puts(i8* dereferenceable(1) %41)
%43 = call i32 (...) @reset_all_irqs()
ret i32 0
}