#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*/ _ParseArgs(int, char **, int);
int /*<<< orphan*/ _QueryProcInfo(int *, int *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ malloc(int);
scalar_t__ realloc(void *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  int numprocs = 0;
  int gridsize[(6)] = {0, 0, 0, 0, 0, 0};
  int i;
  int currsize = 1024, strsize = 0;
  char *command = (char *)malloc(currsize);
  _ParseArgs(argc, argv, 1);
  _QueryProcInfo(&numprocs, gridsize);
  sprintf(command, "./%s_real -procs %d", argv[0], numprocs);
  strsize = strlen(command);
  if (strsize > currsize) {
    fprintf(stderr, "Buffer size exceeded (cannot recover).  Please contact "
                    "zpl-bugs@cs.washington.edu\n");
    exit(1);
  }
  for (i = 1; i < argc; i++) {
    if (strsize + 1 + strlen(argv[i]) > currsize) {
      currsize = 2 * strlen(command);
      command = (char *)realloc((void *)command, currsize);
    }
    strcat(command, " ");
    strcat(command, argv[i]);
  }
  system(command);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
movl   $0x400,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x38(%rbp),%edi
call   1070 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x1,%edx
call   1090 <_ParseArgs@plt>
lea    -0x30(%rbp),%rsi
lea    -0x14(%rbp),%rdi
call   10d0 <_QueryProcInfo@plt>
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x14(%rbp),%ecx
lea    0xdd6(%rip),%rsi
call   10b0 <sprintf@plt>
mov    -0x48(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x38(%rbp),%eax
jle    1266 <main+0xb6>
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
lea    0xdbd(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12f5 <main+0x145>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
add    %ecx,%eax
cmp    -0x38(%rbp),%eax
jle    12c2 <main+0x112>
mov    -0x48(%rbp),%rdi
call   1030 <strlen@plt>
shl    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x38(%rbp),%esi
call   1080 <realloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
lea    0xd9a(%rip),%rsi
call   10a0 <strcat@plt>
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   10a0 <strcat@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    126d <main+0xbd>
mov    -0x48(%rbp),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
movl   $0x0,0xc(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1080 <_ParseArgs@plt>
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   10c0 <_QueryProcInfo@plt>
mov    (%r14),%rdx
mov    0xc(%rsp),%ecx
lea    0xdfb(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x400,%eax
jg     12a8 <main+0x108>
cmp    $0x2,%ebp
jl     128f <main+0xef>
mov    %eax,%r12d
add    $0x1,%r12d
mov    %ebp,%r13d
mov    $0x400,%ebp
mov    $0x1,%r15d
jmp    1264 <main+0xc4>
nopl   0x0(%rax)
mov    %rbx,%rdi
lea    0xe1d(%rip),%rsi
call   1090 <strcat@plt>
mov    (%r14,%r15,8),%rsi
mov    %rbx,%rdi
call   1090 <strcat@plt>
add    $0x1,%r15
cmp    %r15,%r13
je     128f <main+0xef>
mov    (%r14,%r15,8),%rdi
call   1030 <strlen@plt>
add    %r12d,%eax
cmp    %ebp,%eax
jle    1240 <main+0xa0>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
add    %eax,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   1070 <realloc@plt>
mov    %rax,%rbx
jmp    1240 <main+0xa0>
mov    %rbx,%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d31(%rip),%rax
mov    (%rax),%edi
lea    0xd5c(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"./%s_real -procs %d\00"
@stderr = global i32 0
@.str.1 = [83 x i8] c"Buffer size exceeded (cannot recover). Please contact zpl-bugs@cs.washington.edu\0A\00"
@.str.2 = [2 x i8] c" \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [6 x i32]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%12 = bitcast [6 x i32]* %7 to i8*
store i32 1024, i32* %9
store i32 0, i32* %10
%13 = load i32, i32* %9
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %11
%16 = load i32, i32* %4
%17 = load i8**, i8*** %5
%18 = call i32 @_ParseArgs(i32 %16, i8** %17, i32 1)
%19 = getelementptr inbounds [6 x i32], [6 x i32]* %7, i64 0, i64 0
%20 = call i32 @_QueryProcInfo(i32* %6, i32* %19)
%21 = load i8*, i8** %11
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = load i32, i32* %6
%26 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %24, i32 %25)
%27 = load i8*, i8** %11
%28 = call i32 @strlen(i8* %27)
store i32 %28, i32* %10
%29 = load i32, i32* %10
%30 = load i32, i32* %9
%31 = icmp sgt i32 %29, %30
br i1 %31, label %32, label %36
32: ; preds = %2
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.1, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %2
store i32 1, i32* %8
br label %37
37: ; preds = %71, %36
%38 = load i32, i32* %8
%39 = load i32, i32* %4
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %74
41: ; preds = %37
%42 = load i32, i32* %10
%43 = add nsw i32 %42, 1
%44 = load i8**, i8*** %5
%45 = load i32, i32* %8
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
%48 = load i8*, i8** %47
%49 = call i32 @strlen(i8* %48)
%50 = add nsw i32 %43, %49
%51 = load i32, i32* %9
%52 = icmp sgt i32 %50, %51
br i1 %52, label %53, label %61
53: ; preds = %41
%54 = load i8*, i8** %11
%55 = call i32 @strlen(i8* %54)
%56 = mul nsw i32 2, %55
store i32 %56, i32* %9
%57 = load i8*, i8** %11
%58 = load i32, i32* %9
%59 = call i64 @realloc(i8* %57, i32 %58)
%60 = inttoptr i64 %59 to i8*
store i8* %60, i8** %11
br label %61
61: ; preds = %53, %41
%62 = load i8*, i8** %11
%63 = call i32 @strcat(i8* %62, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%64 = load i8*, i8** %11
%65 = load i8**, i8*** %5
%66 = load i32, i32* %8
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8*, i8** %65, i64 %67
%69 = load i8*, i8** %68
%70 = call i32 @strcat(i8* %64, i8* %69)
br label %71
71: ; preds = %61
%72 = load i32, i32* %8
%73 = add nsw i32 %72, 1
store i32 %73, i32* %8
br label %37
74: ; preds = %37
%75 = load i8*, i8** %11
%76 = call i32 @system(i8* %75)
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"./%s_real -procs %d\00"
@stderr = global i32 0
@.str.1 = [83 x i8] c"Buffer size exceeded (cannot recover). Please contact zpl-bugs@cs.washington.edu\0A\00"
@.str.2 = [2 x i8] c" \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca [6 x i32]
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = bitcast [6 x i32]* %4 to i8*
%7 = tail call i64 @malloc(i32 1024)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i32 @_ParseArgs(i32 %0, i8** %1, i32 1)
%10 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 0
%11 = call i32 @_QueryProcInfo(i32* %3, i32* %10)
%12 = load i8*, i8** %1
%13 = load i32, i32* %3
%14 = call i32 @sprintf(i8* dereferenceable(1) %8, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %12, i32 %13)
%15 = call i32 @strlen(i8* %8)
%16 = icmp sgt i32 %15, 1024
br i1 %16, label %22, label %17
17: ; preds = %2
%18 = icmp sgt i32 %0, 1
br i1 %18, label %19, label %48
19: ; preds = %17
%20 = add nsw i32 %15, 1
%21 = zext i32 %0 to i64
br label %26
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %19, %40
%27 = phi i64 [ 1, %19 ], [ %46, %40 ]
%28 = phi i8* [ %8, %19 ], [ %42, %40 ]
%29 = phi i32 [ 1024, %19 ], [ %41, %40 ]
%30 = getelementptr inbounds i8*, i8** %1, i64 %27
%31 = load i8*, i8** %30
%32 = call i32 @strlen(i8* %31)
%33 = add nsw i32 %20, %32
%34 = icmp sgt i32 %33, %29
br i1 %34, label %35, label %40
35: ; preds = %26
%36 = call i32 @strlen(i8* %28)
%37 = shl nsw i32 %36, 1
%38 = call i64 @realloc(i8* %28, i32 %37)
%39 = inttoptr i64 %38 to i8*
br label %40
40: ; preds = %35, %26
%41 = phi i32 [ %37, %35 ], [ %29, %26 ]
%42 = phi i8* [ %39, %35 ], [ %28, %26 ]
%43 = call i32 @strcat(i8* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%44 = load i8*, i8** %30
%45 = call i32 @strcat(i8* %42, i8* %44)
%46 = add nuw nsw i64 %27, 1
%47 = icmp eq i64 %46, %21
br i1 %47, label %48, label %26
48: ; preds = %40, %17
%49 = phi i8* [ %8, %17 ], [ %42, %40 ]
%50 = call i32 @system(i8* %49)
ret i32 0
}