#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*/ FATAL(char *, int /*<<< orphan*/, int /*<<< orphan*/,
                         int /*<<< orphan*/);
size_t intMin(int, int);
scalar_t__ strlen(char const *);
int /*<<< orphan*/ strncat(char *, char const *, unsigned int);
int /*<<< orphan*/ strncpy(char *, char const *, unsigned int);
char *szCat(const char *sz1, const char *sz2, const char *sz3,
            const char *sz4) {
  static char szBuf[700];
  if (!sz1)
    FATAL("szCat() : Invalid Arguments", 0, 0, 0);
  strncpy((char *)szBuf, sz1, (unsigned)intMin((int)strlen(sz1), 698));
  szBuf[intMin((int)strlen(sz1), 698)] = '\0';
  if (sz2)
    strncat((char *)szBuf, sz2,
            (unsigned)intMin((int)strlen(sz2) + 1,
                             698 - (int)strlen((char const *)szBuf)));
  if (sz3)
    strncat((char *)szBuf, sz3,
            (unsigned)intMin((int)strlen(sz3) + 1,
                             698 - (int)strlen((char const *)szBuf)));
  if (sz4)
    strncat((char *)szBuf, sz4,
            (unsigned)intMin((int)strlen(sz4) + 1,
                             698 - (int)strlen((char const *)szBuf)));
  return (char *)szBuf;
}


x86 assembly (clang, -O0):
<szCat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1185 <szCat+0x35>
lea    0xe86(%rip),%rdi
xor    %ecx,%ecx
mov    %ecx,%esi
mov    %ecx,%edx
call   1030 <FATAL@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
mov    $0x2ba,%esi
call   1070 <intMin@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
lea    0x2eb1(%rip),%rdi
call   1040 <strncpy@plt>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
mov    $0x2ba,%esi
call   1070 <intMin@plt>
mov    %rax,%rcx
lea    0x2e8d(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
cmpq   $0x0,-0x10(%rbp)
je     1226 <szCat+0xd6>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
lea    0x2e60(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x34(%rbp),%edi
mov    $0x2ba,%esi
sub    %eax,%esi
call   1070 <intMin@plt>
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
lea    0x2e3f(%rip),%rdi
call   1060 <strncat@plt>
cmpq   $0x0,-0x18(%rbp)
je     1275 <szCat+0x125>
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
lea    0x2e11(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x44(%rbp),%edi
mov    $0x2ba,%esi
sub    %eax,%esi
call   1070 <intMin@plt>
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
lea    0x2df0(%rip),%rdi
call   1060 <strncat@plt>
cmpq   $0x0,-0x20(%rbp)
je     12c4 <szCat+0x174>
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
lea    0x2dc2(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x54(%rbp),%edi
mov    $0x2ba,%esi
sub    %eax,%esi
call   1070 <intMin@plt>
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
lea    0x2da1(%rip),%rdi
call   1060 <strncat@plt>
lea    0x2d95(%rip),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<szCat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
test   %rdi,%rdi
jne    117e <szCat+0x2e>
lea    0xe8d(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <FATAL@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    $0x2ba,%ebp
mov    %eax,%edi
mov    $0x2ba,%esi
call   1070 <intMin@plt>
lea    0x2ec2(%rip),%r13
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
mov    $0x2ba,%esi
call   1070 <intMin@plt>
movb   $0x0,(%rax,%r13,1)
test   %r12,%r12
je     11fb <szCat+0xab>
mov    %r12,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%ebx
lea    0x2e85(%rip),%r13
mov    %r13,%rdi
call   1050 <strlen@plt>
sub    %eax,%ebp
mov    %ebx,%edi
mov    %ebp,%esi
call   1070 <intMin@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1060 <strncat@plt>
test   %r15,%r15
je     1235 <szCat+0xe5>
mov    %r15,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%ebx
lea    0x2e4e(%rip),%rbp
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    $0x2ba,%esi
sub    %eax,%esi
mov    %ebx,%edi
call   1070 <intMin@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1060 <strncat@plt>
test   %r14,%r14
je     126f <szCat+0x11f>
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%ebx
lea    0x2e14(%rip),%rbp
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    $0x2ba,%esi
sub    %eax,%esi
mov    %ebx,%edi
call   1070 <intMin@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1060 <strncat@plt>
lea    0x2dea(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@szCat.szBuf = internal global [700 x i8] zeroinitializer
@.str = [28 x i8] c"szCat() : Invalid Arguments\00"
define i8* @szCat(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %13, label %11
11: ; preds = %4
%12 = call i32 @FATAL(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 0, i32 0, i32 0)
br label %13
13: ; preds = %11, %4
%14 = load i8*, i8** %5
%15 = load i8*, i8** %5
%16 = call i64 @strlen(i8* %15)
%17 = trunc i64 %16 to i32
%18 = call i64 @intMin(i32 %17, i32 698)
%19 = trunc i64 %18 to i32
%20 = call i32 @strncpy(i8* getelementptr inbounds ([700 x i8], [700 x i8]* @szCat.szBuf, i64 0, i64 0), i8* %14, i32 %19)
%21 = load i8*, i8** %5
%22 = call i64 @strlen(i8* %21)
%23 = trunc i64 %22 to i32
%24 = call i64 @intMin(i32 %23, i32 698)
%25 = getelementptr inbounds [700 x i8], [700 x i8]* @szCat.szBuf, i64 0, i64 %24
store i8 0, i8* %25
%26 = load i8*, i8** %6
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %40
28: ; preds = %13
%29 = load i8*, i8** %6
%30 = load i8*, i8** %6
%31 = call i64 @strlen(i8* %30)
%32 = trunc i64 %31 to i32
%33 = add nsw i32 %32, 1
%34 = call i64 @strlen(i8* getelementptr inbounds ([700 x i8], [700 x i8]* @szCat.szBuf, i64 0, i64 0))
%35 = trunc i64 %34 to i32
%36 = sub nsw i32 698, %35
%37 = call i64 @intMin(i32 %33, i32 %36)
%38 = trunc i64 %37 to i32
%39 = call i32 @strncat(i8* getelementptr inbounds ([700 x i8], [700 x i8]* @szCat.szBuf, i64 0, i64 0), i8* %29, i32 %38)
br label %40
40: ; preds = %28, %13
%41 = load i8*, i8** %7
%42 = icmp ne i8* %41, null
br i1 %42, label %43, label %55
43: ; preds = %40
%44 = load i8*, i8** %7
%45 = load i8*, i8** %7
%46 = call i64 @strlen(i8* %45)
%47 = trunc i64 %46 to i32
%48 = add nsw i32 %47, 1
%49 = call i64 @strlen(i8* getelementptr inbounds ([700 x i8], [700 x i8]* @szCat.szBuf, i64 0, i64 0))
%50 = trunc i64 %49 to i32
%51 = sub nsw i32 698, %50
%52 = call i64 @intMin(i32 %48, i32 %51)
%53 = trunc i64 %52 to i32
%54 = call i32 @strncat(i8* getelementptr inbounds ([700 x i8], [700 x i8]* @szCat.szBuf, i64 0, i64 0), i8* %44, i32 %53)
br label %55
55: ; preds = %43, %40
%56 = load i8*, i8** %8
%57 = icmp ne i8* %56, null
br i1 %57, label %58, label %70
58: ; preds = %55
%59 = load i8*, i8** %8
%60 = load i8*, i8** %8
%61 = call i64 @strlen(i8* %60)
%62 = trunc i64 %61 to i32
%63 = add nsw i32 %62, 1
%64 = call i64 @strlen(i8* getelementptr inbounds ([700 x i8], [700 x i8]* @szCat.szBuf, i64 0, i64 0))
%65 = trunc i64 %64 to i32
%66 = sub nsw i32 698, %65
%67 = call i64 @intMin(i32 %63, i32 %66)
%68 = trunc i64 %67 to i32
%69 = call i32 @strncat(i8* getelementptr inbounds ([700 x i8], [700 x i8]* @szCat.szBuf, i64 0, i64 0), i8* %59, i32 %68)
br label %70
70: ; preds = %58, %55
ret i8* getelementptr inbounds ([700 x i8], [700 x i8]* @szCat.szBuf, i64 0, i64 0)
}

LLVM IR (-O2):
@szCat.szBuf = internal global [700 x i8] zeroinitializer
@.str = [28 x i8] c"szCat() : Invalid Arguments\00"
define i8* @szCat(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = icmp eq i8* %0, null
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i32 @FATAL(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 0, i32 0, i32 0)
br label %8
8: ; preds = %6, %4
%9 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%10 = trunc i64 %9 to i32
%11 = tail call i64 @intMin(i32 %10, i32 698)
%12 = trunc i64 %11 to i32
%13 = tail call i32 @strncpy(i8* getelementptr inbounds ([700 x i8], [700 x i8]* @szCat.szBuf, i64 0, i64 0), i8* %0, i32 %12)
%14 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%15 = trunc i64 %14 to i32
%16 = tail call i64 @intMin(i32 %15, i32 698)
%17 = getelementptr inbounds [700 x i8], [700 x i8]* @szCat.szBuf, i64 0, i64 %16
store i8 0, i8* %17
%18 = icmp eq i8* %1, null
br i1 %18, label %29, label %19
19: ; preds = %8
%20 = tail call i64 @strlen(i8* %1)
%21 = trunc i64 %20 to i32
%22 = add nsw i32 %21, 1
%23 = tail call i64 @strlen(i8* dereferenceable(1) getelementptr inbounds ([700 x i8], [700 x i8]* @szCat.szBuf, i64 0, i64 0))
%24 = trunc i64 %23 to i32
%25 = sub nsw i32 698, %24
%26 = tail call i64 @intMin(i32 %22, i32 %25)
%27 = trunc i64 %26 to i32
%28 = tail call i32 @strncat(i8* getelementptr inbounds ([700 x i8], [700 x i8]* @szCat.szBuf, i64 0, i64 0), i8* %1, i32 %27)
br label %29
29: ; preds = %19, %8
%30 = icmp eq i8* %2, null
br i1 %30, label %41, label %31
31: ; preds = %29
%32 = tail call i64 @strlen(i8* %2)
%33 = trunc i64 %32 to i32
%34 = add nsw i32 %33, 1
%35 = tail call i64 @strlen(i8* dereferenceable(1) getelementptr inbounds ([700 x i8], [700 x i8]* @szCat.szBuf, i64 0, i64 0))
%36 = trunc i64 %35 to i32
%37 = sub nsw i32 698, %36
%38 = tail call i64 @intMin(i32 %34, i32 %37)
%39 = trunc i64 %38 to i32
%40 = tail call i32 @strncat(i8* getelementptr inbounds ([700 x i8], [700 x i8]* @szCat.szBuf, i64 0, i64 0), i8* %2, i32 %39)
br label %41
41: ; preds = %31, %29
%42 = icmp eq i8* %3, null
br i1 %42, label %53, label %43
43: ; preds = %41
%44 = tail call i64 @strlen(i8* %3)
%45 = trunc i64 %44 to i32
%46 = add nsw i32 %45, 1
%47 = tail call i64 @strlen(i8* dereferenceable(1) getelementptr inbounds ([700 x i8], [700 x i8]* @szCat.szBuf, i64 0, i64 0))
%48 = trunc i64 %47 to i32
%49 = sub nsw i32 698, %48
%50 = tail call i64 @intMin(i32 %46, i32 %49)
%51 = trunc i64 %50 to i32
%52 = tail call i32 @strncat(i8* getelementptr inbounds ([700 x i8], [700 x i8]* @szCat.szBuf, i64 0, i64 0), i8* %3, i32 %51)
br label %53
53: ; preds = %43, %41
ret i8* getelementptr inbounds ([700 x i8], [700 x i8]* @szCat.szBuf, i64 0, i64 0)
}