run_script_with_args(argc, argv, quiet) int argc;
char *argv[];
int quiet;
{
  char buff[256];
  char *total_args;
  int len;
  int ret;
  int i;
  len = 2;
  for (i = 2; i < argc; i++)
    len += strlen(argv[i]) + 1;
  len++;
  total_args = malloc(len);
  strcpy(total_args, "*=");
  for (i = 2; i < argc; i++) {
    strcat(total_args, argv[i]);
    if (i + 1 < argc)
      strcat(total_args, " ");
    sprintf(buff, "%d=%s", i - 1, argv[i]);
    set_env(buff);
  }
  set_env(total_args);
  free(total_args);
  sprintf(buff, "#=%d", argc - 2);
  set_env(buff);
  ret = run_script(argv[1], quiet);
  return (ret);
}


x86 assembly (clang, -O0):
<run_script_with_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x2,-0x12c(%rbp)
movl   $0x2,-0x134(%rbp)
mov    -0x134(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11f7 <run_script_with_args+0x77>
mov    -0x10(%rbp),%rax
movslq -0x134(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
add    $0x1,%rcx
movslq -0x12c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x12c(%rbp)
mov    -0x134(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134(%rbp)
jmp    11a9 <run_script_with_args+0x29>
mov    -0x12c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x12c(%rbp)
movslq -0x12c(%rbp),%rdi
call   1080 <malloc@plt>
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rdi
lea    0xdd9(%rip),%rsi
call   1040 <strcpy@plt>
movl   $0x2,-0x134(%rbp)
mov    -0x134(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12d4 <run_script_with_args+0x154>
mov    -0x128(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x134(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1090 <strcat@plt>
mov    -0x134(%rbp),%eax
add    $0x1,%eax
cmp    -0x4(%rbp),%eax
jge    1285 <run_script_with_args+0x105>
mov    -0x128(%rbp),%rdi
lea    0xd83(%rip),%rsi
call   1090 <strcat@plt>
lea    -0x120(%rbp),%rdi
mov    -0x134(%rbp),%edx
sub    $0x1,%edx
mov    -0x10(%rbp),%rax
movslq -0x134(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xd5a(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x120(%rbp),%rdi
mov    $0x0,%al
call   1060 <set_env@plt>
mov    -0x134(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134(%rbp)
jmp    1236 <run_script_with_args+0xb6>
mov    -0x128(%rbp),%rdi
mov    $0x0,%al
call   1060 <set_env@plt>
mov    -0x128(%rbp),%rdi
call   1030 <free@plt>
lea    -0x120(%rbp),%rdi
mov    -0x4(%rbp),%edx
sub    $0x2,%edx
lea    0xd09(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x120(%rbp),%rdi
mov    $0x0,%al
call   1060 <set_env@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x14(%rbp),%esi
mov    $0x0,%al
call   1070 <run_script@plt>
mov    %eax,-0x130(%rbp)
mov    -0x130(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_script_with_args>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %edx,%r14d
mov    %rsi,%r13
mov    %edi,%r12d
cmp    $0x2,%edi
jle    125f <run_script_with_args+0xef>
mov    %r12d,%r15d
mov    $0x2,%ebp
mov    $0x2,%ebx
mov    0x0(%r13,%rbx,8),%rdi
call   1040 <strlen@plt>
add    %eax,%ebp
add    $0x1,%ebp
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11a0 <run_script_with_args+0x30>
add    $0x1,%ebp
movslq %ebp,%rdi
call   1070 <malloc@plt>
mov    %rax,%rbp
movw   $0x3d2a,(%rax)
movb   $0x0,0x2(%rax)
cmp    $0x3,%r12d
jl     1280 <run_script_with_args+0x110>
mov    %r12d,(%rsp)
mov    %r14d,0x4(%rsp)
mov    $0x2,%eax
sub    %r15,%rax
mov    %rax,0x8(%rsp)
mov    $0x3,%r12d
lea    0x10(%rsp),%rbx
jmp    1239 <run_script_with_args+0xc9>
nopl   0x0(%rax)
lea    -0x2(%r12),%edx
mov    %rbx,%rdi
lea    0xdf4(%rip),%rsi
mov    %r14,%rcx
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <set_env@plt>
mov    0x8(%rsp),%rax
add    %r12,%rax
add    $0x1,%rax
add    $0x1,%r12
cmp    $0x3,%rax
je     1277 <run_script_with_args+0x107>
mov    -0x8(%r13,%r12,8),%r14
mov    %rbp,%rdi
mov    %r14,%rsi
call   1080 <strcat@plt>
cmp    %r15,%r12
jae    1200 <run_script_with_args+0x90>
mov    %rbp,%rdi
call   1040 <strlen@plt>
movw   $0x20,0x0(%rbp,%rax,1)
jmp    1200 <run_script_with_args+0x90>
mov    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,%rbp
movw   $0x3d2a,(%rax)
movb   $0x0,0x2(%rax)
jmp    1280 <run_script_with_args+0x110>
mov    0x4(%rsp),%r14d
mov    (%rsp),%r12d
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <set_env@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
add    $0xfffffffe,%r12d
lea    0xd6c(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %r12d,%edx
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <set_env@plt>
mov    0x8(%r13),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <run_script@plt>
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"*=\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [6 x i8] c"%d=%s\00"
@.str.3 = [5 x i8] c"#=%d\00"
define i32 @run_script_with_args(i32 %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [256 x i8]
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
store i32 2, i32* %9
store i32 2, i32* %11
br label %12
12: ; preds = %28, %3
%13 = load i32, i32* %11
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %31
16: ; preds = %12
%17 = load i8**, i8*** %5
%18 = load i32, i32* %11
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = call i64 @strlen(i8* %21)
%23 = add i64 %22, 1
%24 = load i32, i32* %9
%25 = sext i32 %24 to i64
%26 = add i64 %25, %23
%27 = trunc i64 %26 to i32
store i32 %27, i32* %9
br label %28
28: ; preds = %16
%29 = load i32, i32* %11
%30 = add nsw i32 %29, 1
store i32 %30, i32* %11
br label %12
31: ; preds = %12
%32 = load i32, i32* %9
%33 = add nsw i32 %32, 1
store i32 %33, i32* %9
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = call i8* @malloc(i64 %35)
store i8* %36, i8** %8
%37 = load i8*, i8** %8
%38 = call i8* @strcpy(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 2, i32* %11
br label %39
39: ; preds = %70, %31
%40 = load i32, i32* %11
%41 = load i32, i32* %4
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %73
43: ; preds = %39
%44 = load i8*, i8** %8
%45 = load i8**, i8*** %5
%46 = load i32, i32* %11
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %45, i64 %47
%49 = load i8*, i8** %48
%50 = call i8* @strcat(i8* %44, i8* %49)
%51 = load i32, i32* %11
%52 = add nsw i32 %51, 1
%53 = load i32, i32* %4
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %58
55: ; preds = %43
%56 = load i8*, i8** %8
%57 = call i8* @strcat(i8* %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %58
58: ; preds = %55, %43
%59 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%60 = load i32, i32* %11
%61 = sub nsw i32 %60, 1
%62 = load i8**, i8*** %5
%63 = load i32, i32* %11
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8*, i8** %62, i64 %64
%66 = load i8*, i8** %65
%67 = call i32 (i8*, i8*, ...) @sprintf(i8* %59, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %61, i8* %66)
%68 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%69 = call i32 (i8*, ...) bitcast (i32 (...)* @set_env to i32 (i8*, ...)*)(i8* %68)
br label %70
70: ; preds = %58
%71 = load i32, i32* %11
%72 = add nsw i32 %71, 1
store i32 %72, i32* %11
br label %39
73: ; preds = %39
%74 = load i8*, i8** %8
%75 = call i32 (i8*, ...) bitcast (i32 (...)* @set_env to i32 (i8*, ...)*)(i8* %74)
%76 = load i8*, i8** %8
%77 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%78 = load i32, i32* %4
%79 = sub nsw i32 %78, 2
%80 = call i32 (i8*, i8*, ...) @sprintf(i8* %77, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %79)
%81 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%82 = call i32 (i8*, ...) bitcast (i32 (...)* @set_env to i32 (i8*, ...)*)(i8* %81)
%83 = load i8**, i8*** %5
%84 = getelementptr inbounds i8*, i8** %83, i64 1
%85 = load i8*, i8** %84
%86 = load i32, i32* %6
%87 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @run_script to i32 (i8*, i32, ...)*)(i8* %85, i32 %86)
store i32 %87, i32* %10
%88 = load i32, i32* %10
ret i32 %88
}

LLVM IR (-O2):
@.str = [3 x i8] c"*=\00"
@.str.2 = [6 x i8] c"%d=%s\00"
@.str.3 = [5 x i8] c"#=%d\00"
define i32 @run_script_with_args(i32 %0, i8** nocapture %1, i32 %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = icmp sgt i32 %0, 2
br i1 %6, label %9, label %7
7: ; preds = %3
%8 = tail call dereferenceable_or_null(3) i8* @malloc(i64 3)
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %8, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 3, i1 false)
br label %46
9: ; preds = %3
%10 = zext i32 %0 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 2, %9 ], [ %20, %11 ]
%13 = phi i32 [ 2, %9 ], [ %19, %11 ]
%14 = getelementptr inbounds i8*, i8** %1, i64 %12
%15 = load i8*, i8** %14
%16 = tail call i64 @strlen(i8* dereferenceable(1) %15)
%17 = trunc i64 %16 to i32
%18 = add i32 %13, 1
%19 = add i32 %18, %17
%20 = add nuw nsw i64 %12, 1
%21 = icmp eq i64 %20, %10
br i1 %21, label %22, label %11
22: ; preds = %11
%23 = add i32 %19, 1
%24 = sext i32 %23 to i64
%25 = tail call i8* @malloc(i64 %24)
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %25, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 3, i1 false)
br i1 %6, label %26, label %46
26: ; preds = %22
%27 = zext i32 %0 to i64
%28 = zext i32 %0 to i64
br label %29
29: ; preds = %26, %40
%30 = phi i64 [ 2, %26 ], [ %34, %40 ]
%31 = getelementptr inbounds i8*, i8** %1, i64 %30
%32 = load i8*, i8** %31
%33 = call i8* @strcat(i8* dereferenceable(1) %25, i8* dereferenceable(1) %32)
%34 = add nuw nsw i64 %30, 1
%35 = icmp ult i64 %34, %27
br i1 %35, label %36, label %40
36: ; preds = %29
%37 = call i64 @strlen(i8* dereferenceable(1) %25)
%38 = getelementptr i8, i8* %25, i64 %37
%39 = bitcast i8* %38 to i16*
store i16 32, i16* %39
br label %40
40: ; preds = %36, %29
%41 = trunc i64 %30 to i32
%42 = add i32 %41, -1
%43 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %42, i8* %32)
%44 = call i32 (i8*, ...) bitcast (i32 (...)* @set_env to i32 (i8*, ...)*)(i8* %5)
%45 = icmp eq i64 %34, %28
br i1 %45, label %46, label %29
46: ; preds = %40, %7, %22
%47 = phi i8* [ %8, %7 ], [ %25, %22 ], [ %25, %40 ]
%48 = call i32 (i8*, ...) bitcast (i32 (...)* @set_env to i32 (i8*, ...)*)(i8* %47)
%49 = add nsw i32 %0, -2
%50 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %49)
%51 = call i32 (i8*, ...) bitcast (i32 (...)* @set_env to i32 (i8*, ...)*)(i8* %5)
%52 = getelementptr inbounds i8*, i8** %1, i64 1
%53 = load i8*, i8** %52
%54 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @run_script to i32 (i8*, i32, ...)*)(i8* %53, i32 %2)
ret i32 %54
}