#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 */
typedef int /*<<< orphan*/ szValue;

/* Variables and functions */
int MakeDecNumber(char *, int, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
int MakeEqStr(const char *szTailingDelim, int mult, char *szLinearCT,
              int nLen_szLinearCT, int *bOverflow) {
  int len = 0, len_delim;
  char szValue[16];
  if (!szTailingDelim || !*szTailingDelim || *bOverflow)
    return 0;
  if (mult != 1) {
    len = MakeDecNumber(szValue, (int)sizeof(szValue), NULL, mult);
  }
  len_delim = strlen(szTailingDelim);
  if (len_delim + len < nLen_szLinearCT) {
    if (len > 0) {
      memcpy(szLinearCT, szValue, len);
    }
    strcpy(szLinearCT + len, szTailingDelim);
    return len + len_delim;
  }
  *bOverflow |= 1;
  return 0;
}


x86 assembly (clang, -O0):
<MakeEqStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1186 <MakeEqStr+0x46>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1186 <MakeEqStr+0x46>
mov    -0x30(%rbp),%rax
cmpl   $0x0,(%rax)
je     1192 <MakeEqStr+0x52>
movl   $0x0,-0x4(%rbp)
jmp    121d <MakeEqStr+0xdd>
cmpl   $0x1,-0x14(%rbp)
je     11b4 <MakeEqStr+0x74>
lea    -0x50(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    $0x10,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <MakeDecNumber@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
add    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    120b <MakeEqStr+0xcb>
cmpl   $0x0,-0x34(%rbp)
jle    11e9 <MakeEqStr+0xa9>
mov    -0x20(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x20(%rbp),%rdi
movslq -0x34(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x34(%rbp),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    121d <MakeEqStr+0xdd>
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
or     $0x1,%ecx
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MakeEqStr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %ebp,%ebp
test   %rdi,%rdi
je     11c6 <MakeEqStr+0x86>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     11c6 <MakeEqStr+0x86>
mov    %r8,%r15
cmpl   $0x0,(%r8)
jne    11c6 <MakeEqStr+0x86>
mov    %ecx,%r12d
mov    %rdx,%r14
mov    %esi,%ecx
xor    %r13d,%r13d
cmp    $0x1,%esi
je     1188 <MakeEqStr+0x48>
mov    %rsp,%rdi
mov    $0x10,%esi
xor    %edx,%edx
call   1060 <MakeDecNumber@plt>
mov    %eax,%r13d
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
add    %r13d,%ebp
cmp    %r12d,%ebp
jge    11c0 <MakeEqStr+0x80>
test   %r13d,%r13d
jle    11ad <MakeEqStr+0x6d>
mov    %rsp,%rsi
mov    %r14,%rdi
mov    %r13d,%edx
call   1050 <memcpy@plt>
movslq %r13d,%rax
add    %rax,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
jmp    11c6 <MakeEqStr+0x86>
orb    $0x1,(%r15)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @MakeEqStr(i8* %0, i32 %1, i8* %2, i32 %3, i32* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca [16 x i8]
store i8* %0, i8** %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i32* %4, i32** %11
store i32 0, i32* %12
%15 = load i8*, i8** %7
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %25
17: ; preds = %5
%18 = load i8*, i8** %7
%19 = load i8, i8* %18
%20 = icmp ne i8 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i32*, i32** %11
%23 = load i32, i32* %22
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %21, %17, %5
store i32 0, i32* %6
br label %63
26: ; preds = %21
%27 = load i32, i32* %8
%28 = icmp ne i32 %27, 1
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = getelementptr inbounds [16 x i8], [16 x i8]* %14, i64 0, i64 0
%31 = load i32, i32* %8
%32 = call i32 @MakeDecNumber(i8* %30, i32 16, i32* null, i32 %31)
store i32 %32, i32* %12
br label %33
33: ; preds = %29, %26
%34 = load i8*, i8** %7
%35 = call i32 @strlen(i8* %34)
store i32 %35, i32* %13
%36 = load i32, i32* %13
%37 = load i32, i32* %12
%38 = add nsw i32 %36, %37
%39 = load i32, i32* %10
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %59
41: ; preds = %33
%42 = load i32, i32* %12
%43 = icmp sgt i32 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %41
%45 = load i8*, i8** %9
%46 = getelementptr inbounds [16 x i8], [16 x i8]* %14, i64 0, i64 0
%47 = load i32, i32* %12
%48 = call i32 @memcpy(i8* %45, i8* %46, i32 %47)
br label %49
49: ; preds = %44, %41
%50 = load i8*, i8** %9
%51 = load i32, i32* %12
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i8*, i8** %7
%55 = call i32 @strcpy(i8* %53, i8* %54)
%56 = load i32, i32* %12
%57 = load i32, i32* %13
%58 = add nsw i32 %56, %57
store i32 %58, i32* %6
br label %63
59: ; preds = %33
%60 = load i32*, i32** %11
%61 = load i32, i32* %60
%62 = or i32 %61, 1
store i32 %62, i32* %60
store i32 0, i32* %6
br label %63
63: ; preds = %59, %49, %25
%64 = load i32, i32* %6
ret i32 %64
}

LLVM IR (-O2):
define i32 @MakeEqStr(i8* %0, i32 %1, i8* %2, i32 %3, i32* nocapture %4) {
%6 = alloca [16 x i8]
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%8 = icmp eq i8* %0, null
br i1 %8, label %35, label %9
9: ; preds = %5
%10 = load i8, i8* %0
%11 = icmp eq i8 %10, 0
br i1 %11, label %35, label %12
12: ; preds = %9
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %35
15: ; preds = %12
%16 = icmp eq i32 %1, 1
br i1 %16, label %19, label %17
17: ; preds = %15
%18 = call i32 @MakeDecNumber(i8* %7, i32 16, i32* null, i32 %1)
br label %19
19: ; preds = %17, %15
%20 = phi i32 [ %18, %17 ], [ 0, %15 ]
%21 = call i32 @strlen(i8* %0)
%22 = add nsw i32 %21, %20
%23 = icmp slt i32 %22, %3
br i1 %23, label %24, label %32
24: ; preds = %19
%25 = icmp sgt i32 %20, 0
br i1 %25, label %26, label %28
26: ; preds = %24
%27 = call i32 @memcpy(i8* %2, i8* %7, i32 %20)
br label %28
28: ; preds = %26, %24
%29 = sext i32 %20 to i64
%30 = getelementptr inbounds i8, i8* %2, i64 %29
%31 = call i32 @strcpy(i8* %30, i8* %0)
br label %35
32: ; preds = %19
%33 = load i32, i32* %4
%34 = or i32 %33, 1
store i32 %34, i32* %4
br label %35
35: ; preds = %5, %9, %12, %32, %28
%36 = phi i32 [ %22, %28 ], [ 0, %32 ], [ 0, %12 ], [ 0, %9 ], [ 0, %5 ]
ret i32 %36
}