#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*/ 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/rcmanager.py") + 1;
  for (i = 1; i < argc; i++) {
    length += strlen(argv[i] + 1);
  }
  str = (char *)malloc(length * sizeof(char));
  ptr_str = str;
  sprintf(ptr_str, "%s ", "/opt/robocomp/bin/rcmanager.py");
  ptr_str += strlen("/opt/robocomp/bin/rcmanager.py") + 1;
  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    0xe93(%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    11b4 <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    117f <main+0x2f>
movslq -0x18(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe45(%rip),%rsi
lea    0xe1f(%rip),%rdx
call   1070 <sprintf@plt>
lea    0xe13(%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)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1266 <main+0x116>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdf0(%rip),%rsi
call   1070 <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    120c <main+0xbc>
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,%r13
mov    %edi,%r14d
lea    0xe98(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
add    $0x1,%ebp
mov    %r14d,%r12d
cmp    $0x2,%r14d
jl     1199 <main+0x49>
mov    $0x1,%ebx
mov    0x0(%r13,%rbx,8),%rdi
add    $0x1,%rdi
call   1040 <strlen@plt>
add    %eax,%ebp
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1180 <main+0x30>
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
lea    0xe75(%rip),%rsi
lea    0xe4f(%rip),%rbp
mov    %rax,%rdi
mov    %rbp,%rdx
call   1070 <sprintf@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%r14d
jl     120c <main+0xbc>
cltq
lea    (%rax,%r15,1),%rbp
add    $0x1,%rbp
mov    $0x1,%ebx
lea    0xe3f(%rip),%r14
mov    0x0(%r13,%rbx,8),%rdx
mov    %rbp,%rdi
mov    %r14,%rsi
call   1070 <sprintf@plt>
mov    0x0(%r13,%rbx,8),%rdi
call   1040 <strlen@plt>
cltq
add    %rax,%rbp
add    $0x1,%rbp
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11e0 <main+0x90>
mov    %r15,%rdi
call   1050 <system@plt>
mov    %eax,%ebx
mov    %r15,%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 = [31 x i8] c"/opt/robocomp/bin/rcmanager.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 ([31 x i8], [31 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 = load i8*, i8** %9
%38 = call i32 @sprintf(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%39 = call i32 @strlen(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%40 = add nsw i32 %39, 1
%41 = load i8*, i8** %9
%42 = sext i32 %40 to i64
%43 = getelementptr inbounds i8, i8* %41, i64 %42
store i8* %43, i8** %9
store i32 1, i32* %6
br label %44
44: ; preds = %66, %29
%45 = load i32, i32* %6
%46 = load i32, i32* %4
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %69
48: ; preds = %44
%49 = load i8*, i8** %9
%50 = load i8**, i8*** %5
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %50, i64 %52
%54 = load i8*, i8** %53
%55 = call i32 @sprintf(i8* %49, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %54)
%56 = load i8**, i8*** %5
%57 = load i32, i32* %6
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = call i32 @strlen(i8* %60)
%62 = add nsw i32 %61, 1
%63 = load i8*, i8** %9
%64 = sext i32 %62 to i64
%65 = getelementptr inbounds i8, i8* %63, i64 %64
store i8* %65, i8** %9
br label %66
66: ; preds = %48
%67 = load i32, i32* %6
%68 = add nsw i32 %67, 1
store i32 %68, i32* %6
br label %44
69: ; preds = %44
%70 = load i8*, i8** %8
%71 = call i32 @system(i8* %70)
store i32 %71, i32* %6
%72 = load i8*, i8** %8
%73 = call i32 @free(i8* %72)
%74 = load i32, i32* %6
ret i32 %74
}

LLVM IR (-O2):
@.str = [31 x i8] c"/opt/robocomp/bin/rcmanager.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 ([31 x i8], [31 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 @sprintf(i8* dereferenceable(1) %21, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%23 = tail call i32 @strlen(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br i1 %5, label %24, label %42
24: ; preds = %18
%25 = add nsw i32 %23, 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
}