#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*/ sleep_ms(int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int system(char *);
int main(int argc, char *argv[]) {
  int a = 0;
  char init[255];
  strcpy(init, "system/"
               "div");
  strcat(init, " INIT");
  while (a++ < argc - 1) {
    strcat(init, " ");
    strcat(init, argv[a]);
  }
  int ret = system(init);
  while (ret == 1 || ret == 2 || ret == 256 || ret == 512) {
    sleep_ms(1000);
    if (ret == 1 || ret == 256) {
      system("system/"
             "divdbg"
             " system/EXEC.EXE");
      ret = system("system/"
                   "div");
    }
    sleep_ms(1000);
    if (ret == 2 || ret == 512) {
      ret = system("system/"
                   "div"
                   " TEST");
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x120(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x120(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11cf <main+0x8f>
lea    -0x120(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1060 <strcat@plt>
jmp    1186 <main+0x46>
lea    -0x120(%rbp),%rdi
call   1040 <system@plt>
mov    %eax,-0x124(%rbp)
mov    $0x1,%al
cmpl   $0x1,-0x124(%rbp)
mov    %al,-0x125(%rbp)
je     1236 <main+0xf6>
mov    $0x1,%al
cmpl   $0x2,-0x124(%rbp)
mov    %al,-0x125(%rbp)
je     1236 <main+0xf6>
mov    $0x1,%al
cmpl   $0x100,-0x124(%rbp)
mov    %al,-0x125(%rbp)
je     1236 <main+0xf6>
cmpl   $0x200,-0x124(%rbp)
sete   %al
mov    %al,-0x125(%rbp)
mov    -0x125(%rbp),%al
test   $0x1,%al
jne    1249 <main+0x109>
jmp    12cc <main+0x18c>
mov    $0x3e8,%edi
call   1050 <sleep_ms@plt>
cmpl   $0x1,-0x124(%rbp)
je     1270 <main+0x130>
cmpl   $0x100,-0x124(%rbp)
jne    128e <main+0x14e>
lea    0xd9c(%rip),%rdi
call   1040 <system@plt>
lea    0xd7d(%rip),%rdi
call   1040 <system@plt>
mov    %eax,-0x124(%rbp)
mov    $0x3e8,%edi
call   1050 <sleep_ms@plt>
cmpl   $0x2,-0x124(%rbp)
je     12b5 <main+0x175>
cmpl   $0x200,-0x124(%rbp)
jne    12c7 <main+0x187>
lea    0xd75(%rip),%rdi
call   1040 <system@plt>
mov    %eax,-0x124(%rbp)
jmp    11e1 <main+0xa1>
mov    -0x124(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%r15
mov    %edi,%ebx
lea    0xea4(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
lea    0xe9d(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcat@plt>
cmp    $0x2,%ebx
jl     11b0 <main+0x70>
mov    %ebx,%r12d
mov    $0x1,%ebx
lea    0xe87(%rip),%r14
mov    %rsp,%r13
nopl   (%rax)
mov    %r13,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
mov    (%r15,%rbx,8),%rsi
mov    %r13,%rdi
call   1060 <strcat@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1190 <main+0x50>
mov    %rsp,%rdi
call   1040 <system@plt>
mov    %eax,%ebx
lea    0xe52(%rip),%r14
lea    0xe38(%rip),%r15
lea    0xe62(%rip),%r12
jmp    11ea <main+0xaa>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1040 <system@plt>
mov    %eax,%ebx
lea    -0x1(%rbx),%eax
cmp    $0x2,%eax
jb     1202 <main+0xc2>
cmp    $0x200,%ebx
je     1202 <main+0xc2>
cmp    $0x100,%ebx
jne    1244 <main+0x104>
mov    $0x3e8,%edi
call   1050 <sleep_ms@plt>
cmp    $0x100,%ebx
je     1219 <main+0xd9>
cmp    $0x1,%ebx
jne    122b <main+0xeb>
mov    %r14,%rdi
call   1040 <system@plt>
mov    %r15,%rdi
call   1040 <system@plt>
mov    %eax,%ebx
mov    $0x3e8,%edi
call   1050 <sleep_ms@plt>
cmp    $0x200,%ebx
je     11e0 <main+0xa0>
cmp    $0x2,%ebx
je     11e0 <main+0xa0>
jmp    11ea <main+0xaa>
mov    %ebx,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"system/div\00"
@.str.1 = [6 x i8] c" INIT\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [30 x i8] c"system/divdbg system/EXEC.EXE\00"
@.str.4 = [16 x i8] c"system/div TEST\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [255 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%10 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%12 = call i32 @strcat(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %19, %2
%14 = load i32, i32* %6
%15 = add nsw i32 %14, 1
store i32 %15, i32* %6
%16 = load i32, i32* %4
%17 = sub nsw i32 %16, 1
%18 = icmp slt i32 %14, %17
br i1 %18, label %19, label %29
19: ; preds = %13
%20 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%21 = call i32 @strcat(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%22 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%23 = load i8**, i8*** %5
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 @strcat(i8* %22, i8* %27)
br label %13
29: ; preds = %13
%30 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%31 = call i32 @system(i8* %30)
store i32 %31, i32* %8
br label %32
32: ; preds = %65, %29
%33 = load i32, i32* %8
%34 = icmp eq i32 %33, 1
br i1 %34, label %44, label %35
35: ; preds = %32
%36 = load i32, i32* %8
%37 = icmp eq i32 %36, 2
br i1 %37, label %44, label %38
38: ; preds = %35
%39 = load i32, i32* %8
%40 = icmp eq i32 %39, 256
br i1 %40, label %44, label %41
41: ; preds = %38
%42 = load i32, i32* %8
%43 = icmp eq i32 %42, 512
br label %44
44: ; preds = %41, %38, %35, %32
%45 = phi i1 [ true, %38 ], [ true, %35 ], [ true, %32 ], [ %43, %41 ]
br i1 %45, label %46, label %66
46: ; preds = %44
%47 = call i32 @sleep_ms(i32 1000)
%48 = load i32, i32* %8
%49 = icmp eq i32 %48, 1
br i1 %49, label %53, label %50
50: ; preds = %46
%51 = load i32, i32* %8
%52 = icmp eq i32 %51, 256
br i1 %52, label %53, label %56
53: ; preds = %50, %46
%54 = call i32 @system(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%55 = call i32 @system(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 %55, i32* %8
br label %56
56: ; preds = %53, %50
%57 = call i32 @sleep_ms(i32 1000)
%58 = load i32, i32* %8
%59 = icmp eq i32 %58, 2
br i1 %59, label %63, label %60
60: ; preds = %56
%61 = load i32, i32* %8
%62 = icmp eq i32 %61, 512
br i1 %62, label %63, label %65
63: ; preds = %60, %56
%64 = call i32 @system(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
store i32 %64, i32* %8
br label %65
65: ; preds = %63, %60
br label %32
66: ; preds = %44
%67 = load i32, i32* %8
ret i32 %67
}

LLVM IR (-O2):
@.str = [11 x i8] c"system/div\00"
@.str.1 = [6 x i8] c" INIT\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [30 x i8] c"system/divdbg system/EXEC.EXE\00"
@.str.4 = [16 x i8] c"system/div TEST\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [255 x i8]
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %18
8: ; preds = %2
%9 = zext i32 %0 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 1, %8 ], [ %16, %10 ]
%12 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = getelementptr inbounds i8*, i8** %1, i64 %11
%14 = load i8*, i8** %13
%15 = call i32 @strcat(i8* %4, i8* %14)
%16 = add nuw nsw i64 %11, 1
%17 = icmp eq i64 %16, %9
br i1 %17, label %18, label %10
18: ; preds = %10, %2
%19 = call i32 @system(i8* %4)
br label %20
20: ; preds = %30, %18
%21 = phi i32 [ %19, %18 ], [ %31, %30 ]
switch i32 %21, label %34 [
i32 512, label %22
i32 256, label %22
i32 2, label %22
i32 1, label %22
]
22: ; preds = %20, %20, %20, %20
%23 = call i32 @sleep_ms(i32 1000)
switch i32 %21, label %27 [
i32 256, label %24
i32 1, label %24
]
24: ; preds = %22, %22
%25 = call i32 @system(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%26 = call i32 @system(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %22, %24
%28 = phi i32 [ %26, %24 ], [ %21, %22 ]
%29 = call i32 @sleep_ms(i32 1000)
switch i32 %28, label %30 [
i32 512, label %32
i32 2, label %32
]
30: ; preds = %27, %32
%31 = phi i32 [ %33, %32 ], [ %28, %27 ]
br label %20
32: ; preds = %27, %27
%33 = call i32 @system(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %30
34: ; preds = %20
ret i32 %21
}