#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*/ exit(int);
char *get_firmware_version();
int /*<<< orphan*/ nxt_bluetooth_done();
int nxt_bluetooth_initialize(char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int ret;
  char *bla;
  ret = nxt_bluetooth_initialize("00:16:53:03:96:6B");
  if (ret) {
    printf("Failed to initialize bluetooth\n");
    exit(1);
  }
  bla = get_firmware_version();
  printf("Return is >%s<\n", bla);
  nxt_bluetooth_done();
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1050 <nxt_bluetooth_initialize@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1190 <main+0x40>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    $0x0,%al
call   1030 <get_firmware_version@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <nxt_bluetooth_done@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xe98(%rip),%rdi
call   1060 <nxt_bluetooth_initialize@plt>
test   %eax,%eax
jne    1194 <main+0x34>
xor    %eax,%eax
call   1040 <get_firmware_version@plt>
lea    0xe93(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <nxt_bluetooth_done@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"00:16:53:03:96:6B\00"
@.str.1 = [32 x i8] c"Failed to initialize bluetooth\0A\00"
@.str.2 = [16 x i8] c"Return is >%s<\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
store i32 0, i32* %1
%4 = call i32 @nxt_bluetooth_initialize(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %0
%11 = call i8* (...) @get_firmware_version()
store i8* %11, i8** %3
%12 = load i8*, i8** %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = call i32 (...) @nxt_bluetooth_done()
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"00:16:53:03:96:6B\00"
@.str.2 = [16 x i8] c"Return is >%s<\0A\00"
@str = [31 x i8] c"Failed to initialize bluetooth\00"
define i32 @main() {
%1 = tail call i32 @nxt_bluetooth_initialize(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32 %1, 0
br i1 %2, label %6, label %3
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %0
%7 = tail call i8* (...) @get_firmware_version()
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%9 = tail call i32 (...) @nxt_bluetooth_done()
ret i32 0
}