#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*/ fprintf(int /*<<< orphan*/, char *, char const *);
scalar_t__ openPort(char const *);
int /*<<< orphan*/ stderr;
int TemmaConnect(const char *device) {
  fprintf(stderr, "Connecting to device %s\n", device);
  if (openPort(device) < 0) {
    fprintf(stderr, "Error connecting to device %s\n", device);
    return -1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<TemmaConnect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2ead(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xec0(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <openPort@plt>
cmp    $0x0,%rax
jge    117d <TemmaConnect+0x5d>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xead(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1184 <TemmaConnect+0x64>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TemmaConnect>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2eb2(%rip),%r14
mov    (%r14),%edi
lea    0xec8(%rip),%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <openPort@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jns    1169 <TemmaConnect+0x49>
mov    (%r14),%edi
lea    0xebd(%rip),%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"Connecting to device %s\0A\00"
@.str.1 = [31 x i8] c"Error connecting to device %s\0A\00"
define i32 @TemmaConnect(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i32, i32* @stderr
%5 = load i8*, i8** %3
%6 = call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = load i8*, i8** %3
%8 = call i64 @openPort(i8* %7)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %3
%13 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %12)
store i32 -1, i32* %2
br label %15
14: ; preds = %1
store i32 0, i32* %2
br label %15
15: ; preds = %14, %10
%16 = load i32, i32* %2
ret i32 %16
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"Connecting to device %s\0A\00"
@.str.1 = [31 x i8] c"Error connecting to device %s\0A\00"
define i32 @TemmaConnect(i8* %0) {
%2 = load i32, i32* @stderr
%3 = tail call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = tail call i64 @openPort(i8* %0)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %9
9: ; preds = %1, %6
%10 = phi i32 [ -1, %6 ], [ 0, %1 ]
ret i32 %10
}