#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 execv(char *, char **);
int main(int argc, char *argv[]) {
  char *argvnew[argc + 2];
  int id = 0, is = 0;
  argvnew[id++] = argv[is++];
  argvnew[id++] = "--personality="
                  "ARCH";
  while (is < argc)
    argvnew[id++] = argv[is++];
  argvnew[id++] = 0;
  return execv("/usr/bin/pkgconf", argvnew);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,%ecx
mov    %rsp,%rax
mov    %rax,-0x18(%rbp)
lea    0xf(,%rcx,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,-0x30(%rbp)
mov    %rax,%rsp
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rcx
mov    -0x28(%rbp),%edx
mov    %edx,%esi
add    $0x1,%esi
mov    %esi,-0x28(%rbp)
movslq %edx,%rdx
mov    (%rcx,%rdx,8),%rdx
mov    -0x24(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x24(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x24(%rbp)
movslq %ecx,%rcx
lea    0xe63(%rip),%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11de <main+0xce>
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    -0x28(%rbp),%edx
mov    %edx,%esi
add    $0x1,%esi
mov    %esi,-0x28(%rbp)
movslq %edx,%rdx
mov    (%rcx,%rdx,8),%rdx
mov    -0x24(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x24(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    11a1 <main+0x91>
mov    -0x30(%rbp),%rsi
mov    -0x24(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x24(%rbp)
cltq
movq   $0x0,(%rsi,%rax,8)
lea    0xe15(%rip),%rdi
call   1030 <execv@plt>
mov    %eax,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    %edi,%r14d
lea    0x2(%r14),%eax
mov    %rsp,%rcx
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
mov    %rcx,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
neg    %rax
mov    (%rsi),%rdx
mov    %rdx,(%rcx,%rax,1)
lea    0xea9(%rip),%rax
mov    %rax,0x8(%rbx)
mov    $0x2,%eax
cmp    $0x2,%edi
jl     1181 <main+0x61>
lea    0x10(%rbx),%rdi
add    $0x8,%rsi
lea    -0x1(%r14),%edx
shl    $0x3,%rdx
call   1030 <memcpy@plt>
add    $0x1,%r14d
mov    %r14,%rax
movq   $0x0,(%rbx,%rax,8)
lea    0xe83(%rip),%rdi
mov    %rbx,%rsi
call   1040 <execv@plt>
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"--personality=ARCH\00"
@.str.1 = [17 x i8] c"/usr/bin/pkgconf\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = add nsw i32 %10, 2
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %6
%14 = alloca i8*, i64 %12
store i64 %12, i64* %7
store i32 0, i32* %8
store i32 0, i32* %9
%15 = load i8**, i8*** %5
%16 = load i32, i32* %9
%17 = add nsw i32 %16, 1
store i32 %17, i32* %9
%18 = sext i32 %16 to i64
%19 = getelementptr inbounds i8*, i8** %15, i64 %18
%20 = load i8*, i8** %19
%21 = load i32, i32* %8
%22 = add nsw i32 %21, 1
store i32 %22, i32* %8
%23 = sext i32 %21 to i64
%24 = getelementptr inbounds i8*, i8** %14, i64 %23
store i8* %20, i8** %24
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
%27 = sext i32 %25 to i64
%28 = getelementptr inbounds i8*, i8** %14, i64 %27
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8** %28
br label %29
29: ; preds = %33, %2
%30 = load i32, i32* %9
%31 = load i32, i32* %4
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %44
33: ; preds = %29
%34 = load i8**, i8*** %5
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
store i32 %36, i32* %9
%37 = sext i32 %35 to i64
%38 = getelementptr inbounds i8*, i8** %34, i64 %37
%39 = load i8*, i8** %38
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
%42 = sext i32 %40 to i64
%43 = getelementptr inbounds i8*, i8** %14, i64 %42
store i8* %39, i8** %43
br label %29
44: ; preds = %29
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
%47 = sext i32 %45 to i64
%48 = getelementptr inbounds i8*, i8** %14, i64 %47
store i8* null, i8** %48
%49 = call i32 @execv(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8** %14)
store i32 %49, i32* %3
%50 = load i8*, i8** %6
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@.str = [19 x i8] c"--personality=ARCH\00"
@.str.1 = [17 x i8] c"/usr/bin/pkgconf\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = add nsw i32 %0, 2
%4 = zext i32 %3 to i64
%5 = alloca i8*, i64 %4
%6 = load i8*, i8** %1
store i8* %6, i8** %5
%7 = getelementptr inbounds i8*, i8** %5, i64 1
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8** %7
%8 = icmp sgt i32 %0, 1
br i1 %8, label %9, label %19
9: ; preds = %2
%10 = getelementptr i8*, i8** %5, i64 2
%11 = bitcast i8** %10 to i8*
%12 = getelementptr i8*, i8** %1, i64 1
%13 = bitcast i8** %12 to i8*
%14 = add nsw i32 %0, -1
%15 = zext i32 %14 to i64
%16 = shl nuw nsw i64 %15, 3
%17 = add nuw i32 %0, 1
%18 = zext i32 %17 to i64
br label %19
19: ; preds = %9, %2
%20 = phi i64 [ 2, %2 ], [ %18, %9 ]
%21 = getelementptr inbounds i8*, i8** %5, i64 %20
store i8* null, i8** %21
%22 = call i32 @execv(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8** %5)
ret i32 %22
}