#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*/ close(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strcat(char *, char *);
int system(char *);
int main(int argc, char **argv) {
  int i = 0;
  char cmd[500];
  memset(cmd, 0, 500);
  for (i = 3; i < 1024; i++) {
    close(i);
  }
  for (i = 1; i < argc; i++) {
    strcat(cmd, argv[i]);
    strcat(cmd, " ");
  }
  return system(cmd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x210(%rbp),%rdi
xor    %esi,%esi
mov    $0x1f4,%edx
call   1040 <memset@plt>
movl   $0x3,-0x14(%rbp)
cmpl   $0x400,-0x14(%rbp)
jge    119d <main+0x5d>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117a <main+0x3a>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e9 <main+0xa9>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rdi
lea    0xe2a(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a4 <main+0x64>
lea    -0x210(%rbp),%rdi
call   1030 <system@plt>
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x200,%rsp
mov    %rsi,%r15
mov    %edi,%r14d
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x1f4,%edx
call   1040 <memset@plt>
mov    $0x3,%ebp
nopl   0x0(%rax)
mov    %ebp,%edi
call   1050 <close@plt>
add    $0x1,%ebp
cmp    $0x400,%ebp
jne    1170 <main+0x30>
cmp    $0x2,%r14d
jl     11c0 <main+0x80>
mov    %r14d,%r12d
mov    $0x1,%ebx
mov    %rsp,%rbp
lea    0xe66(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rsi
mov    %rbp,%rdi
call   1060 <strcat@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11a0 <main+0x60>
mov    %rsp,%rdi
call   1030 <system@plt>
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [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 [500 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%8 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i32 0, i32 500)
store i32 3, i32* %6
br label %10
10: ; preds = %16, %2
%11 = load i32, i32* %6
%12 = icmp slt i32 %11, 1024
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = load i32, i32* %6
%15 = call i32 @close(i32 %14)
br label %16
16: ; preds = %13
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 1
store i32 %18, i32* %6
br label %10
19: ; preds = %10
store i32 1, i32* %6
br label %20
20: ; preds = %34, %19
%21 = load i32, i32* %6
%22 = load i32, i32* %4
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %37
24: ; preds = %20
%25 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%26 = load i8**, i8*** %5
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 @strcat(i8* %25, i8* %30)
%32 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%33 = call i32 @strcat(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %34
34: ; preds = %24
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %20
37: ; preds = %20
%38 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%39 = call i32 @system(i8* %38)
ret i32 %39
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [500 x i8]
%4 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 0, i32 500)
br label %10
6: ; preds = %10
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %23
8: ; preds = %6
%9 = zext i32 %0 to i64
br label %15
10: ; preds = %2, %10
%11 = phi i32 [ 3, %2 ], [ %13, %10 ]
%12 = call i32 @close(i32 %11)
%13 = add nuw nsw i32 %11, 1
%14 = icmp eq i32 %13, 1024
br i1 %14, label %6, label %10
15: ; preds = %8, %15
%16 = phi i64 [ 1, %8 ], [ %21, %15 ]
%17 = getelementptr inbounds i8*, i8** %1, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 @strcat(i8* %4, i8* %18)
%20 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%21 = add nuw nsw i64 %16, 1
%22 = icmp eq i64 %21, %9
br i1 %22, label %23, label %15
23: ; preds = %15, %6
%24 = call i32 @system(i8* %4)
ret i32 %24
}