#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, int /*<<< orphan*/);
int /*<<< orphan*/ puts(int /*<<< orphan*/);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ usage(int /*<<< orphan*/);
int main(int argc, char **argv) {
  if (argc < 3) {
    usage(0);
    return 0;
  } else {
    char newStr[256] = "";
    for (int i = 1; i < argc; i++) {
      printf("Length of argument %i: %li characters\n", i, strlen(argv[i]));
      strcat(newStr, argv[i]);
    }
    puts(strcat("All arguments concatenated: ", newStr));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1196 <main+0x36>
xor    %edi,%edi
call   1070 <usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    123f <main+0xdf>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
movl   $0x1,-0x114(%rbp)
mov    -0x114(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1225 <main+0xc5>
mov    -0x114(%rbp),%eax
mov    %eax,-0x118(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x114(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    -0x118(%rbp),%esi
mov    %eax,%edx
lea    0xe0f(%rip),%rdi
call   1050 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x114(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1080 <strcat@plt>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    11b3 <main+0x53>
lea    -0x110(%rbp),%rsi
lea    0xdf4(%rip),%rdi
call   1080 <strcat@plt>
mov    %eax,%edi
call   1030 <puts@plt>
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100,%rsp
cmp    $0x2,%edi
jg     1171 <main+0x21>
xor    %edi,%edi
call   1060 <usage@plt>
jmp    1230 <main+0xe0>
mov    %rsi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %edi,%r13d
mov    $0x1,%ebx
lea    0xe13(%rip),%r15
mov    %rsp,%r12
mov    (%r14,%rbx,8),%rdi
call   1040 <strlen@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1050 <printf@plt>
mov    (%r14,%rbx,8),%rsi
mov    %r12,%rdi
call   1070 <strcat@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11f0 <main+0xa0>
lea    0xe06(%rip),%rdi
mov    %rsp,%rsi
call   1070 <strcat@plt>
mov    %eax,%edi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [39 x i8] c"Length of argument %i: %li characters\0A\00"
@.str.1 = [29 x i8] c"All arguments concatenated: \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @usage(i32 0)
store i32 0, i32* %3
br label %41
12: ; preds = %2
%13 = bitcast [256 x i8]* %6 to i8*
store i32 1, i32* %7
br label %14
14: ; preds = %34, %12
%15 = load i32, i32* %7
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %37
18: ; preds = %14
%19 = load i32, i32* %7
%20 = load i8**, i8*** %5
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 @strlen(i8* %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %19, i32 %25)
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%28 = load i8**, i8*** %5
%29 = load i32, i32* %7
%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)
br label %34
34: ; preds = %18
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %14
37: ; preds = %14
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%39 = call i32 @strcat(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %38)
%40 = call i32 @puts(i32 %39)
br label %41
41: ; preds = %10, %37
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@.str = [39 x i8] c"Length of argument %i: %li characters\0A\00"
@.str.1 = [29 x i8] c"All arguments concatenated: \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = icmp slt i32 %0, 3
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @usage(i32 0)
br label %24
7: ; preds = %2
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%9 = zext i32 %0 to i64
br label %13
10: ; preds = %13
%11 = call i32 @strcat(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%12 = call i32 @puts(i32 %11)
br label %24
13: ; preds = %7, %13
%14 = phi i64 [ 1, %7 ], [ %22, %13 ]
%15 = getelementptr inbounds i8*, i8** %1, i64 %14
%16 = load i8*, i8** %15
%17 = call i32 @strlen(i8* %16)
%18 = trunc i64 %14 to i32
%19 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %17)
%20 = load i8*, i8** %15
%21 = call i32 @strcat(i8* %8, i8* %20)
%22 = add nuw nsw i64 %14, 1
%23 = icmp eq i64 %22, %9
br i1 %23, label %10, label %13
24: ; preds = %5, %10
ret i32 0
}