#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 */
scalar_t__ dxl_initialize(int, int);
int /*<<< orphan*/ dxl_write_word(int, int, int);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *);
int init_connection(int baudrate, int speed, int deviceIndex) {
  if (dxl_initialize(deviceIndex, baudrate) == 0) {
    printf("Failed to open USB2Dynamixel!\n");
    printf("Press Enter key to terminate...\n");
    getchar();
    return 0;
  } else
    printf("Succeed to open USB2Dynamixel!\n");
  dxl_write_word((254), 32, speed);
  return 1;
}


x86 assembly (clang, -O0):
<init_connection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <dxl_initialize@plt>
cmp    $0x0,%rax
jne    1191 <init_connection+0x51>
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
movl   $0x0,-0x4(%rbp)
jmp    11b6 <init_connection+0x76>
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%edx
mov    $0xfe,%edi
mov    $0x20,%esi
call   1050 <dxl_write_word@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_connection>:
push   %rbx
mov    %esi,%ebx
mov    %edi,%esi
mov    %edx,%edi
call   1040 <dxl_initialize@plt>
test   %rax,%rax
je     1175 <init_connection+0x35>
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
mov    $0xfe,%edi
mov    $0x20,%esi
mov    %ebx,%edx
call   1050 <dxl_write_word@plt>
mov    $0x1,%ebx
jmp    1196 <init_connection+0x56>
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Failed to open USB2Dynamixel!\0A\00"
@.str.1 = [33 x i8] c"Press Enter key to terminate...\0A\00"
@.str.2 = [32 x i8] c"Succeed to open USB2Dynamixel!\0A\00"
define i32 @init_connection(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i32, i32* %7
%9 = load i32, i32* %5
%10 = call i64 @dxl_initialize(i32 %8, i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 (...) @getchar()
store i32 0, i32* %4
br label %21
16: ; preds = %3
%17 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16
%19 = load i32, i32* %6
%20 = call i32 @dxl_write_word(i32 254, i32 32, i32 %19)
store i32 1, i32* %4
br label %21
21: ; preds = %18, %12
%22 = load i32, i32* %4
ret i32 %22
}

LLVM IR (-O2):
@str = [31 x i8] c"Succeed to open USB2Dynamixel!\00"
@str.3 = [30 x i8] c"Failed to open USB2Dynamixel!\00"
@str.4 = [32 x i8] c"Press Enter key to terminate...\00"
define i32 @init_connection(i32 %0, i32 %1, i32 %2) {
%4 = tail call i64 @dxl_initialize(i32 %2, i32 %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.3, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.4, i64 0, i64 0))
%9 = tail call i32 (...) @getchar()
br label %13
10: ; preds = %3
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @dxl_write_word(i32 254, i32 32, i32 %1)
br label %13
13: ; preds = %10, %6
%14 = phi i32 [ 0, %6 ], [ 1, %10 ]
ret i32 %14
}