#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*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  char prog_name[128];
  strcpy(prog_name, argv[0]);
  char arg1[80];
  strcpy(arg1, argv[1]);
  strcat(arg1, prog_name);
  char buf[80];
  sprintf(buf, "%s", argv[2]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1030 <strcpy@plt>
lea    -0xe0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1040 <strcat@plt>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe6e(%rip),%rsi
call   1050 <sprintf@plt>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x120,%rsp
mov    %rsi,%rbx
mov    (%rsi),%rsi
lea    0xa0(%rsp),%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    0x8(%rbx),%rsi
lea    0x50(%rsp),%r15
mov    %r15,%rdi
call   1030 <strcpy@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <strcat@plt>
mov    0x10(%rbx),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [128 x i8]
%6 = alloca [80 x i8]
%7 = alloca [80 x i8]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%9 = load i8**, i8*** %4
%10 = getelementptr inbounds i8*, i8** %9, i64 0
%11 = load i8*, i8** %10
%12 = call i32 @strcpy(i8* %8, i8* %11)
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%14 = load i8**, i8*** %4
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strcpy(i8* %13, i8* %16)
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%20 = call i32 @strcat(i8* %18, i8* %19)
%21 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%22 = load i8**, i8*** %4
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %24)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [128 x i8]
%4 = alloca [80 x i8]
%5 = alloca [80 x i8]
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%7 = load i8*, i8** %1
%8 = call i32 @strcpy(i8* %6, i8* %7)
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @strcpy(i8* %9, i8* %11)
%13 = call i32 @strcat(i8* %9, i8* %6)
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = call i8* bitcast (i32 (i8*, i8*)* @strcpy to i8* (i8*, i8*)*)(i8* %14, i8* %16)
ret i32 0
}