#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(void *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strlen(char *);
char *compress_args(int argc, char **argv) {
  char *temp_string;
  int index = 1;
  int total_size = 0;
  for (index = 1; index < argc; index++)
    total_size += strlen(argv[index]);
  temp_string = (char *)malloc(total_size + 1);
  memset((void *)temp_string, 0, total_size);
  for (index = 1; index < argc; index++)
    strcat(temp_string, argv[index]);
  return temp_string;
}


x86 assembly (clang, -O0):
<compress_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    119c <compress_args+0x5c>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1164 <compress_args+0x24>
mov    -0x20(%rbp),%edi
add    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%edx
xor    %esi,%esi
call   1040 <memset@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ef <compress_args+0xaf>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1060 <strcat@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c0 <compress_args+0x80>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compress_args>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %edi,%r14d
xor    %ebp,%ebp
mov    %edi,%r13d
cmp    $0x2,%edi
jl     1184 <compress_args+0x44>
xor    %ebp,%ebp
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r12,%rbx,8),%rdi
call   1030 <strlen@plt>
add    %eax,%ebp
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1170 <compress_args+0x30>
lea    0x1(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1040 <memset@plt>
cmp    $0x2,%r14d
jl     11c5 <compress_args+0x85>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%r12,%rbx,8),%rsi
mov    %r15,%rdi
call   1060 <strcat@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11b0 <compress_args+0x70>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @compress_args(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 1, i32* %6
store i32 0, i32* %7
store i32 1, i32* %6
br label %8
8: ; preds = %23, %2
%9 = load i32, i32* %6
%10 = load i32, i32* %3
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %26
12: ; preds = %8
%13 = load i8**, i8*** %4
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = call i64 @strlen(i8* %17)
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = add nsw i64 %20, %18
%22 = trunc i64 %21 to i32
store i32 %22, i32* %7
br label %23
23: ; preds = %12
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %8
26: ; preds = %8
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
%29 = call i64 @malloc(i32 %28)
%30 = inttoptr i64 %29 to i8*
store i8* %30, i8** %5
%31 = load i8*, i8** %5
%32 = load i32, i32* %7
%33 = call i32 @memset(i8* %31, i32 0, i32 %32)
store i32 1, i32* %6
br label %34
34: ; preds = %46, %26
%35 = load i32, i32* %6
%36 = load i32, i32* %3
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %49
38: ; preds = %34
%39 = load i8*, i8** %5
%40 = load i8**, i8*** %4
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = call i32 @strcat(i8* %39, i8* %44)
br label %46
46: ; preds = %38
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
store i32 %48, i32* %6
br label %34
49: ; preds = %34
%50 = load i8*, i8** %5
ret i8* %50
}

LLVM IR (-O2):
define i8* @compress_args(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %16
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 1, %4 ], [ %14, %6 ]
%8 = phi i32 [ 0, %4 ], [ %13, %6 ]
%9 = getelementptr inbounds i8*, i8** %1, i64 %7
%10 = load i8*, i8** %9
%11 = tail call i64 @strlen(i8* dereferenceable(1) %10)
%12 = trunc i64 %11 to i32
%13 = add i32 %8, %12
%14 = add nuw nsw i64 %7, 1
%15 = icmp eq i64 %14, %5
br i1 %15, label %16, label %6
16: ; preds = %6, %2
%17 = phi i32 [ 0, %2 ], [ %13, %6 ]
%18 = add nsw i32 %17, 1
%19 = tail call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i8*
%21 = tail call i32 @memset(i8* %20, i32 0, i32 %17)
br i1 %3, label %22, label %31
22: ; preds = %16
%23 = zext i32 %0 to i64
br label %24
24: ; preds = %22, %24
%25 = phi i64 [ 1, %22 ], [ %29, %24 ]
%26 = getelementptr inbounds i8*, i8** %1, i64 %25
%27 = load i8*, i8** %26
%28 = tail call i32 @strcat(i8* %20, i8* %27)
%29 = add nuw nsw i64 %25, 1
%30 = icmp eq i64 %29, %23
br i1 %30, label %31, label %24
31: ; preds = %24, %16
ret i8* %20
}