#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 EE_bluetooth_connect();
int /*<<< orphan*/ EE_bluetooth_connect_dev(char *);
int /*<<< orphan*/ EE_bluetooth_free();
int /*<<< orphan*/ EE_bluetooth_init();
int /*<<< orphan*/ EE_bluetooth_inquiry();
char *ee_elm327_get_version();
int /*<<< orphan*/ ee_elm327_init();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ vehicleScan();
int main(int argc, char **argv) {
  EE_bluetooth_init();
  if (!EE_bluetooth_inquiry()) {
    printf("No device found\n");
    EE_bluetooth_connect_dev("00:0D:18:3A:73:9D");
    ee_elm327_init();
    printf("Elm327 Version: %s\n", ee_elm327_get_version());
    for (;;) {
      vehicleScan();
    }
  } else {
    if (EE_bluetooth_connect() == -1) {
      printf("Error during Bluetooth connection!\n");
    } else {
      ee_elm327_init();
      printf("Elm327 Version: %s\n", ee_elm327_get_version());
      for (;;) {
        vehicleScan();
      }
    }
  }
  EE_bluetooth_free();
  printf("Bye!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1090 <EE_bluetooth_init@plt>
mov    $0x0,%al
call   10a0 <EE_bluetooth_inquiry@plt>
cmp    $0x0,%eax
jne    1202 <main+0x72>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe3f(%rip),%rdi
call   1040 <EE_bluetooth_connect_dev@plt>
mov    $0x0,%al
call   1060 <ee_elm327_init@plt>
mov    $0x0,%al
call   1080 <ee_elm327_get_version@plt>
mov    %rax,%rsi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   10b0 <vehicleScan@plt>
jmp    11f6 <main+0x66>
mov    $0x0,%al
call   1070 <EE_bluetooth_connect@plt>
cmp    $0xffffffff,%eax
jne    1225 <main+0x95>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1250 <main+0xc0>
mov    $0x0,%al
call   1060 <ee_elm327_init@plt>
mov    $0x0,%al
call   1080 <ee_elm327_get_version@plt>
mov    %rax,%rsi
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   10b0 <vehicleScan@plt>
jmp    1244 <main+0xb4>
jmp    1255 <main+0xc5>
mov    $0x0,%al
call   1030 <EE_bluetooth_free@plt>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   10a0 <EE_bluetooth_init@plt>
xor    %eax,%eax
call   10b0 <EE_bluetooth_inquiry@plt>
test   %eax,%eax
je     11e9 <main+0x49>
xor    %eax,%eax
call   1080 <EE_bluetooth_connect@plt>
cmp    $0xffffffff,%eax
je     1229 <main+0x89>
xor    %eax,%eax
call   1070 <ee_elm327_init@plt>
xor    %eax,%eax
call   1090 <ee_elm327_get_version@plt>
lea    0xe3e(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xchg   %ax,%ax
xor    %eax,%eax
call   10c0 <vehicleScan@plt>
jmp    11e0 <main+0x40>
lea    0xe36(%rip),%rdi
call   1040 <puts@plt>
lea    0xe04(%rip),%rdi
call   1050 <EE_bluetooth_connect_dev@plt>
xor    %eax,%eax
call   1070 <ee_elm327_init@plt>
xor    %eax,%eax
call   1090 <ee_elm327_get_version@plt>
lea    0xdfc(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   10c0 <vehicleScan@plt>
jmp    1220 <main+0x80>
lea    0xe06(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <EE_bluetooth_free@plt>
lea    0xe16(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"No device found\0A\00"
@.str.1 = [18 x i8] c"00:0D:18:3A:73:9D\00"
@.str.2 = [20 x i8] c"Elm327 Version: %s\0A\00"
@.str.3 = [36 x i8] c"Error during Bluetooth connection!\0A\00"
@.str.4 = [6 x i8] c"Bye!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 (...) @EE_bluetooth_init()
%7 = call i32 (...) @EE_bluetooth_inquiry()
%8 = icmp ne i32 %7, 0
br i1 %8, label %17, label %9
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @EE_bluetooth_connect_dev(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (...) @ee_elm327_init()
%13 = call i8* (...) @ee_elm327_get_version()
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %15, %9
%16 = call i32 (...) @vehicleScan()
br label %15
17: ; preds = %2
%18 = call i32 (...) @EE_bluetooth_connect()
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
br label %28
22: ; preds = %17
%23 = call i32 (...) @ee_elm327_init()
%24 = call i8* (...) @ee_elm327_get_version()
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %26, %22
%27 = call i32 (...) @vehicleScan()
br label %26
28: ; preds = %20
br label %29
29: ; preds = %28
%30 = call i32 (...) @EE_bluetooth_free()
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [18 x i8] c"00:0D:18:3A:73:9D\00"
@.str.2 = [20 x i8] c"Elm327 Version: %s\0A\00"
@str = [16 x i8] c"No device found\00"
@str.5 = [35 x i8] c"Error during Bluetooth connection!\00"
@str.6 = [5 x i8] c"Bye!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @EE_bluetooth_init()
%4 = tail call i32 (...) @EE_bluetooth_inquiry()
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %14
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @EE_bluetooth_connect_dev(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 (...) @ee_elm327_init()
%10 = tail call i8* (...) @ee_elm327_get_version()
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %12, %6
%13 = tail call i32 (...) @vehicleScan()
br label %12
14: ; preds = %2
%15 = tail call i32 (...) @EE_bluetooth_connect()
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.5, i64 0, i64 0))
%19 = tail call i32 (...) @EE_bluetooth_free()
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.6, i64 0, i64 0))
ret i32 0
21: ; preds = %14
%22 = tail call i32 (...) @ee_elm327_init()
%23 = tail call i8* (...) @ee_elm327_get_version()
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %25, %21
%26 = tail call i32 (...) @vehicleScan()
br label %25
}