#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*/ _exit(int /*<<< orphan*/);
int /*<<< orphan*/ execvp(char *, char **);
char **malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
void do_child(int id, unsigned int argc, char **argv, int max, char *script) {
  int i;
  char **new_args = malloc(sizeof(char *) * (argc + 5));
  char string1[50], string2[50];
  for (i = 1; i != argc; i++) {
    new_args[i + 4] = argv[i];
  }
  new_args[i + 4] = NULL;
  new_args[0] = "nothing";
  new_args[1] = new_args[5];
  new_args[2] = "-index";
  sprintf(string1, "%d", id);
  new_args[3] = string1;
  new_args[4] = "-max";
  sprintf(string2, "%d", max);
  new_args[5] = string2;
  execvp(script, new_args);
  printf("tried to execute %s\n", "/home/julia/coccinelle/tools/distributed/"
                                  "spatch_linux_script");
  perror("exec failure");
  _exit(0);
}


x86 assembly (clang, -O0):
<do_child>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x8(%rbp),%eax
add    $0x5,%eax
mov    %eax,%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     11d1 <do_child+0x71>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x30(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x4,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    119a <do_child+0x3a>
mov    -0x30(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x4,%ecx
movslq %ecx,%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
lea    0xe0f(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
mov    0x28(%rax),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x30(%rbp),%rax
lea    0xdf9(%rip),%rcx
mov    %rcx,0x10(%rax)
lea    -0x70(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xdee(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x70(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x30(%rbp),%rax
lea    0xdd5(%rip),%rcx
mov    %rcx,0x20(%rax)
lea    -0xb0(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xdbd(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0xb0(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,0x28(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1070 <execvp@plt>
lea    0xd9d(%rip),%rdi
lea    0xdab(%rip),%rsi
call   1040 <printf@plt>
lea    0xddc(%rip),%rdi
call   1060 <perror@plt>
xor    %edi,%edi
call   1030 <_exit@plt>

x86 assembly (clang, -O2):
<do_child>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %r8,%r14
mov    %ecx,%r15d
mov    %rdx,%r13
mov    %esi,%ebp
mov    %edi,%r12d
lea    0x28(,%rbp,8),%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    $0x5,%eax
cmp    $0x1,%ebp
je     11c5 <do_child+0x55>
mov    %rbx,%rdi
add    $0x28,%rdi
add    $0x8,%r13
lea    -0x1(%rbp),%edx
shl    $0x3,%rdx
mov    %r13,%rsi
call   1050 <memcpy@plt>
add    $0x4,%ebp
mov    %rbp,%rax
movq   $0x0,(%rbx,%rax,8)
lea    0xe2c(%rip),%rax
mov    %rax,(%rbx)
mov    0x28(%rbx),%rax
mov    %rax,0x8(%rbx)
lea    0xe22(%rip),%rax
mov    %rax,0x10(%rbx)
lea    0xe1e(%rip),%r13
lea    0x40(%rsp),%rbp
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r12d,%edx
call   1090 <sprintf@plt>
mov    %rbp,0x18(%rbx)
lea    0xe03(%rip),%rax
mov    %rax,0x20(%rbx)
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r15d,%edx
call   1090 <sprintf@plt>
mov    %rbp,0x28(%rbx)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <execvp@plt>
lea    0xddd(%rip),%rdi
lea    0xdeb(%rip),%rsi
call   1040 <printf@plt>
lea    0xe1c(%rip),%rdi
call   1070 <perror@plt>
xor    %edi,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"nothing\00"
@.str.1 = [7 x i8] c"-index\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [5 x i8] c"-max\00"
@.str.4 = [21 x i8] c"tried to execute %s\0A\00"
@.str.5 = [61 x i8] c"/home/julia/coccinelle/tools/distributed/spatch_linux_script\00"
@.str.6 = [13 x i8] c"exec failure\00"
define void @do_child(i32 %0, i32 %1, i8** %2, i32 %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8**
%13 = alloca [50 x i8]
%14 = alloca [50 x i8]
store i32 %0, i32* %6
store i32 %1, i32* %7
store i8** %2, i8*** %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%15 = load i32, i32* %7
%16 = add i32 %15, 5
%17 = zext i32 %16 to i64
%18 = mul i64 8, %17
%19 = trunc i64 %18 to i32
%20 = call i8** @malloc(i32 %19)
store i8** %20, i8*** %12
store i32 1, i32* %11
br label %21
21: ; preds = %36, %5
%22 = load i32, i32* %11
%23 = load i32, i32* %7
%24 = icmp ne i32 %22, %23
br i1 %24, label %25, label %39
25: ; preds = %21
%26 = load i8**, i8*** %8
%27 = load i32, i32* %11
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = load i8**, i8*** %12
%32 = load i32, i32* %11
%33 = add nsw i32 %32, 4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %31, i64 %34
store i8* %30, i8** %35
br label %36
36: ; preds = %25
%37 = load i32, i32* %11
%38 = add nsw i32 %37, 1
store i32 %38, i32* %11
br label %21
39: ; preds = %21
%40 = load i8**, i8*** %12
%41 = load i32, i32* %11
%42 = add nsw i32 %41, 4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %40, i64 %43
store i8* null, i8** %44
%45 = load i8**, i8*** %12
%46 = getelementptr inbounds i8*, i8** %45, i64 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %46
%47 = load i8**, i8*** %12
%48 = getelementptr inbounds i8*, i8** %47, i64 5
%49 = load i8*, i8** %48
%50 = load i8**, i8*** %12
%51 = getelementptr inbounds i8*, i8** %50, i64 1
store i8* %49, i8** %51
%52 = load i8**, i8*** %12
%53 = getelementptr inbounds i8*, i8** %52, i64 2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %53
%54 = getelementptr inbounds [50 x i8], [50 x i8]* %13, i64 0, i64 0
%55 = load i32, i32* %6
%56 = call i32 @sprintf(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %55)
%57 = getelementptr inbounds [50 x i8], [50 x i8]* %13, i64 0, i64 0
%58 = load i8**, i8*** %12
%59 = getelementptr inbounds i8*, i8** %58, i64 3
store i8* %57, i8** %59
%60 = load i8**, i8*** %12
%61 = getelementptr inbounds i8*, i8** %60, i64 4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %61
%62 = getelementptr inbounds [50 x i8], [50 x i8]* %14, i64 0, i64 0
%63 = load i32, i32* %9
%64 = call i32 @sprintf(i8* %62, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %63)
%65 = getelementptr inbounds [50 x i8], [50 x i8]* %14, i64 0, i64 0
%66 = load i8**, i8*** %12
%67 = getelementptr inbounds i8*, i8** %66, i64 5
store i8* %65, i8** %67
%68 = load i8*, i8** %10
%69 = load i8**, i8*** %12
%70 = call i32 @execvp(i8* %68, i8** %69)
%71 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.5, i64 0, i64 0))
%72 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%73 = call i32 @_exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [8 x i8] c"nothing\00"
@.str.1 = [7 x i8] c"-index\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [5 x i8] c"-max\00"
@.str.4 = [21 x i8] c"tried to execute %s\0A\00"
@.str.5 = [61 x i8] c"/home/julia/coccinelle/tools/distributed/spatch_linux_script\00"
@.str.6 = [13 x i8] c"exec failure\00"
define void @do_child(i32 %0, i32 %1, i8** nocapture %2, i32 %3, i8* %4) {
%6 = alloca [50 x i8]
%7 = alloca [50 x i8]
%8 = shl i32 %1, 3
%9 = add i32 %8, 40
%10 = tail call i8** @malloc(i32 %9)
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%13 = icmp eq i32 %1, 1
br i1 %13, label %24, label %14
14: ; preds = %5
%15 = getelementptr i8*, i8** %10, i64 5
%16 = bitcast i8** %15 to i8*
%17 = getelementptr i8*, i8** %2, i64 1
%18 = bitcast i8** %17 to i8*
%19 = add i32 %1, -1
%20 = zext i32 %19 to i64
%21 = shl nuw nsw i64 %20, 3
%22 = add i32 %1, 4
%23 = zext i32 %22 to i64
br label %24
24: ; preds = %14, %5
%25 = phi i64 [ 5, %5 ], [ %23, %14 ]
%26 = getelementptr inbounds i8*, i8** %10, i64 %25
store i8* null, i8** %26
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %10
%27 = getelementptr inbounds i8*, i8** %10, i64 5
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8*, i8** %10, i64 1
store i8* %28, i8** %29
%30 = getelementptr inbounds i8*, i8** %10, i64 2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %30
%31 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %0)
%32 = getelementptr inbounds i8*, i8** %10, i64 3
store i8* %11, i8** %32
%33 = getelementptr inbounds i8*, i8** %10, i64 4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %33
%34 = call i32 @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %3)
store i8* %12, i8** %27
%35 = call i32 @execvp(i8* %4, i8** %10)
%36 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.5, i64 0, i64 0))
%37 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%38 = call i32 @_exit(i32 0)
unreachable
}