#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 check(char *, char *);
int search(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int /*<<< orphan*/ system(char *);
int exec_command(char *fname) {
  int i;
  char c[2] = " ";
  for (i = 0; i < strlen(fname); i++) {
    if (fname[i] == '.')
      break;
    c[0] = fname[i];
  }
  char input[20] = "", output[20] = "", fl[30] = "", cmd1[100] = "";
  strcat(input, " input");
  strcat(output, " serveroutput");
  strcat(input, c);
  strcat(output, c);
  strcat(input, ".txt");
  strcat(output, ".txt");
  strcat(cmd1, "python checker1.py ");
  strcat(fl, fname);
  strcat(cmd1, fl);
  strcat(cmd1, input);
  strcat(cmd1, output);
  char *abc = "> result.txt";
  strcat(cmd1, abc);
  system(cmd1);
  int z = search("timeout", "result.txt");
  if (z == 0) {
    int x = check("result.txt", "success.txt");
    return x;
  } else
    return 2;
}


x86 assembly (clang, -O0):
<exec_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %rdi,-0x10(%rbp)
mov    0xeb1(%rip),%ax
mov    %ax,-0x16(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xf4(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0xf4(%rbp),%eax
cmp    %ecx,%eax
jge    11d9 <exec_command+0x79>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    11bd <exec_command+0x5d>
jmp    11d9 <exec_command+0x79>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x16(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1181 <exec_command+0x21>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1060 <memset@plt>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1060 <memset@plt>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1060 <memset@plt>
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1060 <memset@plt>
lea    -0x30(%rbp),%rdi
lea    0xdd9(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x50(%rbp),%rdi
lea    0xdd0(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x30(%rbp),%rdi
lea    -0x16(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0x50(%rbp),%rdi
lea    -0x16(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0x30(%rbp),%rdi
lea    0xde4(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x50(%rbp),%rdi
lea    0xdd4(%rip),%rsi
call   1080 <strcat@plt>
lea    -0xe0(%rbp),%rdi
lea    0xd91(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1080 <strcat@plt>
lea    0xd5c(%rip),%rax
mov    %rax,-0xe8(%rbp)
lea    -0xe0(%rbp),%rdi
mov    -0xe8(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0xe0(%rbp),%rdi
call   1040 <system@plt>
lea    0xd3c(%rip),%rdi
lea    0xd2a(%rip),%rsi
call   1050 <search@plt>
mov    %eax,-0xec(%rbp)
cmpl   $0x0,-0xec(%rbp)
jne    1340 <exec_command+0x1e0>
lea    0xd0b(%rip),%rdi
lea    0xd17(%rip),%rsi
call   1070 <check@plt>
mov    %eax,-0xf0(%rbp)
mov    -0xf0(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1347 <exec_command+0x1e7>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exec_command>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %rdi,%r14
movw   $0x20,0xe(%rsp)
call   1030 <strlen@plt>
mov    $0x20,%bl
test   %eax,%eax
jle    11ae <exec_command+0x5e>
mov    (%r14),%al
cmp    $0x2e,%al
je     11ae <exec_command+0x5e>
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jge    11ae <exec_command+0x5e>
movzbl (%r14,%rbp,1),%eax
add    $0x1,%rbp
cmp    $0x2e,%al
jne    1190 <exec_command+0x40>
mov    %bl,0xe(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movl   $0x0,0x40(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x20(%rsp)
movups %xmm0,0x5e(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movl   $0x0,0xd0(%rsp)
lea    0xde8(%rip),%rsi
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <strcat@plt>
lea    0xddb(%rip),%rsi
lea    0x10(%rsp),%r15
mov    %r15,%rdi
call   1070 <strcat@plt>
lea    0xe(%rsp),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
lea    0xdea(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
lea    0xd9d(%rip),%rsi
lea    0x70(%rsp),%r12
mov    %r12,%rdi
call   1070 <strcat@plt>
lea    0x50(%rsp),%r13
mov    %r13,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1070 <strcat@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1070 <strcat@plt>
lea    0xd6c(%rip),%rsi
mov    %r12,%rdi
call   1070 <strcat@plt>
mov    %r12,%rdi
call   1040 <system@plt>
lea    0xd62(%rip),%rdi
lea    0xd50(%rip),%rsi
call   1050 <search@plt>
mov    %eax,%ecx
mov    $0x2,%eax
test   %ecx,%ecx
jne    12fe <exec_command+0x1ae>
lea    0xd39(%rip),%rdi
lea    0xd45(%rip),%rsi
call   1060 <check@plt>
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.exec_command.c = [2 x i8] c" \00"
@.str = [7 x i8] c" input\00"
@.str.1 = [14 x i8] c" serveroutput\00"
@.str.2 = [5 x i8] c".txt\00"
@.str.3 = [20 x i8] c"python checker1.py \00"
@.str.4 = [13 x i8] c"> result.txt\00"
@.str.5 = [8 x i8] c"timeout\00"
@.str.6 = [11 x i8] c"result.txt\00"
@.str.7 = [12 x i8] c"success.txt\00"
define i32 @exec_command(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [2 x i8]
%6 = alloca [20 x i8]
%7 = alloca [20 x i8]
%8 = alloca [30 x i8]
%9 = alloca [100 x i8]
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %3
%13 = bitcast [2 x i8]* %5 to i8*
store i32 0, i32* %4
br label %14
14: ; preds = %35, %1
%15 = load i32, i32* %4
%16 = load i8*, i8** %3
%17 = call i32 @strlen(i8* %16)
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %38
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 46
br i1 %26, label %27, label %28
27: ; preds = %19
br label %38
28: ; preds = %19
%29 = load i8*, i8** %3
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
store i8 %33, i8* %34
br label %35
35: ; preds = %28
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
br label %14
38: ; preds = %27, %14
%39 = bitcast [20 x i8]* %6 to i8*
%40 = bitcast [20 x i8]* %7 to i8*
%41 = bitcast [30 x i8]* %8 to i8*
%42 = bitcast [100 x i8]* %9 to i8*
%43 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%44 = call i32 @strcat(i8* %43, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%45 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%46 = call i32 @strcat(i8* %45, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%47 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%48 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%49 = call i32 @strcat(i8* %47, i8* %48)
%50 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%51 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%52 = call i32 @strcat(i8* %50, i8* %51)
%53 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%54 = call i32 @strcat(i8* %53, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%55 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%56 = call i32 @strcat(i8* %55, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%57 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%58 = call i32 @strcat(i8* %57, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%59 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%60 = load i8*, i8** %3
%61 = call i32 @strcat(i8* %59, i8* %60)
%62 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%63 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%64 = call i32 @strcat(i8* %62, i8* %63)
%65 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%66 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%67 = call i32 @strcat(i8* %65, i8* %66)
%68 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%69 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%70 = call i32 @strcat(i8* %68, i8* %69)
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8** %10
%71 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%72 = load i8*, i8** %10
%73 = call i32 @strcat(i8* %71, i8* %72)
%74 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%75 = call i32 @system(i8* %74)
%76 = call i32 @search(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
store i32 %76, i32* %11
%77 = load i32, i32* %11
%78 = icmp eq i32 %77, 0
br i1 %78, label %79, label %82
79: ; preds = %38
%80 = call i32 @check(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
store i32 %80, i32* %12
%81 = load i32, i32* %12
store i32 %81, i32* %2
br label %83
82: ; preds = %38
store i32 2, i32* %2
br label %83
83: ; preds = %82, %79
%84 = load i32, i32* %2
ret i32 %84
}

LLVM IR (-O2):
@.str = [7 x i8] c" input\00"
@.str.1 = [14 x i8] c" serveroutput\00"
@.str.2 = [5 x i8] c".txt\00"
@.str.3 = [20 x i8] c"python checker1.py \00"
@.str.4 = [13 x i8] c"> result.txt\00"
@.str.5 = [8 x i8] c"timeout\00"
@.str.6 = [11 x i8] c"result.txt\00"
@.str.7 = [12 x i8] c"success.txt\00"
define i32 @exec_command(i8* %0) {
%2 = alloca i16
%3 = alloca [20 x i8]
%4 = alloca [20 x i8]
%5 = alloca [30 x i8]
%6 = alloca [100 x i8]
%7 = bitcast i16* %2 to i8*
store i16 32, i16* %2
%8 = tail call i32 @strlen(i8* %0)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %24
10: ; preds = %1
%11 = load i8, i8* %0
%12 = icmp eq i8 %11, 46
br i1 %12, label %24, label %13
13: ; preds = %10, %19
%14 = phi i64 [ %23, %19 ], [ 1, %10 ]
%15 = phi i8 [ %21, %19 ], [ %11, %10 ]
%16 = tail call i32 @strlen(i8* %0)
%17 = sext i32 %16 to i64
%18 = icmp slt i64 %14, %17
br i1 %18, label %19, label %24
19: ; preds = %13
%20 = getelementptr inbounds i8, i8* %0, i64 %14
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 46
%23 = add nuw nsw i64 %14, 1
br i1 %22, label %24, label %13
24: ; preds = %19, %13, %10, %1
%25 = phi i8 [ 32, %1 ], [ 32, %10 ], [ %15, %13 ], [ %15, %19 ]
store i8 %25, i8* %7
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%28 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%30 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%31 = call i32 @strcat(i8* %27, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%32 = call i32 @strcat(i8* %26, i8* %7)
%33 = call i32 @strcat(i8* %27, i8* %7)
%34 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%35 = call i32 @strcat(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 @strcat(i8* %29, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%37 = call i32 @strcat(i8* %28, i8* %0)
%38 = call i32 @strcat(i8* %29, i8* %28)
%39 = call i32 @strcat(i8* %29, i8* %26)
%40 = call i32 @strcat(i8* %29, i8* %27)
%41 = call i32 @strcat(i8* %29, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%42 = call i32 @system(i8* %29)
%43 = call i32 @search(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %24
%46 = call i32 @check(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
br label %47
47: ; preds = %24, %45
%48 = phi i32 [ %46, %45 ], [ 2, %24 ]
ret i32 %48
}