#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*/ ErrLog(int, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
void OpsLogStart(int sock, char *name, int argc, char *argv[]) {
  char buffer[4096];
  int i;
  sprintf(buffer, "PROGRAM START->");
  for (i = 0; i < argc; i++) {
    if (i != 0)
      strcat(buffer, " ");
    strcat(buffer, argv[i]);
  }
  ErrLog(sock, name, buffer);
}


x86 assembly (clang, -O0):
<OpsLogStart>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x1020(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1050 <sprintf@plt>
movl   $0x0,-0x1024(%rbp)
mov    -0x1024(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c4 <OpsLogStart+0x94>
cmpl   $0x0,-0x1024(%rbp)
je     1195 <OpsLogStart+0x65>
lea    -0x1020(%rbp),%rdi
lea    0xe80(%rip),%rsi
call   1040 <strcat@plt>
lea    -0x1020(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x1024(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <strcat@plt>
mov    -0x1024(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1024(%rbp)
jmp    1166 <OpsLogStart+0x36>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x1020(%rbp),%rdx
call   1030 <ErrLog@plt>
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OpsLogStart>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
mov    %rsi,0x8(%rsp)
mov    %edi,%r15d
movups 0xec0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
test   %edx,%edx
jle    11a1 <OpsLogStart+0x81>
mov    %rcx,%r13
mov    %edx,%ebp
mov    (%rcx),%rsi
lea    0x10(%rsp),%rdi
call   1040 <strcat@plt>
cmp    $0x1,%ebp
je     11a1 <OpsLogStart+0x81>
mov    %ebp,%ebx
mov    $0x1,%r14d
lea    0xea1(%rip),%r12
lea    0x10(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rdi
mov    %r12,%rsi
call   1040 <strcat@plt>
mov    0x0(%r13,%r14,8),%rsi
mov    %rbp,%rdi
call   1040 <strcat@plt>
add    $0x1,%r14
cmp    %r14,%rbx
jne    1180 <OpsLogStart+0x60>
lea    0x10(%rsp),%rdx
mov    %r15d,%edi
mov    0x8(%rsp),%rsi
call   1030 <ErrLog@plt>
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"PROGRAM START->\00"
@.str.1 = [2 x i8] c" \00"
define void @OpsLogStart(i32 %0, i8* %1, i32 %2, i8** %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8**
%9 = alloca [4096 x i8]
%10 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8** %3, i8*** %8
%11 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%12 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %10
br label %13
13: ; preds = %31, %4
%14 = load i32, i32* %10
%15 = load i32, i32* %7
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %34
17: ; preds = %13
%18 = load i32, i32* %10
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%22 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %20, %17
%24 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%25 = load i8**, i8*** %8
%26 = load i32, i32* %10
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 @strcat(i8* %24, i8* %29)
br label %31
31: ; preds = %23
%32 = load i32, i32* %10
%33 = add nsw i32 %32, 1
store i32 %33, i32* %10
br label %13
34: ; preds = %13
%35 = load i32, i32* %5
%36 = load i8*, i8** %6
%37 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%38 = call i32 @ErrLog(i32 %35, i8* %36, i8* %37)
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"PROGRAM START->\00"
@.str.1 = [2 x i8] c" \00"
define void @OpsLogStart(i32 %0, i8* %1, i32 %2, i8** nocapture %3) {
%5 = alloca [4096 x i8]
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%7 = icmp sgt i32 %2, 0
br i1 %7, label %8, label %21
8: ; preds = %4
%9 = zext i32 %2 to i64
%10 = load i8*, i8** %3
%11 = call i32 @strcat(i8* %6, i8* %10)
%12 = icmp eq i32 %2, 1
br i1 %12, label %21, label %13
13: ; preds = %8, %13
%14 = phi i64 [ %19, %13 ], [ 1, %8 ]
%15 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = getelementptr inbounds i8*, i8** %3, i64 %14
%17 = load i8*, i8** %16
%18 = call i32 @strcat(i8* %6, i8* %17)
%19 = add nuw nsw i64 %14, 1
%20 = icmp eq i64 %19, %9
br i1 %20, label %21, label %13
21: ; preds = %13, %8, %4
%22 = call i32 @ErrLog(i32 %0, i8* %1, i8* %6)
ret void
}