#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*/ EE_bluetooth_sendS(char *);
int EE_elm327_check_response_no_timeout(char *);
int /*<<< orphan*/ printf(char *);
int ee_elm327_set_protocol(char protocol) {
  char protoStr[3];
  printf("Changing protocol\n");
  protoStr[0] = protocol;
  protoStr[1] = '\r';
  protoStr[2] = '\0';
  EE_bluetooth_sendS("AT SP ");
  EE_bluetooth_sendS(protoStr);
  return EE_elm327_check_response_no_timeout("OK\r\r");
}


x86 assembly (clang, -O0):
<ee_elm327_set_protocol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1(%rbp),%al
mov    %al,-0x4(%rbp)
movb   $0xd,-0x3(%rbp)
movb   $0x0,-0x2(%rbp)
lea    0xeb4(%rip),%rdi
call   1040 <EE_bluetooth_sendS@plt>
lea    -0x4(%rbp),%rdi
call   1040 <EE_bluetooth_sendS@plt>
lea    0xea6(%rip),%rdi
call   1050 <EE_elm327_check_response_no_timeout@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ee_elm327_set_protocol>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
mov    %bl,0xd(%rsp)
movw   $0xd,0xe(%rsp)
lea    0xeab(%rip),%rdi
call   1040 <EE_bluetooth_sendS@plt>
lea    0xd(%rsp),%rdi
call   1040 <EE_bluetooth_sendS@plt>
lea    0xe9c(%rip),%rdi
call   1050 <EE_elm327_check_response_no_timeout@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Changing protocol\0A\00"
@.str.1 = [7 x i8] c"AT SP \00"
@.str.2 = [5 x i8] c"OK\0D\0D\00"
define i32 @ee_elm327_set_protocol(i8 signext %0) {
%2 = alloca i8
%3 = alloca [3 x i8]
store i8 %0, i8* %2
%4 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%5 = load i8, i8* %2
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
store i8 %5, i8* %6
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 1
store i8 13, i8* %7
%8 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
store i8 0, i8* %8
%9 = call i32 @EE_bluetooth_sendS(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%11 = call i32 @EE_bluetooth_sendS(i8* %10)
%12 = call i32 @EE_elm327_check_response_no_timeout(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
ret i32 %12
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"AT SP \00"
@.str.2 = [5 x i8] c"OK\0D\0D\00"
@str = [18 x i8] c"Changing protocol\00"
define i32 @ee_elm327_set_protocol(i8 signext %0) {
%2 = alloca [3 x i8]
%3 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
store i8 %0, i8* %3
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 1
store i8 13, i8* %5
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 2
store i8 0, i8* %6
%7 = tail call i32 @EE_bluetooth_sendS(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @EE_bluetooth_sendS(i8* %3)
%9 = call i32 @EE_elm327_check_response_no_timeout(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
ret i32 %9
}