#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*/ printf(char *);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
void hello(int iArgCount, char *iArgs[], char *szReturnBuffer, int iSize) {
  int i = 0;
  for (i = 0; i < iArgCount; i++) {
    if ((strlen(szReturnBuffer) + strlen(iArgs[i])) < iSize) {
      strcat(szReturnBuffer, iArgs[i]);
      strcat(szReturnBuffer, " ");
    } else {
      printf("Error: exceeded buffer size\n");
      break;
    }
  }
}


x86 assembly (clang, -O0):
<hello>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11db <hello+0xab>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
cmp    -0x1c(%rbp),%eax
jge    11b7 <hello+0x87>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xe53(%rip),%rsi
call   1050 <strcat@plt>
jmp    11c8 <hello+0x98>
lea    0xe44(%rip),%rdi
call   1040 <printf@plt>
jmp    11db <hello+0xab>
jmp    11cd <hello+0x9d>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1154 <hello+0x24>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hello>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    118e <hello+0x5e>
mov    %ecx,%r14d
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %edi,%r13d
xor    %r15d,%r15d
xchg   %ax,%ax
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    (%r12,%r15,8),%rdi
call   1040 <strlen@plt>
add    %ebp,%eax
cmp    %r14d,%eax
jge    119d <hello+0x6d>
mov    (%r12,%r15,8),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %rbx,%rdi
lea    0xe80(%rip),%rsi
call   1050 <strcat@plt>
add    $0x1,%r15
cmp    %r15,%r13
jne    1150 <hello+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe5e(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

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

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@str = [28 x i8] c"Error: exceeded buffer size\00"
define void @hello(i32 %0, i8** nocapture %1, i8* %2, i32 %3) {
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %24
6: ; preds = %4
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %16
%9 = phi i64 [ 0, %6 ], [ %20, %16 ]
%10 = tail call i32 @strlen(i8* %2)
%11 = getelementptr inbounds i8*, i8** %1, i64 %9
%12 = load i8*, i8** %11
%13 = tail call i32 @strlen(i8* %12)
%14 = add nsw i32 %13, %10
%15 = icmp slt i32 %14, %3
br i1 %15, label %16, label %22
16: ; preds = %8
%17 = load i8*, i8** %11
%18 = tail call i32 @strcat(i8* %2, i8* %17)
%19 = tail call i32 @strcat(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = add nuw nsw i64 %9, 1
%21 = icmp eq i64 %20, %7
br i1 %21, label %24, label %8
22: ; preds = %8
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %24
24: ; preds = %16, %4, %22
ret void
}