#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fwrite(char *, size_t, int, int /*<<< orphan*/);
scalar_t__ getchar();
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ stdout;
size_t strlen(char *);
int system(char *);
int main(int argc, char *argv[]) {
  static size_t MAXBUF = 1024;
  char sbuf[MAXBUF + 1];
  size_t len = 0;
  size_t tmp0 = (size_t)getchar();
  size_t tmp1 = (size_t)getchar();
  size_t tmp2 = (size_t)getchar();
  size_t tmp3 = (size_t)getchar();
  len = (size_t)tmp3 << 8;
  len = len + tmp2;
  len = len << 8;
  len = len + tmp1;
  len = len << 8;
  len = len + tmp0;
  if ((len < 7) || (len > MAXBUF))
    return 0;
  FILE *pFlog = NULL;
  pFlog = fopen("~/execute.log", "a");
  size_t i;
  for (i = 0; i < len; i++) {
    if (i >= MAXBUF)
      break;
    sbuf[i] = (char)getchar();
  }
  sbuf[i] = '\0';
  sbuf[len - 2] = 0;
  if (pFlog != NULL)
    fprintf(pFlog, "Exec:%s\n", sbuf + 8);
  if (system(sbuf + 8) == -1) {
    sprintf(sbuf + 4, "\"Exec Error.\"");
  } else {
    sprintf(sbuf + 4, "\"Exec Ok.\"");
  }
  len = strlen(sbuf + 4);
  tmp0 = (len & 0xFFFFFFFF);
  sbuf[0] = (char)(tmp0 & 0xff);
  tmp0 = tmp0 >> 8;
  sbuf[1] = (char)(tmp0 & 0xff);
  tmp0 = tmp0 >> 8;
  sbuf[2] = (char)(tmp0 & 0xff);
  tmp0 = tmp0 >> 8;
  sbuf[3] = (char)(tmp0 & 0xff);
  len += 4;
  fwrite(sbuf, len, 1, stdout);
  if (pFlog)
    fclose(pFlog);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ec3(%rip),%rdx
mov    %rdx,%rax
add    $0x1,%rax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
add    $0x10,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %rax,-0x40(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
shl    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
shl    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
shl    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x7,-0x28(%rbp)
jb     125c <main+0xdc>
mov    -0x28(%rbp),%rax
cmp    0x2e0a(%rip),%rax
jbe    126f <main+0xef>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    1423 <main+0x2a3>
movq   $0x0,-0x58(%rbp)
lea    0xd82(%rip),%rdi
lea    0xd89(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x58(%rbp)
movq   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    12e2 <main+0x162>
mov    -0x60(%rbp),%rax
cmp    0x2db1(%rip),%rax
jb     12ba <main+0x13a>
jmp    12e2 <main+0x162>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %rax,%rcx
mov    -0x68(%rbp),%rax
mov    %cl,%dl
mov    -0x60(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    1296 <main+0x116>
mov    -0x68(%rbp),%rax
mov    -0x60(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rcx
sub    $0x2,%rcx
movb   $0x0,(%rax,%rcx,1)
cmpq   $0x0,-0x58(%rbp)
je     131d <main+0x19d>
mov    -0x68(%rbp),%rdx
mov    -0x58(%rbp),%rdi
add    $0x8,%rdx
lea    0xcf8(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x68(%rbp),%rdi
add    $0x8,%rdi
call   1050 <system@plt>
cmp    $0xffffffff,%eax
jne    134c <main+0x1cc>
mov    -0x68(%rbp),%rdi
add    $0x4,%rdi
lea    0xcd7(%rip),%rsi
call   1090 <sprintf@plt>
jmp    1360 <main+0x1e0>
mov    -0x68(%rbp),%rdi
add    $0x4,%rdi
lea    0xccc(%rip),%rsi
call   1090 <sprintf@plt>
mov    -0x68(%rbp),%rdi
add    $0x4,%rdi
call   1040 <strlen@plt>
mov    -0x68(%rbp),%rdi
mov    %rax,-0x28(%rbp)
movabs $0xffffffff,%rax
and    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
and    $0xff,%rax
mov    %al,(%rdi)
mov    -0x30(%rbp),%rax
shr    $0x8,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
and    $0xff,%rax
mov    %al,0x1(%rdi)
mov    -0x30(%rbp),%rax
shr    $0x8,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
and    $0xff,%rax
mov    %al,0x2(%rdi)
mov    -0x30(%rbp),%rax
shr    $0x8,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
and    $0xff,%rax
mov    %al,0x3(%rdi)
mov    -0x28(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
mov    0x2beb(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   10a0 <fwrite@plt>
cmpq   $0x0,-0x58(%rbp)
je     1415 <main+0x295>
mov    -0x58(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %rax,%r12
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %rax,%rbp
mov    %rax,%r13
shl    $0x8,%r13
add    %r12,%r13
shl    $0x8,%r13
add    %rbx,%r13
shl    $0x8,%r13
lea    (%r15,%r13,1),%rax
add    $0xfffffffffffffbff,%rax
cmp    $0xfffffffffffffc06,%rax
jb     12c0 <main+0x150>
add    %r15,%r13
lea    0xe22(%rip),%rdi
lea    0xe29(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
shl    $0x18,%rbp
add    %r15,%rbp
shl    $0x10,%r12
add    %rbp,%r12
shl    $0x8,%rbx
add    %r12,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %al,(%rsp,%rbp,1)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1210 <main+0xa0>
movb   $0x0,(%rsp,%r13,1)
movb   $0x0,-0x2(%rsp,%r13,1)
test   %r14,%r14
je     1247 <main+0xd7>
lea    0x8(%rsp),%rdx
lea    0xdd1(%rip),%rsi
mov    %r14,%rdi
call   1070 <fprintf@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <system@plt>
cmp    $0xffffffff,%eax
je     1270 <main+0x100>
movabs $0x6b4f206365784522,%rax
20 4f 6b
mov    %rax,-0x4(%rbx)
movl   $0x222e6b,0x3(%rbx)
jmp    128c <main+0x11c>
movabs $0x222e726f727245,%rax
mov    %rax,0x2(%rbx)
movabs $0x7245206365784522,%rax
20 45 72
mov    %rax,-0x4(%rbx)
lea    0x4(%rsp),%rdi
call   1040 <strlen@plt>
mov    %eax,(%rsp)
lea    0x4(%rax),%rsi
mov    0x2d3c(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdi
mov    $0x1,%edx
call   1090 <fwrite@plt>
test   %r14,%r14
je     12c0 <main+0x150>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@main.MAXBUF = internal global i64 1024
@.str = [14 x i8] c"~/execute.log\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [9 x i8] c"Exec:%s\0A\00"
@.str.3 = [14 x i8] c"\22Exec Error.\22\00"
@.str.4 = [11 x i8] c"\22Exec Ok.\22\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i64, i64* @main.MAXBUF
%17 = add i64 %16, 1
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %6
%19 = alloca i8, i64 %17
store i64 %17, i64* %7
store i64 0, i64* %8
%20 = call i64 (...) @getchar()
store i64 %20, i64* %9
%21 = call i64 (...) @getchar()
store i64 %21, i64* %10
%22 = call i64 (...) @getchar()
store i64 %22, i64* %11
%23 = call i64 (...) @getchar()
store i64 %23, i64* %12
%24 = load i64, i64* %12
%25 = shl i64 %24, 8
store i64 %25, i64* %8
%26 = load i64, i64* %8
%27 = load i64, i64* %11
%28 = add i64 %26, %27
store i64 %28, i64* %8
%29 = load i64, i64* %8
%30 = shl i64 %29, 8
store i64 %30, i64* %8
%31 = load i64, i64* %8
%32 = load i64, i64* %10
%33 = add i64 %31, %32
store i64 %33, i64* %8
%34 = load i64, i64* %8
%35 = shl i64 %34, 8
store i64 %35, i64* %8
%36 = load i64, i64* %8
%37 = load i64, i64* %9
%38 = add i64 %36, %37
store i64 %38, i64* %8
%39 = load i64, i64* %8
%40 = icmp ult i64 %39, 7
br i1 %40, label %45, label %41
41: ; preds = %2
%42 = load i64, i64* %8
%43 = load i64, i64* @main.MAXBUF
%44 = icmp ugt i64 %42, %43
br i1 %44, label %45, label %46
45: ; preds = %41, %2
store i32 0, i32* %3
store i32 1, i32* %13
br label %125
46: ; preds = %41
store i32* null, i32** %14
%47 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %47, i32** %14
store i64 0, i64* %15
br label %48
48: ; preds = %62, %46
%49 = load i64, i64* %15
%50 = load i64, i64* %8
%51 = icmp ult i64 %49, %50
br i1 %51, label %52, label %65
52: ; preds = %48
%53 = load i64, i64* %15
%54 = load i64, i64* @main.MAXBUF
%55 = icmp uge i64 %53, %54
br i1 %55, label %56, label %57
56: ; preds = %52
br label %65
57: ; preds = %52
%58 = call i64 (...) @getchar()
%59 = trunc i64 %58 to i8
%60 = load i64, i64* %15
%61 = getelementptr inbounds i8, i8* %19, i64 %60
store i8 %59, i8* %61
br label %62
62: ; preds = %57
%63 = load i64, i64* %15
%64 = add i64 %63, 1
store i64 %64, i64* %15
br label %48
65: ; preds = %56, %48
%66 = load i64, i64* %15
%67 = getelementptr inbounds i8, i8* %19, i64 %66
store i8 0, i8* %67
%68 = load i64, i64* %8
%69 = sub i64 %68, 2
%70 = getelementptr inbounds i8, i8* %19, i64 %69
store i8 0, i8* %70
%71 = load i32*, i32** %14
%72 = icmp ne i32* %71, null
br i1 %72, label %73, label %77
73: ; preds = %65
%74 = load i32*, i32** %14
%75 = getelementptr inbounds i8, i8* %19, i64 8
%76 = call i32 @fprintf(i32* %74, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %75)
br label %77
77: ; preds = %73, %65
%78 = getelementptr inbounds i8, i8* %19, i64 8
%79 = call i32 @system(i8* %78)
%80 = icmp eq i32 %79, -1
br i1 %80, label %81, label %84
81: ; preds = %77
%82 = getelementptr inbounds i8, i8* %19, i64 4
%83 = call i32 @sprintf(i8* %82, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %87
84: ; preds = %77
%85 = getelementptr inbounds i8, i8* %19, i64 4
%86 = call i32 @sprintf(i8* %85, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %87
87: ; preds = %84, %81
%88 = getelementptr inbounds i8, i8* %19, i64 4
%89 = call i64 @strlen(i8* %88)
store i64 %89, i64* %8
%90 = load i64, i64* %8
%91 = and i64 %90, 4294967295
store i64 %91, i64* %9
%92 = load i64, i64* %9
%93 = and i64 %92, 255
%94 = trunc i64 %93 to i8
%95 = getelementptr inbounds i8, i8* %19, i64 0
store i8 %94, i8* %95
%96 = load i64, i64* %9
%97 = lshr i64 %96, 8
store i64 %97, i64* %9
%98 = load i64, i64* %9
%99 = and i64 %98, 255
%100 = trunc i64 %99 to i8
%101 = getelementptr inbounds i8, i8* %19, i64 1
store i8 %100, i8* %101
%102 = load i64, i64* %9
%103 = lshr i64 %102, 8
store i64 %103, i64* %9
%104 = load i64, i64* %9
%105 = and i64 %104, 255
%106 = trunc i64 %105 to i8
%107 = getelementptr inbounds i8, i8* %19, i64 2
store i8 %106, i8* %107
%108 = load i64, i64* %9
%109 = lshr i64 %108, 8
store i64 %109, i64* %9
%110 = load i64, i64* %9
%111 = and i64 %110, 255
%112 = trunc i64 %111 to i8
%113 = getelementptr inbounds i8, i8* %19, i64 3
store i8 %112, i8* %113
%114 = load i64, i64* %8
%115 = add i64 %114, 4
store i64 %115, i64* %8
%116 = load i64, i64* %8
%117 = load i32, i32* @stdout
%118 = call i32 @fwrite(i8* %19, i64 %116, i32 1, i32 %117)
%119 = load i32*, i32** %14
%120 = icmp ne i32* %119, null
br i1 %120, label %121, label %124
121: ; preds = %87
%122 = load i32*, i32** %14
%123 = call i32 @fclose(i32* %122)
br label %124
124: ; preds = %121, %87
store i32 0, i32* %3
store i32 1, i32* %13
br label %125
125: ; preds = %124, %45
%126 = load i8*, i8** %6
%127 = load i32, i32* %3
ret i32 %127
}

LLVM IR (-O2):
@.str = [14 x i8] c"~/execute.log\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [9 x i8] c"Exec:%s\0A\00"
@.str.3 = [14 x i8] c"\22Exec Error.\22\00"
@.str.4 = [11 x i8] c"\22Exec Ok.\22\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1025 x i8]
%4 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 0
%5 = tail call i64 (...) @getchar()
%6 = tail call i64 (...) @getchar()
%7 = tail call i64 (...) @getchar()
%8 = tail call i64 (...) @getchar()
%9 = shl i64 %8, 8
%10 = add i64 %9, %7
%11 = shl i64 %10, 8
%12 = add i64 %11, %6
%13 = shl i64 %12, 8
%14 = add i64 %13, %5
%15 = add i64 %14, -1025
%16 = icmp ult i64 %15, -1018
br i1 %16, label %59, label %17
17: ; preds = %2
%18 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %19
%20 = phi i64 [ %24, %19 ], [ 0, %17 ]
%21 = tail call i64 (...) @getchar()
%22 = trunc i64 %21 to i8
%23 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 %20
store i8 %22, i8* %23
%24 = add nuw i64 %20, 1
%25 = icmp eq i64 %24, %14
br i1 %25, label %26, label %19
26: ; preds = %19
%27 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 %14
store i8 0, i8* %27
%28 = add i64 %14, -2
%29 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 %28
store i8 0, i8* %29
%30 = icmp eq i32* %18, null
br i1 %30, label %34, label %31
31: ; preds = %26
%32 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 8
%33 = call i32 @fprintf(i32* %18, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %31, %26
%35 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 8
%36 = call i32 @system(i8* %35)
%37 = icmp eq i32 %36, -1
%38 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 4
br i1 %37, label %39, label %40
39: ; preds = %34
br label %41
40: ; preds = %34
br label %41
41: ; preds = %40, %39
%42 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 4
%43 = call i64 @strlen(i8* %42)
%44 = trunc i64 %43 to i8
store i8 %44, i8* %4
%45 = lshr i64 %43, 8
%46 = trunc i64 %45 to i8
%47 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 1
store i8 %46, i8* %47
%48 = lshr i64 %43, 16
%49 = trunc i64 %48 to i8
%50 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 2
store i8 %49, i8* %50
%51 = lshr i64 %43, 24
%52 = trunc i64 %51 to i8
%53 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 3
store i8 %52, i8* %53
%54 = add i64 %43, 4
%55 = load i32, i32* @stdout
%56 = call i32 @fwrite(i8* %4, i64 %54, i32 1, i32 %55)
br i1 %30, label %59, label %57
57: ; preds = %41
%58 = call i32 @fclose(i32* %18)
br label %59
59: ; preds = %41, %57, %2
ret i32 0
}