#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 O_RDWR;
int O_TRUNC;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ file_get_contents(char *, char *);
int /*<<< orphan*/ file_put_contents(char *, char *, int /*<<< orphan*/);
char *get(int);
int open(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ strlen(char *);
scalar_t__ strstr(char *, char *);
int /*<<< orphan*/ system(char *);
int main(void) {
  char *rb = get(0);
  char *wb = get(1);
  char *script_file = get(2);
  char *input = get(3);
  char *output = get(4);
  char *errput = get(5);
  char *cmd = get(6);
  char *end = get(7);
  char *quit = get(8);
  char *dumb = get(9);
  char script[4096];
  int fid0;
  int fid1;
  int fid2;
  printf("%s\n", rb);
  printf("%s\n", wb);
  printf("%s\n", script_file);
  printf("%s\n", input);
  printf("%s\n", output);
  printf("%s\n", errput);
  printf("%s\n", cmd);
  printf("%s\n", end);
  printf("%s\n", quit);
  printf("%s\n", dumb);
  while (1) {
    file_get_contents(script_file, script);
    if (strstr(script, end)) {
      if (strstr(script, quit)) {
        file_put_contents(script_file, dumb, strlen(dumb));
        break;
      } else {
        fid0 = open(input, O_RDWR);
        fid1 = open(output, O_RDWR | O_TRUNC);
        fid2 = open(errput, O_RDWR | O_TRUNC);
        system(cmd);
        file_put_contents(script_file, dumb, strlen(dumb));
        close(fid0);
        close(fid1);
        close(fid2);
      }
    }
    sleep(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1090,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1090 <get@plt>
mov    %rax,-0x10(%rbp)
mov    $0x1,%edi
call   1090 <get@plt>
mov    %rax,-0x18(%rbp)
mov    $0x2,%edi
call   1090 <get@plt>
mov    %rax,-0x20(%rbp)
mov    $0x3,%edi
call   1090 <get@plt>
mov    %rax,-0x28(%rbp)
mov    $0x4,%edi
call   1090 <get@plt>
mov    %rax,-0x30(%rbp)
mov    $0x5,%edi
call   1090 <get@plt>
mov    %rax,-0x38(%rbp)
mov    $0x6,%edi
call   1090 <get@plt>
mov    %rax,-0x40(%rbp)
mov    $0x7,%edi
call   1090 <get@plt>
mov    %rax,-0x48(%rbp)
mov    $0x8,%edi
call   1090 <get@plt>
mov    %rax,-0x50(%rbp)
mov    $0x9,%edi
call   1090 <get@plt>
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xdba(%rip),%rdi
call   1060 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xdaa(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xd9a(%rip),%rdi
call   1060 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xd8a(%rip),%rdi
call   1060 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xd7a(%rip),%rdi
call   1060 <printf@plt>
mov    -0x38(%rbp),%rsi
lea    0xd6a(%rip),%rdi
call   1060 <printf@plt>
mov    -0x40(%rbp),%rsi
lea    0xd5a(%rip),%rdi
call   1060 <printf@plt>
mov    -0x48(%rbp),%rsi
lea    0xd4a(%rip),%rdi
call   1060 <printf@plt>
mov    -0x50(%rbp),%rsi
lea    0xd3a(%rip),%rdi
call   1060 <printf@plt>
mov    -0x58(%rbp),%rsi
lea    0xd2a(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x1060(%rbp),%rsi
call   1080 <file_get_contents@plt>
lea    -0x1060(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   10c0 <strstr@plt>
cmp    $0x0,%rax
je     1415 <main+0x275>
lea    -0x1060(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   10c0 <strstr@plt>
cmp    $0x0,%rax
je     1358 <main+0x1b8>
mov    -0x20(%rbp),%rax
mov    %rax,-0x1080(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x1078(%rbp)
mov    -0x58(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x1080(%rbp),%rdi
mov    -0x1078(%rbp),%rsi
mov    %eax,%edx
call   1040 <file_put_contents@plt>
jmp    1424 <main+0x284>
mov    -0x28(%rbp),%rdi
mov    0x2c7d(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x1064(%rbp)
mov    -0x30(%rbp),%rdi
mov    0x2c65(%rip),%rax
mov    (%rax),%esi
mov    0x2c74(%rip),%rax
or     (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x1068(%rbp)
mov    -0x38(%rbp),%rdi
mov    0x2c44(%rip),%rax
mov    (%rax),%esi
mov    0x2c53(%rip),%rax
or     (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x106c(%rbp)
mov    -0x40(%rbp),%rdi
call   1050 <system@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x1090(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x1088(%rbp)
mov    -0x58(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x1090(%rbp),%rdi
mov    -0x1088(%rbp),%rsi
mov    %eax,%edx
call   1040 <file_put_contents@plt>
mov    -0x1064(%rbp),%edi
call   1070 <close@plt>
mov    -0x1068(%rbp),%edi
call   1070 <close@plt>
mov    -0x106c(%rbp),%edi
call   1070 <close@plt>
jmp    1415 <main+0x275>
mov    $0x1,%edi
call   10b0 <sleep@plt>
jmp    12db <main+0x13b>
xor    %eax,%eax
add    $0x1090,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1048,%rsp
xor    %edi,%edi
call   1090 <get@plt>
mov    %rax,(%rsp)
mov    $0x1,%edi
call   1090 <get@plt>
mov    %rax,0x10(%rsp)
mov    $0x2,%edi
call   1090 <get@plt>
mov    %rax,0x8(%rsp)
mov    $0x3,%edi
call   1090 <get@plt>
mov    %rax,0x20(%rsp)
mov    $0x4,%edi
call   1090 <get@plt>
mov    %rax,0x18(%rsp)
mov    $0x5,%edi
call   1090 <get@plt>
mov    %rax,%rbx
mov    $0x6,%edi
call   1090 <get@plt>
mov    %rax,%rbp
mov    $0x7,%edi
call   1090 <get@plt>
mov    %rax,%r14
mov    $0x8,%edi
call   1090 <get@plt>
mov    %rax,%r13
mov    $0x9,%edi
call   1090 <get@plt>
mov    %rax,%r15
lea    0xdc0(%rip),%r12
mov    %r12,%rdi
mov    (%rsp),%rsi
call   1060 <printf@plt>
mov    %r12,%rdi
mov    0x10(%rsp),%rsi
call   1060 <printf@plt>
mov    %r12,%rdi
mov    0x8(%rsp),%rsi
call   1060 <printf@plt>
mov    %r12,%rdi
mov    0x20(%rsp),%rsi
call   1060 <printf@plt>
mov    %r12,%rdi
mov    0x18(%rsp),%rsi
call   1060 <printf@plt>
mov    %r12,%rdi
mov    %rbx,0x30(%rsp)
mov    %rbx,%rsi
call   1060 <printf@plt>
mov    %r12,%rdi
mov    %rbp,0x28(%rsp)
mov    %rbp,%rsi
call   1060 <printf@plt>
mov    %r12,%rdi
mov    %r14,0x10(%rsp)
mov    %r14,%rsi
call   1060 <printf@plt>
mov    %r12,%rdi
mov    %r13,0x38(%rsp)
mov    %r13,%rsi
call   1060 <printf@plt>
mov    %r12,%rdi
mov    %r15,(%rsp)
mov    %r15,%rsi
call   1060 <printf@plt>
lea    0x40(%rsp),%r12
mov    (%rsp),%r14
jmp    12ea <main+0x14a>
nopw   0x0(%rax,%rax,1)
mov    $0x1,%edi
call   10b0 <sleep@plt>
mov    0x8(%rsp),%rdi
mov    %r12,%rsi
call   1080 <file_get_contents@plt>
mov    %r12,%rdi
mov    0x10(%rsp),%rsi
call   10c0 <strstr@plt>
test   %rax,%rax
je     12e0 <main+0x140>
mov    %r12,%rdi
mov    0x38(%rsp),%rsi
call   10c0 <strstr@plt>
test   %rax,%rax
jne    1399 <main+0x1f9>
mov    0x2cbe(%rip),%rbp
mov    0x0(%rbp),%esi
mov    0x20(%rsp),%rdi
call   10a0 <open@plt>
mov    %eax,%r13d
mov    0x2cbf(%rip),%rbx
mov    (%rbx),%esi
or     0x0(%rbp),%esi
mov    0x18(%rsp),%rdi
call   10a0 <open@plt>
mov    %eax,%r15d
mov    (%rbx),%esi
or     0x0(%rbp),%esi
mov    0x30(%rsp),%rdi
call   10a0 <open@plt>
mov    %eax,%ebp
mov    0x28(%rsp),%rdi
call   1050 <system@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    0x8(%rsp),%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <file_put_contents@plt>
mov    %r13d,%edi
call   1070 <close@plt>
mov    %r15d,%edi
call   1070 <close@plt>
mov    %ebp,%edi
call   1070 <close@plt>
jmp    12e0 <main+0x140>
mov    (%rsp),%rbp
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    0x8(%rsp),%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <file_put_contents@plt>
xor    %eax,%eax
add    $0x1048,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca [4096 x i8]
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %1
%16 = call i8* @get(i32 0)
store i8* %16, i8** %2
%17 = call i8* @get(i32 1)
store i8* %17, i8** %3
%18 = call i8* @get(i32 2)
store i8* %18, i8** %4
%19 = call i8* @get(i32 3)
store i8* %19, i8** %5
%20 = call i8* @get(i32 4)
store i8* %20, i8** %6
%21 = call i8* @get(i32 5)
store i8* %21, i8** %7
%22 = call i8* @get(i32 6)
store i8* %22, i8** %8
%23 = call i8* @get(i32 7)
store i8* %23, i8** %9
%24 = call i8* @get(i32 8)
store i8* %24, i8** %10
%25 = call i8* @get(i32 9)
store i8* %25, i8** %11
%26 = load i8*, i8** %2
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = load i8*, i8** %3
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %28)
%30 = load i8*, i8** %4
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %30)
%32 = load i8*, i8** %5
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %32)
%34 = load i8*, i8** %6
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %34)
%36 = load i8*, i8** %7
%37 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %36)
%38 = load i8*, i8** %8
%39 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %38)
%40 = load i8*, i8** %9
%41 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %40)
%42 = load i8*, i8** %10
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %42)
%44 = load i8*, i8** %11
%45 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %44)
br label %46
46: ; preds = %0, %93
%47 = load i8*, i8** %4
%48 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%49 = call i32 @file_get_contents(i8* %47, i8* %48)
%50 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%51 = load i8*, i8** %9
%52 = call i64 @strstr(i8* %50, i8* %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %93
54: ; preds = %46
%55 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%56 = load i8*, i8** %10
%57 = call i64 @strstr(i8* %55, i8* %56)
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %65
59: ; preds = %54
%60 = load i8*, i8** %4
%61 = load i8*, i8** %11
%62 = load i8*, i8** %11
%63 = call i32 @strlen(i8* %62)
%64 = call i32 @file_put_contents(i8* %60, i8* %61, i32 %63)
br label %95
65: ; preds = %54
%66 = load i8*, i8** %5
%67 = load i32, i32* @O_RDWR
%68 = call i32 @open(i8* %66, i32 %67)
store i32 %68, i32* %13
%69 = load i8*, i8** %6
%70 = load i32, i32* @O_RDWR
%71 = load i32, i32* @O_TRUNC
%72 = or i32 %70, %71
%73 = call i32 @open(i8* %69, i32 %72)
store i32 %73, i32* %14
%74 = load i8*, i8** %7
%75 = load i32, i32* @O_RDWR
%76 = load i32, i32* @O_TRUNC
%77 = or i32 %75, %76
%78 = call i32 @open(i8* %74, i32 %77)
store i32 %78, i32* %15
%79 = load i8*, i8** %8
%80 = call i32 @system(i8* %79)
%81 = load i8*, i8** %4
%82 = load i8*, i8** %11
%83 = load i8*, i8** %11
%84 = call i32 @strlen(i8* %83)
%85 = call i32 @file_put_contents(i8* %81, i8* %82, i32 %84)
%86 = load i32, i32* %13
%87 = call i32 @close(i32 %86)
%88 = load i32, i32* %14
%89 = call i32 @close(i32 %88)
%90 = load i32, i32* %15
%91 = call i32 @close(i32 %90)
br label %92
92: ; preds = %65
br label %93
93: ; preds = %92, %46
%94 = call i32 @sleep(i32 1)
br label %46
95: ; preds = %59
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
define i32 @main() {
%1 = alloca [4096 x i8]
%2 = tail call i8* @get(i32 0)
%3 = tail call i8* @get(i32 1)
%4 = tail call i8* @get(i32 2)
%5 = tail call i8* @get(i32 3)
%6 = tail call i8* @get(i32 4)
%7 = tail call i8* @get(i32 5)
%8 = tail call i8* @get(i32 6)
%9 = tail call i8* @get(i32 7)
%10 = tail call i8* @get(i32 8)
%11 = tail call i8* @get(i32 9)
%12 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%13 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %5)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %6)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %7)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %8)
%20 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %9)
%21 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %10)
%22 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %23
23: ; preds = %50, %0
%24 = call i32 @file_get_contents(i8* %4, i8* %12)
%25 = call i64 @strstr(i8* %12, i8* %9)
%26 = icmp eq i64 %25, 0
br i1 %26, label %50, label %27
27: ; preds = %23
%28 = call i64 @strstr(i8* %12, i8* %10)
%29 = icmp eq i64 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = call i32 @strlen(i8* %11)
%32 = call i32 @file_put_contents(i8* %4, i8* %11, i32 %31)
ret i32 0
33: ; preds = %27
%34 = load i32, i32* @O_RDWR
%35 = call i32 @open(i8* %5, i32 %34)
%36 = load i32, i32* @O_RDWR
%37 = load i32, i32* @O_TRUNC
%38 = or i32 %37, %36
%39 = call i32 @open(i8* %6, i32 %38)
%40 = load i32, i32* @O_RDWR
%41 = load i32, i32* @O_TRUNC
%42 = or i32 %41, %40
%43 = call i32 @open(i8* %7, i32 %42)
%44 = call i32 @system(i8* %8)
%45 = call i32 @strlen(i8* %11)
%46 = call i32 @file_put_contents(i8* %4, i8* %11, i32 %45)
%47 = call i32 @close(i32 %35)
%48 = call i32 @close(i32 %39)
%49 = call i32 @close(i32 %43)
br label %50
50: ; preds = %33, %23
%51 = call i32 @sleep(i32 1)
br label %23
}