#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 */
unsigned long OCDB_PGConnect(char *, int, char *);
int /*<<< orphan*/ OCDB_PGFinish(unsigned long);
int add_conn_lists(int, char *, unsigned long);
int OCDBConnect(int dbtype, char *conninfo, char *connname, int autocommit,
                char *cencoding) {
  int retval = 0;
  unsigned long connaddr;
  connaddr = OCDB_PGConnect(conninfo, autocommit, cencoding);
  if (connaddr == (-1)) {
    return (-1);
  }
  retval = add_conn_lists(dbtype, connname, connaddr);
  if (retval == -1) {
    OCDB_PGFinish(connaddr);
    return -1;
  };
  return retval;
}


x86 assembly (clang, -O0):
<OCDBConnect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1050 <OCDB_PGConnect@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0xffffffffffffffff,-0x38(%rbp)
jne    117c <OCDBConnect+0x4c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b4 <OCDBConnect+0x84>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1030 <add_conn_lists@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    11ae <OCDBConnect+0x7e>
mov    -0x38(%rbp),%rdi
call   1040 <OCDB_PGFinish@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b4 <OCDBConnect+0x84>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OCDBConnect>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %edi,%ebp
mov    %rsi,%rdi
mov    %ecx,%esi
mov    %r8,%rdx
call   1050 <OCDB_PGConnect@plt>
mov    %rax,%rbx
mov    $0xffffffff,%eax
cmp    $0xffffffffffffffff,%rbx
je     1173 <OCDBConnect+0x43>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <add_conn_lists@plt>
cmp    $0xffffffff,%eax
jne    1173 <OCDBConnect+0x43>
mov    %rbx,%rdi
call   1040 <OCDB_PGFinish@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @OCDBConnect(i32 %0, i8* %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i64
store i32 %0, i32* %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i32 0, i32* %12
%14 = load i8*, i8** %8
%15 = load i32, i32* %10
%16 = load i8*, i8** %11
%17 = call i64 @OCDB_PGConnect(i8* %14, i32 %15, i8* %16)
store i64 %17, i64* %13
%18 = load i64, i64* %13
%19 = icmp eq i64 %18, -1
br i1 %19, label %20, label %21
20: ; preds = %5
store i32 -1, i32* %6
br label %33
21: ; preds = %5
%22 = load i32, i32* %7
%23 = load i8*, i8** %9
%24 = load i64, i64* %13
%25 = call i32 @add_conn_lists(i32 %22, i8* %23, i64 %24)
store i32 %25, i32* %12
%26 = load i32, i32* %12
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %31
28: ; preds = %21
%29 = load i64, i64* %13
%30 = call i32 @OCDB_PGFinish(i64 %29)
store i32 -1, i32* %6
br label %33
31: ; preds = %21
%32 = load i32, i32* %12
store i32 %32, i32* %6
br label %33
33: ; preds = %31, %28, %20
%34 = load i32, i32* %6
ret i32 %34
}

LLVM IR (-O2):
define i32 @OCDBConnect(i32 %0, i8* %1, i8* %2, i32 %3, i8* %4) {
%6 = tail call i64 @OCDB_PGConnect(i8* %1, i32 %3, i8* %4)
%7 = icmp eq i64 %6, -1
br i1 %7, label %13, label %8
8: ; preds = %5
%9 = tail call i32 @add_conn_lists(i32 %0, i8* %2, i64 %6)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @OCDB_PGFinish(i64 %6)
br label %13
13: ; preds = %8, %5, %11
%14 = phi i32 [ -1, %11 ], [ -1, %5 ], [ %9, %8 ]
ret i32 %14
}