#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 */
typedef int uint8_t;
typedef int /*<<< orphan*/ data3;
typedef int /*<<< orphan*/ data2;
typedef int /*<<< orphan*/ data1;

/* Variables and functions */
int /*<<< orphan*/ bcm4751_read_dump(int);
int /*<<< orphan*/ bcm4751_serial_write(int, int *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
void bcm4751_switch_protocol(int fd) {
  uint8_t data1[] = {0xff, 0x00, 0xfd, 0x40, 0x00, 0x00, 0xe6, 0xfc};
  uint8_t data2[] = {0xfe, 0x00, 0xfd, 0x6f, 0xfe, 0x00,
                     0x00, 0x00, 0x00, 0x00, 0xb2, 0xfc};
  uint8_t data3[] = {0xfe, 0x00, 0xfd, 0x6f, 0x3a, 0x01,
                     0x00, 0x00, 0x00, 0x00, 0x34, 0xfc};
  sleep(1);
  printf("Sending unknown bytes!\n");
  bcm4751_serial_write(fd, data1, sizeof(data1), NULL);
  bcm4751_serial_write(fd, data2, sizeof(data2), NULL);
  bcm4751_serial_write(fd, data3, sizeof(data3), NULL);
  bcm4751_read_dump(fd);
}


x86 assembly (clang, -O0):
<bcm4751_switch_protocol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x4(%rbp)
mov    0xe8b(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe88(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe85(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe82(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1040 <memset@plt>
movl   $0xfe,-0x60(%rbp)
movl   $0xfd,-0x58(%rbp)
movl   $0x6f,-0x54(%rbp)
movl   $0xfe,-0x50(%rbp)
movl   $0xb2,-0x38(%rbp)
movl   $0xfc,-0x34(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xe3e(%rip),%rsi
mov    $0x30,%edx
call   1050 <memcpy@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x20,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1060 <bcm4751_serial_write@plt>
mov    -0x4(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x30,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1060 <bcm4751_serial_write@plt>
mov    -0x4(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    $0x30,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1060 <bcm4751_serial_write@plt>
mov    -0x4(%rbp),%edi
call   1070 <bcm4751_read_dump@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bcm4751_switch_protocol>:
push   %rbx
sub    $0x80,%rsp
mov    %edi,%ebx
movaps 0xebf(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xea3(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movl   $0xfe,(%rsp)
movabs $0x6f000000fd,%rax
mov    %rax,0x8(%rsp)
movl   $0xfe,0x10(%rsp)
movabs $0xfc000000b2,%rax
mov    %rax,0x28(%rsp)
movaps 0xe99(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xe7d(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe61(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
mov    $0x1,%edi
call   1060 <sleep@plt>
lea    0xe7b(%rip),%rdi
call   1030 <puts@plt>
lea    0x30(%rsp),%rsi
mov    %ebx,%edi
mov    $0x20,%edx
xor    %ecx,%ecx
call   1040 <bcm4751_serial_write@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x30,%edx
xor    %ecx,%ecx
call   1040 <bcm4751_serial_write@plt>
lea    0x50(%rsp),%rsi
mov    %ebx,%edi
mov    $0x30,%edx
xor    %ecx,%ecx
call   1040 <bcm4751_serial_write@plt>
mov    %ebx,%edi
call   1050 <bcm4751_read_dump@plt>
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.bcm4751_switch_protocol.data1 = [8 x i32] [i32 255, i32 0, i32 253, i32 64, i32 0, i32 0, i32 230, i32 252]
@__const.bcm4751_switch_protocol.data3 = [12 x i32] [i32 254, i32 0, i32 253, i32 111, i32 58, i32 1, i32 0, i32 0, i32 0, i32 0, i32 52, i32 252]
@.str = [24 x i8] c"Sending unknown bytes!\0A\00"
define void @bcm4751_switch_protocol(i32 %0) {
%2 = alloca i32
%3 = alloca [8 x i32]
%4 = alloca [12 x i32]
%5 = alloca [12 x i32]
store i32 %0, i32* %2
%6 = bitcast [8 x i32]* %3 to i8*
%7 = bitcast [12 x i32]* %4 to i8*
%8 = bitcast i8* %7 to [12 x i32]*
%9 = getelementptr inbounds [12 x i32], [12 x i32]* %8, i32 0, i32 0
store i32 254, i32* %9
%10 = getelementptr inbounds [12 x i32], [12 x i32]* %8, i32 0, i32 2
store i32 253, i32* %10
%11 = getelementptr inbounds [12 x i32], [12 x i32]* %8, i32 0, i32 3
store i32 111, i32* %11
%12 = getelementptr inbounds [12 x i32], [12 x i32]* %8, i32 0, i32 4
store i32 254, i32* %12
%13 = getelementptr inbounds [12 x i32], [12 x i32]* %8, i32 0, i32 10
store i32 178, i32* %13
%14 = getelementptr inbounds [12 x i32], [12 x i32]* %8, i32 0, i32 11
store i32 252, i32* %14
%15 = bitcast [12 x i32]* %5 to i8*
%16 = call i32 @sleep(i32 1)
%17 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* %2
%19 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 0
%20 = call i32 @bcm4751_serial_write(i32 %18, i32* %19, i32 32, i32* null)
%21 = load i32, i32* %2
%22 = getelementptr inbounds [12 x i32], [12 x i32]* %4, i64 0, i64 0
%23 = call i32 @bcm4751_serial_write(i32 %21, i32* %22, i32 48, i32* null)
%24 = load i32, i32* %2
%25 = getelementptr inbounds [12 x i32], [12 x i32]* %5, i64 0, i64 0
%26 = call i32 @bcm4751_serial_write(i32 %24, i32* %25, i32 48, i32* null)
%27 = load i32, i32* %2
%28 = call i32 @bcm4751_read_dump(i32 %27)
ret void
}

LLVM IR (-O2):
@__const.bcm4751_switch_protocol.data1 = [8 x i32] [i32 255, i32 0, i32 253, i32 64, i32 0, i32 0, i32 230, i32 252]
@__const.bcm4751_switch_protocol.data3 = [12 x i32] [i32 254, i32 0, i32 253, i32 111, i32 58, i32 1, i32 0, i32 0, i32 0, i32 0, i32 52, i32 252]
@str = [23 x i8] c"Sending unknown bytes!\00"
define void @bcm4751_switch_protocol(i32 %0) {
%2 = alloca [8 x i32]
%3 = alloca [12 x i32]
%4 = alloca [12 x i32]
%5 = bitcast [8 x i32]* %2 to i8*
%6 = bitcast [12 x i32]* %3 to i8*
%7 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 0
store i32 254, i32* %7
%8 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 2
store i32 253, i32* %8
%9 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 3
store i32 111, i32* %9
%10 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 4
store i32 254, i32* %10
%11 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 10
store i32 178, i32* %11
%12 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 11
store i32 252, i32* %12
%13 = bitcast [12 x i32]* %4 to i8*
%14 = tail call i32 @sleep(i32 1)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%16 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%17 = call i32 @bcm4751_serial_write(i32 %0, i32* %16, i32 32, i32* null)
%18 = call i32 @bcm4751_serial_write(i32 %0, i32* %7, i32 48, i32* null)
%19 = getelementptr inbounds [12 x i32], [12 x i32]* %4, i64 0, i64 0
%20 = call i32 @bcm4751_serial_write(i32 %0, i32* %19, i32 48, i32* null)
%21 = call i32 @bcm4751_read_dump(i32 %0)
ret void
}