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

/* Variables and functions */
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ sys_log(char *);
int /*<<< orphan*/ system(char *);
int main() {
  FILE *stream = NULL;
  char buf[1024] = {0};
  int cnt_network_monitor_run = 0, cnt_heart_beat_run = 0,
      cnt_remote_control_run = 0;
  printf("**********************************\n");
  printf("run_daemon : start\n");
  printf("**********************************\n");
  while (1) {
    sleep(600);
    printf("---------check network_monitor_run-----------\n");
    stream = NULL;
    if ((stream = popen("ps -ef | grep 'network_monitor' | grep -v 'grep' | "
                        "grep -v 'sh -c' | awk '{print $2}' | wc -l",
                        "r")) == NULL)
      printf("popen failed\n");
    memset(buf, 0, sizeof(buf));
    fread(buf, sizeof(char), sizeof(buf), stream);
    buf[1023] = '\0';
    sscanf(buf, "%d", &cnt_network_monitor_run);
    pclose(stream);
    printf("network_monitor_run process : %d\n", cnt_network_monitor_run);
    if (cnt_network_monitor_run >= 1)
      printf("network_monitor_run : ok!\n");
    else {
      printf("network_monitror_run : down, restart again...\n");
      sys_log("network_monitor_run : down!");
      system("/ailvgo/system/box/network_monitor_run &");
      sleep(5);
    }
    printf("---------check heart_beat_run-----------\n");
    stream = NULL;
    if ((stream = popen("ps -ef | grep 'heart_beat' | grep -v 'grep' | grep -v "
                        "'sh -c' | awk '{print $2}' | wc -l",
                        "r")) == NULL)
      printf("popen failed\n");
    memset(buf, 0, sizeof(buf));
    fread(buf, sizeof(char), sizeof(buf), stream);
    buf[1023] = '\0';
    sscanf(buf, "%d", &cnt_heart_beat_run);
    pclose(stream);
    printf("heart_beat_run process : %d\n", cnt_heart_beat_run);
    if (cnt_heart_beat_run >= 1)
      printf("heart_beat_run : ok!\n");
    else {
      printf("heart_beat_run : down, restart again...\n");
      sys_log("heart_beat_run : down!");
      system("/ailvgo/system/box/heart_beat_run &");
      sleep(5);
    }
    printf("---------check remote_control_run-----------\n");
    stream = NULL;
    if ((stream = popen("ps -ef | grep 'remote_control' | grep -v 'grep' | "
                        "grep -v 'sh -c' | awk '{print $2}' | wc -l",
                        "r")) == NULL)
      printf("popen failed\n");
    memset(buf, 0, sizeof(buf));
    fread(buf, sizeof(char), sizeof(buf), stream);
    buf[1023] = '\0';
    sscanf(buf, "%d", &cnt_remote_control_run);
    pclose(stream);
    printf("remote_control_run process : %d\n", cnt_remote_control_run);
    if (cnt_remote_control_run >= 1)
      printf("remote_control_run : ok!\n");
    else {
      printf("remote_control_run : down, restart again...\n");
      sys_log("remote_control_run : down!");
      system("/ailvgo/system/box/remote_control_run &");
      sleep(5);
    }
  }
  printf("------------run_daemon : over------------\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
movl   $0x0,-0x414(%rbp)
movl   $0x0,-0x418(%rbp)
movl   $0x0,-0x41c(%rbp)
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x258,%edi
call   10b0 <sleep@plt>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movq   $0x0,-0x10(%rbp)
lea    0xe3b(%rip),%rdi
lea    0xe92(%rip),%rsi
call   1090 <popen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1254 <main+0xc4>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
movb   $0x0,-0x11(%rbp)
lea    -0x410(%rbp),%rdi
lea    0xe42(%rip),%rsi
lea    -0x414(%rbp),%rdx
call   1080 <sscanf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <pclose@plt>
mov    -0x414(%rbp),%esi
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x1,-0x414(%rbp)
jl     12dc <main+0x14c>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    130c <main+0x17c>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe53(%rip),%rdi
call   10a0 <sys_log@plt>
lea    0xe63(%rip),%rdi
call   1040 <system@plt>
mov    $0x5,%edi
call   10b0 <sleep@plt>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movq   $0x0,-0x10(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xd95(%rip),%rsi
call   1090 <popen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1351 <main+0x1c1>
lea    0xd7d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
movb   $0x0,-0x11(%rbp)
lea    -0x410(%rbp),%rdi
lea    0xd45(%rip),%rsi
lea    -0x418(%rbp),%rdx
call   1080 <sscanf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <pclose@plt>
mov    -0x418(%rbp),%esi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x1,-0x418(%rbp)
jl     13d9 <main+0x249>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1409 <main+0x279>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe7a(%rip),%rdi
call   10a0 <sys_log@plt>
lea    0xe85(%rip),%rdi
call   1040 <system@plt>
mov    $0x5,%edi
call   10b0 <sleep@plt>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movq   $0x0,-0x10(%rbp)
lea    0xeab(%rip),%rdi
lea    0xc98(%rip),%rsi
call   1090 <popen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    144e <main+0x2be>
lea    0xc80(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
movb   $0x0,-0x11(%rbp)
lea    -0x410(%rbp),%rdi
lea    0xc48(%rip),%rsi
lea    -0x41c(%rbp),%rdx
call   1080 <sscanf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <pclose@plt>
mov    -0x41c(%rbp),%esi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x1,-0x41c(%rbp)
jl     14d6 <main+0x346>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1506 <main+0x376>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeab(%rip),%rdi
call   10a0 <sys_log@plt>
lea    0xeba(%rip),%rdi
call   1040 <system@plt>
mov    $0x5,%edi
call   10b0 <sleep@plt>
jmp    1205 <main+0x75>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
lea    0x10(%rsp),%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <memset@plt>
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
lea    0x106b(%rip),%rbp
mov    %rbp,%rdi
call   1030 <puts@plt>
lea    0x1049(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
lea    0xe57(%rip),%r12
lea    0x11b2(%rip),%r13
lea    0xe4b(%rip),%r15
jmp    124e <main+0xae>
nopw   0x0(%rax,%rax,1)
lea    0x1125(%rip),%rdi
call   1030 <puts@plt>
lea    0xfc6(%rip),%rdi
call   10b0 <sys_log@plt>
lea    0xfd5(%rip),%rdi
call   1050 <system@plt>
mov    $0x5,%edi
call   10c0 <sleep@plt>
mov    $0x258,%edi
call   10c0 <sleep@plt>
lea    0x1013(%rip),%rdi
call   1030 <puts@plt>
lea    0xd95(%rip),%rdi
mov    %r12,%rsi
call   10a0 <popen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1283 <main+0xe3>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %r14,%rcx
call   1040 <fread@plt>
movb   $0x0,0x40f(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
lea    0xc(%rsp),%rdx
call   1090 <sscanf@plt>
mov    %r14,%rdi
call   1070 <pclose@plt>
mov    0xc(%rsp),%esi
lea    0xd91(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmpl   $0x0,0xc(%rsp)
jle    12f0 <main+0x150>
lea    0x10bf(%rip),%rdi
call   1030 <puts@plt>
jmp    131e <main+0x17e>
xchg   %ax,%ax
lea    0xfa9(%rip),%rdi
call   1030 <puts@plt>
lea    0xd82(%rip),%rdi
call   10b0 <sys_log@plt>
lea    0xd92(%rip),%rdi
call   1050 <system@plt>
mov    $0x5,%edi
call   10c0 <sleep@plt>
lea    0xfa9(%rip),%rdi
call   1030 <puts@plt>
lea    0xd99(%rip),%rdi
mov    %r12,%rsi
call   10a0 <popen@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1349 <main+0x1a9>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbp,%rcx
call   1040 <fread@plt>
movb   $0x0,0x40f(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
lea    0x8(%rsp),%rdx
call   1090 <sscanf@plt>
mov    %rbp,%rdi
call   1070 <pclose@plt>
mov    0x8(%rsp),%esi
lea    0xd8b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmpl   $0x0,0x8(%rsp)
jle    13c0 <main+0x220>
lea    0xfe4(%rip),%rdi
call   1030 <puts@plt>
jmp    13ee <main+0x24e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xf30(%rip),%rdi
call   1030 <puts@plt>
lea    0xd6d(%rip),%rdi
call   10b0 <sys_log@plt>
lea    0xd78(%rip),%rdi
call   1050 <system@plt>
mov    $0x5,%edi
call   10c0 <sleep@plt>
lea    0xf2a(%rip),%rdi
call   1030 <puts@plt>
lea    0xd7a(%rip),%rdi
mov    %r12,%rsi
call   10a0 <popen@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1419 <main+0x279>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbp,%rcx
call   1040 <fread@plt>
movb   $0x0,0x40f(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
lea    0x4(%rsp),%rdx
call   1090 <sscanf@plt>
mov    %rbp,%rdi
call   1070 <pclose@plt>
mov    0x4(%rsp),%esi
lea    0xd70(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1220 <main+0x80>
lea    0xef7(%rip),%rdi
call   1030 <puts@plt>
jmp    124e <main+0xae>

LLVM IR (-O0):
@.str = [36 x i8] c"**********************************\0A\00"
@.str.1 = [20 x i8] c"run_daemon : start\0A\00"
@.str.2 = [47 x i8] c"---------check network_monitor_run-----------\0A\00"
@.str.3 = [94 x i8] c"ps -ef | grep 'network_monitor' | grep -v 'grep' | grep -v 'sh -c' | awk '{print $2}' | wc -l\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [14 x i8] c"popen failed\0A\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [34 x i8] c"network_monitor_run process : %d\0A\00"
@.str.8 = [27 x i8] c"network_monitor_run : ok!\0A\00"
@.str.9 = [47 x i8] c"network_monitror_run : down, restart again...\0A\00"
@.str.10 = [28 x i8] c"network_monitor_run : down!\00"
@.str.11 = [41 x i8] c"/ailvgo/system/box/network_monitor_run &\00"
@.str.12 = [42 x i8] c"---------check heart_beat_run-----------\0A\00"
@.str.13 = [89 x i8] c"ps -ef | grep 'heart_beat' | grep -v 'grep' | grep -v 'sh -c' | awk '{print $2}' | wc -l\00"
@.str.14 = [29 x i8] c"heart_beat_run process : %d\0A\00"
@.str.15 = [22 x i8] c"heart_beat_run : ok!\0A\00"
@.str.16 = [41 x i8] c"heart_beat_run : down, restart again...\0A\00"
@.str.17 = [23 x i8] c"heart_beat_run : down!\00"
@.str.18 = [36 x i8] c"/ailvgo/system/box/heart_beat_run &\00"
@.str.19 = [46 x i8] c"---------check remote_control_run-----------\0A\00"
@.str.20 = [93 x i8] c"ps -ef | grep 'remote_control' | grep -v 'grep' | grep -v 'sh -c' | awk '{print $2}' | wc -l\00"
@.str.21 = [33 x i8] c"remote_control_run process : %d\0A\00"
@.str.22 = [26 x i8] c"remote_control_run : ok!\0A\00"
@.str.23 = [45 x i8] c"remote_control_run : down, restart again...\0A\00"
@.str.24 = [27 x i8] c"remote_control_run : down!\00"
@.str.25 = [40 x i8] c"/ailvgo/system/box/remote_control_run &\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [1024 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32* null, i32** %2
%7 = bitcast [1024 x i8]* %3 to i8*
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %0, %96
%12 = call i32 @sleep(i32 600)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
store i32* null, i32** %2
%14 = call i32* @popen(i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %14, i32** %2
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %18
18: ; preds = %16, %11
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%20 = call i32 @memset(i8* %19, i32 0, i32 1024)
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%22 = load i32*, i32** %2
%23 = call i32 @fread(i8* %21, i32 1, i32 1024, i32* %22)
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 1023
store i8 0, i8* %24
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%26 = call i32 @sscanf(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %4)
%27 = load i32*, i32** %2
%28 = call i32 @pclose(i32* %27)
%29 = load i32, i32* %4
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %4
%32 = icmp sge i32 %31, 1
br i1 %32, label %33, label %35
33: ; preds = %18
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0))
br label %40
35: ; preds = %18
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.9, i64 0, i64 0))
%37 = call i32 @sys_log(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0))
%38 = call i32 @system(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.11, i64 0, i64 0))
%39 = call i32 @sleep(i32 5)
br label %40
40: ; preds = %35, %33
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.12, i64 0, i64 0))
store i32* null, i32** %2
%42 = call i32* @popen(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %42, i32** %2
%43 = icmp eq i32* %42, null
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %46
46: ; preds = %44, %40
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%48 = call i32 @memset(i8* %47, i32 0, i32 1024)
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%50 = load i32*, i32** %2
%51 = call i32 @fread(i8* %49, i32 1, i32 1024, i32* %50)
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 1023
store i8 0, i8* %52
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%54 = call i32 @sscanf(i8* %53, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %5)
%55 = load i32*, i32** %2
%56 = call i32 @pclose(i32* %55)
%57 = load i32, i32* %5
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.14, i64 0, i64 0), i32 %57)
%59 = load i32, i32* %5
%60 = icmp sge i32 %59, 1
br i1 %60, label %61, label %63
61: ; preds = %46
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.15, i64 0, i64 0))
br label %68
63: ; preds = %46
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.16, i64 0, i64 0))
%65 = call i32 @sys_log(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0))
%66 = call i32 @system(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.18, i64 0, i64 0))
%67 = call i32 @sleep(i32 5)
br label %68
68: ; preds = %63, %61
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.19, i64 0, i64 0))
store i32* null, i32** %2
%70 = call i32* @popen(i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %70, i32** %2
%71 = icmp eq i32* %70, null
br i1 %71, label %72, label %74
72: ; preds = %68
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %74
74: ; preds = %72, %68
%75 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%76 = call i32 @memset(i8* %75, i32 0, i32 1024)
%77 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%78 = load i32*, i32** %2
%79 = call i32 @fread(i8* %77, i32 1, i32 1024, i32* %78)
%80 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 1023
store i8 0, i8* %80
%81 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%82 = call i32 @sscanf(i8* %81, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %6)
%83 = load i32*, i32** %2
%84 = call i32 @pclose(i32* %83)
%85 = load i32, i32* %6
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.21, i64 0, i64 0), i32 %85)
%87 = load i32, i32* %6
%88 = icmp sge i32 %87, 1
br i1 %88, label %89, label %91
89: ; preds = %74
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.22, i64 0, i64 0))
br label %96
91: ; preds = %74
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.23, i64 0, i64 0))
%93 = call i32 @sys_log(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.24, i64 0, i64 0))
%94 = call i32 @system(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.25, i64 0, i64 0))
%95 = call i32 @sleep(i32 5)
br label %96
96: ; preds = %91, %89
br label %11
}

LLVM IR (-O2):
@.str.3 = [94 x i8] c"ps -ef | grep 'network_monitor' | grep -v 'grep' | grep -v 'sh -c' | awk '{print $2}' | wc -l\00"
@.str.4 = [2 x i8] c"r\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [34 x i8] c"network_monitor_run process : %d\0A\00"
@.str.10 = [28 x i8] c"network_monitor_run : down!\00"
@.str.11 = [41 x i8] c"/ailvgo/system/box/network_monitor_run &\00"
@.str.13 = [89 x i8] c"ps -ef | grep 'heart_beat' | grep -v 'grep' | grep -v 'sh -c' | awk '{print $2}' | wc -l\00"
@.str.14 = [29 x i8] c"heart_beat_run process : %d\0A\00"
@.str.17 = [23 x i8] c"heart_beat_run : down!\00"
@.str.18 = [36 x i8] c"/ailvgo/system/box/heart_beat_run &\00"
@.str.20 = [93 x i8] c"ps -ef | grep 'remote_control' | grep -v 'grep' | grep -v 'sh -c' | awk '{print $2}' | wc -l\00"
@.str.21 = [33 x i8] c"remote_control_run process : %d\0A\00"
@.str.24 = [27 x i8] c"remote_control_run : down!\00"
@.str.25 = [40 x i8] c"/ailvgo/system/box/remote_control_run &\00"
@str.26 = [19 x i8] c"run_daemon : start\00"
@str.27 = [35 x i8] c"**********************************\00"
@str.28 = [46 x i8] c"---------check network_monitor_run-----------\00"
@str.29 = [46 x i8] c"network_monitror_run : down, restart again...\00"
@str.30 = [41 x i8] c"---------check heart_beat_run-----------\00"
@str.31 = [40 x i8] c"heart_beat_run : down, restart again...\00"
@str.32 = [45 x i8] c"---------check remote_control_run-----------\00"
@str.33 = [44 x i8] c"remote_control_run : down, restart again...\00"
@str.34 = [25 x i8] c"remote_control_run : ok!\00"
@str.36 = [21 x i8] c"heart_beat_run : ok!\00"
@str.38 = [26 x i8] c"network_monitor_run : ok!\00"
@str.39 = [13 x i8] c"popen failed\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%6 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.27, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.26, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.27, i64 0, i64 0))
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 1023
br label %13
13: ; preds = %80, %0
%14 = call i32 @sleep(i32 600)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.28, i64 0, i64 0))
%16 = call i32* @popen(i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.39, i64 0, i64 0))
br label %20
20: ; preds = %18, %13
%21 = call i32 @memset(i8* %5, i32 0, i32 1024)
%22 = call i32 @fread(i8* %5, i32 1, i32 1024, i32* %16)
store i8 0, i8* %12
%23 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%24 = call i32 @pclose(i32* %16)
%25 = load i32, i32* %2
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %2
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %20
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.38, i64 0, i64 0))
br label %36
31: ; preds = %20
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.29, i64 0, i64 0))
%33 = call i32 @sys_log(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0))
%34 = call i32 @system(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.11, i64 0, i64 0))
%35 = call i32 @sleep(i32 5)
br label %36
36: ; preds = %31, %29
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.30, i64 0, i64 0))
%38 = call i32* @popen(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.39, i64 0, i64 0))
br label %42
42: ; preds = %40, %36
%43 = call i32 @memset(i8* %5, i32 0, i32 1024)
%44 = call i32 @fread(i8* %5, i32 1, i32 1024, i32* %38)
store i8 0, i8* %12
%45 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%46 = call i32 @pclose(i32* %38)
%47 = load i32, i32* %3
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.14, i64 0, i64 0), i32 %47)
%49 = load i32, i32* %3
%50 = icmp sgt i32 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %42
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.36, i64 0, i64 0))
br label %58
53: ; preds = %42
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.31, i64 0, i64 0))
%55 = call i32 @sys_log(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0))
%56 = call i32 @system(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.18, i64 0, i64 0))
%57 = call i32 @sleep(i32 5)
br label %58
58: ; preds = %53, %51
%59 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.32, i64 0, i64 0))
%60 = call i32* @popen(i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%61 = icmp eq i32* %60, null
br i1 %61, label %62, label %64
62: ; preds = %58
%63 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.39, i64 0, i64 0))
br label %64
64: ; preds = %62, %58
%65 = call i32 @memset(i8* %5, i32 0, i32 1024)
%66 = call i32 @fread(i8* %5, i32 1, i32 1024, i32* %60)
store i8 0, i8* %12
%67 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %4)
%68 = call i32 @pclose(i32* %60)
%69 = load i32, i32* %4
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.21, i64 0, i64 0), i32 %69)
%71 = load i32, i32* %4
%72 = icmp sgt i32 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %64
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.34, i64 0, i64 0))
br label %80
75: ; preds = %64
%76 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.33, i64 0, i64 0))
%77 = call i32 @sys_log(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.24, i64 0, i64 0))
%78 = call i32 @system(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.25, i64 0, i64 0))
%79 = call i32 @sleep(i32 5)
br label %80
80: ; preds = %75, %73
br label %13
}