#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*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int strlen(char *);
int system(char *);
int main(int argc, char **argv) {
  int i;
  int length;
  char *str, *ptr_str;
  length = strlen("/opt/robocomp/bin/main.py") + 1;
  for (i = 1; i < argc; i++) {
    length += strlen(argv[i] + 1);
  }
  str = (char *)malloc(length * sizeof(char));
  ptr_str = str;
  ptr_str += strlen("/opt/robocomp/bin/main.py") + 1;
  printf("%s ", "/opt/robocomp/bin/main.py");
  for (i = 1; i < argc; i++) {
    sprintf(ptr_str, "%s ", argv[i]);
    ptr_str += strlen(argv[i]) + 1;
  }
  i = system(str);
  free(str);
  return i;
}


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)
lea    0xe83(%rip),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c4 <main+0x64>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
add    $0x1,%rdi
call   1040 <strlen@plt>
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118f <main+0x2f>
movslq -0x18(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xe1a(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
add    $0x1,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
lea    0xe15(%rip),%rdi
lea    0xdf4(%rip),%rsi
call   1060 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1272 <main+0x112>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xddf(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
add    $0x1,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1218 <main+0xb8>
mov    -0x20(%rbp),%rdi
call   1050 <system@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %edi,%r15d
lea    0xe88(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
add    $0x1,%ebp
mov    %r15d,%r13d
cmp    $0x2,%r15d
jl     11a8 <main+0x48>
mov    $0x1,%ebx
mov    (%r12,%rbx,8),%rdi
add    $0x1,%rdi
call   1040 <strlen@plt>
add    %eax,%ebp
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1190 <main+0x30>
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
lea    0xe47(%rip),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
lea    0xe50(%rip),%rdi
mov    %rbp,%rsi
call   1060 <printf@plt>
cmp    $0x2,%r15d
jl     121a <main+0xba>
movslq %ebx,%rax
lea    (%rax,%r14,1),%rbp
add    $0x1,%rbp
mov    $0x1,%ebx
lea    0xe2b(%rip),%r15
nop
mov    (%r12,%rbx,8),%rdx
mov    %rbp,%rdi
mov    %r15,%rsi
call   1080 <sprintf@plt>
mov    (%r12,%rbx,8),%rdi
call   1040 <strlen@plt>
cltq
add    %rax,%rbp
add    $0x1,%rbp
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11f0 <main+0x90>
mov    %r14,%rdi
call   1050 <system@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"/opt/robocomp/bin/main.py\00"
@.str.1 = [4 x i8] c"%s \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @strlen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%11 = add nsw i32 %10, 1
store i32 %11, i32* %7
store i32 1, i32* %6
br label %12
12: ; preds = %26, %2
%13 = load i32, i32* %6
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %29
16: ; preds = %12
%17 = load i8**, i8*** %5
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = call i32 @strlen(i8* %22)
%24 = load i32, i32* %7
%25 = add nsw i32 %24, %23
store i32 %25, i32* %7
br label %26
26: ; preds = %16
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %12
29: ; preds = %12
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = mul i64 %31, 1
%33 = trunc i64 %32 to i32
%34 = call i64 @malloc(i32 %33)
%35 = inttoptr i64 %34 to i8*
store i8* %35, i8** %8
%36 = load i8*, i8** %8
store i8* %36, i8** %9
%37 = call i32 @strlen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%38 = add nsw i32 %37, 1
%39 = load i8*, i8** %9
%40 = sext i32 %38 to i64
%41 = getelementptr inbounds i8, i8* %39, i64 %40
store i8* %41, i8** %9
%42 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %6
br label %43
43: ; preds = %65, %29
%44 = load i32, i32* %6
%45 = load i32, i32* %4
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %68
47: ; preds = %43
%48 = load i8*, i8** %9
%49 = load i8**, i8*** %5
%50 = load i32, i32* %6
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %49, i64 %51
%53 = load i8*, i8** %52
%54 = call i32 @sprintf(i8* %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %53)
%55 = load i8**, i8*** %5
%56 = load i32, i32* %6
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %55, i64 %57
%59 = load i8*, i8** %58
%60 = call i32 @strlen(i8* %59)
%61 = add nsw i32 %60, 1
%62 = load i8*, i8** %9
%63 = sext i32 %61 to i64
%64 = getelementptr inbounds i8, i8* %62, i64 %63
store i8* %64, i8** %9
br label %65
65: ; preds = %47
%66 = load i32, i32* %6
%67 = add nsw i32 %66, 1
store i32 %67, i32* %6
br label %43
68: ; preds = %43
%69 = load i8*, i8** %8
%70 = call i32 @system(i8* %69)
store i32 %70, i32* %6
%71 = load i8*, i8** %8
%72 = call i32 @free(i8* %71)
%73 = load i32, i32* %6
ret i32 %73
}

LLVM IR (-O2):
@.str = [26 x i8] c"/opt/robocomp/bin/main.py\00"
@.str.1 = [4 x i8] c"%s \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%4 = add nsw i32 %3, 1
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %18
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 1, %6 ], [ %16, %8 ]
%10 = phi i32 [ %4, %6 ], [ %15, %8 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %9
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = tail call i32 @strlen(i8* %13)
%15 = add nsw i32 %14, %10
%16 = add nuw nsw i64 %9, 1
%17 = icmp eq i64 %16, %7
br i1 %17, label %18, label %8
18: ; preds = %8, %2
%19 = phi i32 [ %4, %2 ], [ %15, %8 ]
%20 = tail call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to i8*
%22 = tail call i32 @strlen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%23 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br i1 %5, label %24, label %42
24: ; preds = %18
%25 = add nsw i32 %22, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %21, i64 %26
%28 = zext i32 %0 to i64
br label %29
29: ; preds = %24, %29
%30 = phi i64 [ 1, %24 ], [ %40, %29 ]
%31 = phi i8* [ %27, %24 ], [ %39, %29 ]
%32 = getelementptr inbounds i8*, i8** %1, i64 %30
%33 = load i8*, i8** %32
%34 = tail call i32 @sprintf(i8* dereferenceable(1) %31, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %33)
%35 = load i8*, i8** %32
%36 = tail call i32 @strlen(i8* %35)
%37 = add nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %31, i64 %38
%40 = add nuw nsw i64 %30, 1
%41 = icmp eq i64 %40, %28
br i1 %41, label %42, label %29
42: ; preds = %29, %18
%43 = tail call i32 @system(i8* %21)
%44 = tail call i32 @free(i8* %21)
ret i32 %43
}