#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*/ time_t;

/* Variables and functions */
char *convert_time(int /*<<< orphan*/);
int /*<<< orphan*/ difftime(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
scalar_t__ getc(int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int stringLen(char *);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *args[]) {
  if (argc < 1)
    return 0;
  if (!args[1]) {
    system("title: Open with cmd v1.0");
    fputs("Open with cmd: No input files.\n", stdout);
    system("echo Open with cmd: You will be redirected to Command Prompt. & "
           "echo.");
    system("cmd.exe");
    return 0;
  }
  do {
    system("cls");
    char command[stringLen(args[1])];
    sprintf(command, "title: %s", args[1]);
    system(command);
    command[0] = 0;
    sprintf(command, "\"%s\"", args[1]);
    time_t start;
    time(&start);
    system(command);
    time_t end;
    time(&end);
    fprintf(stdout,
            "\nProcess ended in %s-----------------------------\nOpened by "
            "Open with cmd.\nPress any key to run again...",
            convert_time(difftime(end, start)));
  } while (getc(stdin));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    11bc <main+0x2c>
movl   $0x0,-0x4(%rbp)
jmp    12fc <main+0x16c>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    1210 <main+0x80>
lea    0xe2e(%rip),%rdi
call   1040 <system@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%esi
lea    0xe33(%rip),%rdi
call   1070 <fputs@plt>
lea    0xe47(%rip),%rdi
call   1040 <system@plt>
lea    0xe81(%rip),%rdi
call   1040 <system@plt>
movl   $0x0,-0x4(%rbp)
jmp    12fc <main+0x16c>
jmp    1215 <main+0x85>
lea    0xe6c(%rip),%rdi
call   1040 <system@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <stringLen@plt>
mov    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe2a(%rip),%rsi
call   10a0 <sprintf@plt>
mov    -0x38(%rbp),%rdi
call   1040 <system@plt>
mov    -0x38(%rbp),%rdi
movb   $0x0,(%rdi)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe10(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x24(%rbp),%rdi
call   1090 <time@plt>
mov    -0x38(%rbp),%rdi
call   1040 <system@plt>
lea    -0x28(%rbp),%rdi
call   1090 <time@plt>
mov    0x2d2b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1050 <difftime@plt>
mov    %eax,%edi
call   1030 <convert_time@plt>
mov    -0x2c(%rbp),%edi
mov    %rax,%rdx
lea    0xdca(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    0x2d04(%rip),%rax
mov    (%rax),%edi
call   10b0 <getc@plt>
cmp    $0x0,%rax
jne    1215 <main+0x85>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    12bf <main+0x12f>
mov    %rsi,%r13
cmpq   $0x0,0x8(%rsi)
je     1286 <main+0xf6>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xec1(%rip),%rdi
call   1040 <system@plt>
mov    0x8(%r13),%rdi
call   1060 <stringLen@plt>
mov    %rsp,%r14
mov    %eax,%ebx
mov    %rsp,%r15
add    $0xf,%rbx
and    $0xfffffffffffffff0,%rbx
mov    %r15,%r12
sub    %rbx,%r12
mov    %r12,%rsp
neg    %rbx
mov    0x8(%r13),%rdx
mov    %r12,%rdi
lea    0xe8d(%rip),%rsi
call   10a0 <sprintf@plt>
mov    %r12,%rdi
call   1040 <system@plt>
movb   $0x0,(%r15,%rbx,1)
mov    0x8(%r13),%rdx
mov    %r12,%rdi
lea    0xe77(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x30(%rbp),%rdi
call   1090 <time@plt>
mov    %r12,%rdi
call   1040 <system@plt>
lea    -0x2c(%rbp),%rdi
call   1090 <time@plt>
mov    0x2d93(%rip),%rax
mov    (%rax),%ebx
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1050 <difftime@plt>
mov    %eax,%edi
call   1030 <convert_time@plt>
mov    %ebx,%edi
lea    0xe39(%rip),%rsi
mov    %rax,%rdx
call   1080 <fprintf@plt>
mov    %r14,%rsp
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
call   10b0 <getc@plt>
test   %rax,%rax
jne    11c0 <main+0x30>
jmp    12bf <main+0x12f>
lea    0xd73(%rip),%rdi
call   1040 <system@plt>
mov    0x2d3f(%rip),%rax
mov    (%rax),%esi
lea    0xd78(%rip),%rdi
call   1070 <fputs@plt>
lea    0xd8c(%rip),%rdi
call   1040 <system@plt>
lea    0xdc6(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"title: Open with cmd v1.0\00"
@.str.1 = [32 x i8] c"Open with cmd: No input files.\0A\00"
@stdout = global i32 0
@.str.2 = [70 x i8] c"echo Open with cmd: You will be redirected to Command Prompt. & echo.\00"
@.str.3 = [8 x i8] c"cmd.exe\00"
@.str.4 = [4 x i8] c"cls\00"
@.str.5 = [10 x i8] c"title: %s\00"
@.str.6 = [5 x i8] c"\22%s\22\00"
@.str.7 = [105 x i8] c"\0AProcess ended in %s-----------------------------\0AOpened by Open with cmd.\0APress any key to run again...\00"
@stdin = 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 i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 0, i32* %3
br label %59
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = icmp ne i8* %16, null
br i1 %17, label %24, label %18
18: ; preds = %13
%19 = call i32 @system(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%20 = load i32, i32* @stdout
%21 = call i32 @fputs(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = call i32 @system(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %59
24: ; preds = %13
br label %25
25: ; preds = %54, %24
%26 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @stringLen(i8* %29)
%31 = zext i32 %30 to i64
%32 = call i8* @llvm.stacksave()
store i8* %32, i8** %6
%33 = alloca i8, i64 %31
store i64 %31, i64* %7
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i32 @sprintf(i8* %33, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %36)
%38 = call i32 @system(i8* %33)
%39 = getelementptr inbounds i8, i8* %33, i64 0
store i8 0, i8* %39
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i32 @sprintf(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %42)
%44 = call i32 @time(i32* %8)
%45 = call i32 @system(i8* %33)
%46 = call i32 @time(i32* %9)
%47 = load i32, i32* @stdout
%48 = load i32, i32* %9
%49 = load i32, i32* %8
%50 = call i32 @difftime(i32 %48, i32 %49)
%51 = call i8* @convert_time(i32 %50)
%52 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([105 x i8], [105 x i8]* @.str.7, i64 0, i64 0), i8* %51)
%53 = load i8*, i8** %6
br label %54
54: ; preds = %25
%55 = load i32, i32* @stdin
%56 = call i64 @getc(i32 %55)
%57 = icmp ne i64 %56, 0
br i1 %57, label %25, label %58
58: ; preds = %54
store i32 0, i32* %3
br label %59
59: ; preds = %58, %18, %12
%60 = load i32, i32* %3
ret i32 %60
}

LLVM IR (-O2):
@.str = [26 x i8] c"title: Open with cmd v1.0\00"
@.str.1 = [32 x i8] c"Open with cmd: No input files.\0A\00"
@stdout = global i32 0
@.str.2 = [70 x i8] c"echo Open with cmd: You will be redirected to Command Prompt. & echo.\00"
@.str.3 = [8 x i8] c"cmd.exe\00"
@.str.4 = [4 x i8] c"cls\00"
@.str.5 = [10 x i8] c"title: %s\00"
@.str.6 = [5 x i8] c"\22%s\22\00"
@.str.7 = [105 x i8] c"\0AProcess ended in %s-----------------------------\0AOpened by Open with cmd.\0APress any key to run again...\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = icmp slt i32 %0, 1
br i1 %5, label %43, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = bitcast i32* %3 to i8*
%12 = bitcast i32* %4 to i8*
br label %19
13: ; preds = %6
%14 = tail call i32 @system(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @stdout
%16 = tail call i32 @fputs(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = tail call i32 @system(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.2, i64 0, i64 0))
%18 = tail call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %43
19: ; preds = %10, %19
%20 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%21 = load i8*, i8** %7
%22 = call i32 @stringLen(i8* %21)
%23 = zext i32 %22 to i64
%24 = call i8* @llvm.stacksave()
%25 = alloca i8, i64 %23
%26 = load i8*, i8** %7
%27 = call i32 @sprintf(i8* %25, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %26)
%28 = call i32 @system(i8* %25)
store i8 0, i8* %25
%29 = load i8*, i8** %7
%30 = call i32 @sprintf(i8* %25, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %29)
%31 = call i32 @time(i32* %3)
%32 = call i32 @system(i8* %25)
%33 = call i32 @time(i32* %4)
%34 = load i32, i32* @stdout
%35 = load i32, i32* %4
%36 = load i32, i32* %3
%37 = call i32 @difftime(i32 %35, i32 %36)
%38 = call i8* @convert_time(i32 %37)
%39 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([105 x i8], [105 x i8]* @.str.7, i64 0, i64 0), i8* %38)
%40 = load i32, i32* @stdin
%41 = call i64 @getc(i32 %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %19
43: ; preds = %19, %2, %13
ret i32 0
}