#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 scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ STDERR_FILENO;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
scalar_t__ chdir(char *);
int /*<<< orphan*/ close(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ system(char *);
int main(void) {
  pid_t pid, sid;
  pid = fork();
  if (pid < 0) {
    exit(EXIT_FAILURE);
  }
  if (pid > 0) {
    exit(EXIT_SUCCESS);
  }
  close(STDIN_FILENO);
  close(STDOUT_FILENO);
  close(STDERR_FILENO);
  while (1) {
    if ((chdir("/data/misc/")) < 0) {
      exit(EXIT_FAILURE);
    }
    system("wget http://epodownload.mediatek.com/EPO.DAT");
    system("wget http://epodownload.mediatek.com/EPO.MD5");
    sleep(3600);
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1080 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jge    1193 <main+0x33>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
cmpq   $0x0,-0x10(%rbp)
jle    11ac <main+0x4c>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
call   1050 <close@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
call   1050 <close@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
call   1050 <close@plt>
lea    0xe23(%rip),%rdi
call   1030 <chdir@plt>
cmp    $0x0,%rax
jge    11fa <main+0x9a>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
lea    0xe0b(%rip),%rdi
call   1040 <system@plt>
lea    0xe2c(%rip),%rdi
call   1040 <system@plt>
mov    $0xe10,%edi
call   1070 <sleep@plt>
jmp    11d6 <main+0x76>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1080 <fork@plt>
test   %rax,%rax
jns    117f <main+0x1f>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
jne    120c <main+0xac>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
call   1050 <close@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
call   1050 <close@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
call   1050 <close@plt>
lea    0xe4a(%rip),%rdi
call   1030 <chdir@plt>
test   %rax,%rax
js     1171 <main+0x11>
lea    0xe45(%rip),%r14
lea    0xe6b(%rip),%r15
lea    0xe2b(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
call   1040 <system@plt>
mov    %r15,%rdi
call   1040 <system@plt>
mov    $0xe10,%edi
call   1070 <sleep@plt>
mov    %rbx,%rdi
call   1030 <chdir@plt>
test   %rax,%rax
jns    11e0 <main+0x80>
jmp    1171 <main+0x11>
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
@.str = [12 x i8] c"/data/misc/\00"
@.str.1 = [45 x i8] c"wget http://epodownload.mediatek.com/EPO.DAT\00"
@.str.2 = [45 x i8] c"wget http://epodownload.mediatek.com/EPO.MD5\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
store i32 0, i32* %1
%4 = call i64 (...) @fork()
store i64 %4, i64* %2
%5 = load i64, i64* %2
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = load i32, i32* @EXIT_FAILURE
%9 = call i32 @exit(i32 %8)
unreachable
10: ; preds = %0
%11 = load i64, i64* %2
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32, i32* @EXIT_SUCCESS
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %10
%17 = load i32, i32* @STDIN_FILENO
%18 = call i32 @close(i32 %17)
%19 = load i32, i32* @STDOUT_FILENO
%20 = call i32 @close(i32 %19)
%21 = load i32, i32* @STDERR_FILENO
%22 = call i32 @close(i32 %21)
br label %23
23: ; preds = %16, %29
%24 = call i64 @chdir(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %23
%30 = call i32 @system(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
%31 = call i32 @system(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 @sleep(i32 3600)
br label %23
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
@.str = [12 x i8] c"/data/misc/\00"
@.str.1 = [45 x i8] c"wget http://epodownload.mediatek.com/EPO.DAT\00"
@.str.2 = [45 x i8] c"wget http://epodownload.mediatek.com/EPO.MD5\00"
define i32 @main() {
%1 = tail call i64 (...) @fork()
%2 = icmp slt i64 %1, 0
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = load i32, i32* @EXIT_FAILURE
%5 = tail call i32 @exit(i32 %4)
unreachable
6: ; preds = %0
%7 = icmp eq i64 %1, 0
br i1 %7, label %11, label %8
8: ; preds = %6
%9 = load i32, i32* @EXIT_SUCCESS
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %6
%12 = load i32, i32* @STDIN_FILENO
%13 = tail call i32 @close(i32 %12)
%14 = load i32, i32* @STDOUT_FILENO
%15 = tail call i32 @close(i32 %14)
%16 = load i32, i32* @STDERR_FILENO
%17 = tail call i32 @close(i32 %16)
%18 = tail call i64 @chdir(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %23, %11
%21 = load i32, i32* @EXIT_FAILURE
%22 = tail call i32 @exit(i32 %21)
unreachable
23: ; preds = %11, %23
%24 = tail call i32 @system(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
%25 = tail call i32 @system(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%26 = tail call i32 @sleep(i32 3600)
%27 = tail call i64 @chdir(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%28 = icmp slt i64 %27, 0
br i1 %28, label %20, label %23
}