#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*/ strcat(char *, char const *);
const char *build_conninfo(const char *db, const char *username,
                           const char *password, const char *host,
                           const char *port) {
  static char conninfo[1024];
  conninfo[0] = '\0';
  strcat(conninfo, "dbname='");
  strcat(conninfo, db);
  strcat(conninfo, "'");
  if (username) {
    strcat(conninfo, " user='");
    strcat(conninfo, username);
    strcat(conninfo, "'");
  }
  if (password) {
    strcat(conninfo, " password='");
    strcat(conninfo, password);
    strcat(conninfo, "'");
  }
  if (host) {
    strcat(conninfo, " host='");
    strcat(conninfo, host);
    strcat(conninfo, "'");
  }
  if (port) {
    strcat(conninfo, " port='");
    strcat(conninfo, port);
    strcat(conninfo, "'");
  }
  return conninfo;
}


x86 assembly (clang, -O0):
<build_conninfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movb   $0x0,0x2f0d(%rip)
lea    0x2f06(%rip),%rdi
lea    0xebf(%rip),%rsi
call   1030 <strcat@plt>
mov    -0x8(%rbp),%rsi
lea    0x2eef(%rip),%rdi
call   1030 <strcat@plt>
lea    0x2ee3(%rip),%rdi
lea    0xeb7(%rip),%rsi
call   1030 <strcat@plt>
cmpq   $0x0,-0x10(%rbp)
je     11aa <build_conninfo+0x9a>
lea    0x2ec5(%rip),%rdi
lea    0xe87(%rip),%rsi
call   1030 <strcat@plt>
mov    -0x10(%rbp),%rsi
lea    0x2eae(%rip),%rdi
call   1030 <strcat@plt>
lea    0x2ea2(%rip),%rdi
lea    0xe76(%rip),%rsi
call   1030 <strcat@plt>
cmpq   $0x0,-0x18(%rbp)
je     11eb <build_conninfo+0xdb>
lea    0x2e84(%rip),%rdi
lea    0xe4e(%rip),%rsi
call   1030 <strcat@plt>
mov    -0x18(%rbp),%rsi
lea    0x2e6d(%rip),%rdi
call   1030 <strcat@plt>
lea    0x2e61(%rip),%rdi
lea    0xe35(%rip),%rsi
call   1030 <strcat@plt>
cmpq   $0x0,-0x20(%rbp)
je     122c <build_conninfo+0x11c>
lea    0x2e43(%rip),%rdi
lea    0xe19(%rip),%rsi
call   1030 <strcat@plt>
mov    -0x20(%rbp),%rsi
lea    0x2e2c(%rip),%rdi
call   1030 <strcat@plt>
lea    0x2e20(%rip),%rdi
lea    0xdf4(%rip),%rsi
call   1030 <strcat@plt>
cmpq   $0x0,-0x28(%rbp)
je     126d <build_conninfo+0x15d>
lea    0x2e02(%rip),%rdi
lea    0xde0(%rip),%rsi
call   1030 <strcat@plt>
mov    -0x28(%rbp),%rsi
lea    0x2deb(%rip),%rdi
call   1030 <strcat@plt>
lea    0x2ddf(%rip),%rdi
lea    0xdb3(%rip),%rsi
call   1030 <strcat@plt>
lea    0x2dcc(%rip),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_conninfo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%rbx
movb   $0x0,0x2f0f(%rip)
lea    0x2f08(%rip),%rbp
lea    0xec1(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <strcat@plt>
lea    0xec2(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcat@plt>
test   %r13,%r13
je     1196 <build_conninfo+0x86>
lea    0x2ed3(%rip),%rbx
lea    0xe95(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcat@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1030 <strcat@plt>
lea    0xe8d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcat@plt>
test   %r12,%r12
je     11cb <build_conninfo+0xbb>
lea    0x2e9e(%rip),%rbx
lea    0xe68(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <strcat@plt>
lea    0xe58(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcat@plt>
test   %r15,%r15
je     1200 <build_conninfo+0xf0>
lea    0x2e69(%rip),%rbx
lea    0xe3f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strcat@plt>
lea    0xe23(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcat@plt>
test   %r14,%r14
je     1235 <build_conninfo+0x125>
lea    0x2e34(%rip),%rbx
lea    0xe12(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcat@plt>
lea    0xdee(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcat@plt>
lea    0x2e04(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@build_conninfo.conninfo = internal global [1024 x i8] zeroinitializer
@.str = [9 x i8] c"dbname='\00"
@.str.1 = [2 x i8] c"'\00"
@.str.2 = [8 x i8] c" user='\00"
@.str.3 = [12 x i8] c" password='\00"
@.str.4 = [8 x i8] c" host='\00"
@.str.5 = [8 x i8] c" port='\00"
define i8* @build_conninfo(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
store i8 0, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0)
%11 = call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%12 = load i8*, i8** %6
%13 = call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* %12)
%14 = call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = load i8*, i8** %7
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %22
17: ; preds = %5
%18 = call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%19 = load i8*, i8** %7
%20 = call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* %19)
%21 = call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %17, %5
%23 = load i8*, i8** %8
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%27 = load i8*, i8** %8
%28 = call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* %27)
%29 = call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %25, %22
%31 = load i8*, i8** %9
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%35 = load i8*, i8** %9
%36 = call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* %35)
%37 = call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %38
38: ; preds = %33, %30
%39 = load i8*, i8** %10
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %46
41: ; preds = %38
%42 = call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%43 = load i8*, i8** %10
%44 = call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* %43)
%45 = call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %46
46: ; preds = %41, %38
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0)
}

LLVM IR (-O2):
@build_conninfo.conninfo = internal global [1024 x i8] zeroinitializer
@.str = [9 x i8] c"dbname='\00"
@.str.1 = [2 x i8] c"'\00"
@.str.2 = [8 x i8] c" user='\00"
@.str.3 = [12 x i8] c" password='\00"
@.str.4 = [8 x i8] c" host='\00"
@.str.5 = [8 x i8] c" port='\00"
define i8* @build_conninfo(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
store i8 0, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0)
%6 = tail call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* %0)
%8 = tail call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i8* %1, null
br i1 %9, label %14, label %10
10: ; preds = %5
%11 = tail call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* %1)
%13 = tail call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %10, %5
%15 = icmp eq i8* %2, null
br i1 %15, label %20, label %16
16: ; preds = %14
%17 = tail call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%18 = tail call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* %2)
%19 = tail call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %16, %14
%21 = icmp eq i8* %3, null
br i1 %21, label %26, label %22
22: ; preds = %20
%23 = tail call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%24 = tail call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* %3)
%25 = tail call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %22, %20
%27 = icmp eq i8* %4, null
br i1 %27, label %32, label %28
28: ; preds = %26
%29 = tail call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%30 = tail call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* %4)
%31 = tail call i32 @strcat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %28, %26
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @build_conninfo.conninfo, i64 0, i64 0)
}