#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*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fwrite(char *, size_t, int, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
size_t strcat2(char **, char const *, char const *, char const *, char const *,
               int /*<<< orphan*/ *);
int main(void) {
  char *s = NULL;
  size_t len;
  const char *ip = "127.0.0.1";
  const char *port = "3306";
  const char *name = "user";
  const char *password = "password";
  len = strcat2(&s, ip, port, name, password, NULL);
  if (s == NULL)
    return -1;
  fwrite(s, len, 1, stdout);
  fputc('\n', stdout);
  if (s != NULL)
    free(s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xea2(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xea1(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe9b(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe95(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%r9d
call   1040 <strcat2@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11bc <main+0x7c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1205 <main+0xc5>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2e15(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   1060 <fwrite@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1050 <fputc@plt>
cmpq   $0x0,-0x10(%rbp)
je     11fe <main+0xbe>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movq   $0x0,(%rsp)
lea    0xead(%rip),%rsi
lea    0xeb0(%rip),%rdx
lea    0xeae(%rip),%rcx
lea    0xeac(%rip),%r8
xor    %ebx,%ebx
mov    %rsp,%rdi
xor    %r9d,%r9d
call   1040 <strcat2@plt>
mov    (%rsp),%rdi
test   %rdi,%rdi
je     11b2 <main+0x72>
mov    0x2e5b(%rip),%r14
mov    (%r14),%ecx
mov    %rax,%rsi
mov    $0x1,%edx
call   1060 <fwrite@plt>
mov    (%r14),%esi
mov    $0xa,%edi
call   1050 <fputc@plt>
mov    (%rsp),%rdi
test   %rdi,%rdi
je     11b7 <main+0x77>
call   1030 <free@plt>
jmp    11b7 <main+0x77>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"127.0.0.1\00"
@.str.1 = [5 x i8] c"3306\00"
@.str.2 = [5 x i8] c"user\00"
@.str.3 = [9 x i8] c"password\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i32 0, i32* %1
store i8* null, i8** %2
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8** %7
%8 = load i8*, i8** %4
%9 = load i8*, i8** %5
%10 = load i8*, i8** %6
%11 = load i8*, i8** %7
%12 = call i64 @strcat2(i8** %2, i8* %8, i8* %9, i8* %10, i8* %11, i32* null)
store i64 %12, i64* %3
%13 = load i8*, i8** %2
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %16
15: ; preds = %0
store i32 -1, i32* %1
br label %29
16: ; preds = %0
%17 = load i8*, i8** %2
%18 = load i64, i64* %3
%19 = load i32, i32* @stdout
%20 = call i32 @fwrite(i8* %17, i64 %18, i32 1, i32 %19)
%21 = load i32, i32* @stdout
%22 = call i32 @fputc(i8 signext 10, i32 %21)
%23 = load i8*, i8** %2
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %28
25: ; preds = %16
%26 = load i8*, i8** %2
%27 = call i32 @free(i8* %26)
br label %28
28: ; preds = %25, %16
store i32 0, i32* %1
br label %29
29: ; preds = %28, %15
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [10 x i8] c"127.0.0.1\00"
@.str.1 = [5 x i8] c"3306\00"
@.str.2 = [5 x i8] c"user\00"
@.str.3 = [9 x i8] c"password\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%3 = call i64 @strcat2(i8** %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* null)
%4 = load i8*, i8** %1
%5 = icmp eq i8* %4, null
br i1 %5, label %15, label %6
6: ; preds = %0
%7 = load i32, i32* @stdout
%8 = call i32 @fwrite(i8* %4, i64 %3, i32 1, i32 %7)
%9 = load i32, i32* @stdout
%10 = call i32 @fputc(i8 signext 10, i32 %9)
%11 = load i8*, i8** %1
%12 = icmp eq i8* %11, null
br i1 %12, label %15, label %13
13: ; preds = %6
%14 = call i32 @free(i8* %11)
br label %15
15: ; preds = %6, %13, %0
%16 = phi i32 [ -1, %0 ], [ 0, %13 ], [ 0, %6 ]
ret i32 %16
}