#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*/ execvp(char *, char **);
char **malloc(int);
int /*<<< orphan*/ printf(char *, char *);
void cleanup(char **argv) {
  char **new_args = malloc(sizeof(char *) * 3);
  new_args[0] = "nothing";
  new_args[1] = argv[1];
  new_args[2] = NULL;
  printf("doing cleanup on %s\n", argv[1]);
  execvp("/home/julia/coccinelle/tools/distributed/"
         "cleanup",
         new_args);
}


x86 assembly (clang, -O0):
<cleanup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x18,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
lea    0xeab(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rax
movq   $0x0,0x10(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe8a(%rip),%rdi
call   1050 <execvp@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cleanup>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x18,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
lea    0xeb5(%rip),%rax
mov    %rax,(%rbx)
mov    0x8(%r14),%rsi
mov    %rsi,0x8(%rbx)
movq   $0x0,0x10(%rbx)
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
lea    0xeac(%rip),%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <execvp@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"nothing\00"
@.str.1 = [21 x i8] c"doing cleanup on %s\0A\00"
@.str.2 = [49 x i8] c"/home/julia/coccinelle/tools/distributed/cleanup\00"
define void @cleanup(i8** %0) {
%2 = alloca i8**
%3 = alloca i8**
store i8** %0, i8*** %2
%4 = call i8** @malloc(i32 24)
store i8** %4, i8*** %3
%5 = load i8**, i8*** %3
%6 = getelementptr inbounds i8*, i8** %5, i64 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = load i8**, i8*** %2
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = load i8**, i8*** %3
%11 = getelementptr inbounds i8*, i8** %10, i64 1
store i8* %9, i8** %11
%12 = load i8**, i8*** %3
%13 = getelementptr inbounds i8*, i8** %12, i64 2
store i8* null, i8** %13
%14 = load i8**, i8*** %2
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = load i8**, i8*** %3
%19 = call i32 @execvp(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i8** %18)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"nothing\00"
@.str.1 = [21 x i8] c"doing cleanup on %s\0A\00"
@.str.2 = [49 x i8] c"/home/julia/coccinelle/tools/distributed/cleanup\00"
define void @cleanup(i8** nocapture %0) {
%2 = tail call i8** @malloc(i32 24)
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %2
%3 = getelementptr inbounds i8*, i8** %0, i64 1
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8*, i8** %2, i64 1
store i8* %4, i8** %5
%6 = getelementptr inbounds i8*, i8** %2, i64 2
store i8* null, i8** %6
%7 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%8 = tail call i32 @execvp(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i8** %2)
ret void
}