#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*/ get_argv_size(int, char **);
char *malloc(int /*<<< orphan*/);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
char *get_expression(int argc, char **argv) {
  char *cmd = malloc(get_argv_size(argc, argv));
  for (int i = 1; i < argc; ++i) {
    if (!strlen(cmd)) {
      strcpy(cmd, argv[i]);
    } else {
      strcat(cmd, argv[i]);
    }
  }
  return cmd;
}


x86 assembly (clang, -O0):
<get_expression>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <get_argv_size@plt>
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11dd <get_expression+0x8d>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
jne    11b5 <get_expression+0x65>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
jmp    11ca <get_expression+0x7a>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1070 <strcat@plt>
jmp    11cf <get_expression+0x7f>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117d <get_expression+0x2d>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_expression>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebp
call   1050 <get_argv_size@plt>
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
cmp    $0x2,%ebp
jl     11a8 <get_expression+0x58>
mov    %ebp,%r15d
mov    $0x1,%ebp
jmp    118e <get_expression+0x3e>
nopw   0x0(%rax,%rax,1)
call   1070 <strcat@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
je     11a8 <get_expression+0x58>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    (%r14,%rbp,8),%rsi
mov    %rbx,%rdi
test   %eax,%eax
jne    1180 <get_expression+0x30>
call   1030 <strcpy@plt>
jmp    1185 <get_expression+0x35>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i8* @get_expression(i32 %0, i8** %1) {
%3 = tail call i32 @get_argv_size(i32 %0, i8** %1)
%4 = tail call i8* @malloc(i32 %3)
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %9
8: ; preds = %19, %2
ret i8* %4
9: ; preds = %6, %19
%10 = phi i64 [ 1, %6 ], [ %20, %19 ]
%11 = tail call i32 @strlen(i8* %4)
%12 = icmp eq i32 %11, 0
%13 = getelementptr inbounds i8*, i8** %1, i64 %10
%14 = load i8*, i8** %13
br i1 %12, label %15, label %17
15: ; preds = %9
%16 = tail call i32 @strcpy(i8* %4, i8* %14)
br label %19
17: ; preds = %9
%18 = tail call i32 @strcat(i8* %4, i8* %14)
br label %19
19: ; preds = %15, %17
%20 = add nuw nsw i64 %10, 1
%21 = icmp eq i64 %20, %7
br i1 %21, label %8, label %9
}