#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 */
scalar_t__ WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
int /*<<< orphan*/ sleep(int);
int system(char *);
void reload_services(void) {
  int ret;
  sleep(1);
  ret = system("/bin/pidof afpd > /dev/zero 2>&1");
  if (ret != -1 && WIFEXITED(ret) && WEXITSTATUS(ret) == 0) {
    system("/bin/kill -HUP `cat /var/run/afpd.pid` > /dev/null 2>&1");
  } else {
    system("/bin/nice -n 19 /usr/sbin/afpd -F /etc/netatalk/afpd.conf -P "
           "/var/run/afpd.pid -c 7 > /dev/null 2>&1");
  }
  system("/usr/bin/killall afpd");
  system("/usr/sbin/afpd -F /etc/netatalk/afpd.conf -P /var/run/afpd.pid -c 7");
}


x86 assembly (clang, -O0):
<reload_services>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%edi
call   1060 <sleep@plt>
lea    0xea7(%rip),%rdi
call   1030 <system@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
je     11a0 <reload_services+0x60>
mov    -0x4(%rbp),%edi
call   1050 <WIFEXITED@plt>
cmp    $0x0,%rax
je     11a0 <reload_services+0x60>
mov    -0x4(%rbp),%edi
call   1040 <WEXITSTATUS@plt>
cmp    $0x0,%rax
jne    11a0 <reload_services+0x60>
lea    0xe8b(%rip),%rdi
call   1030 <system@plt>
jmp    11ac <reload_services+0x6c>
lea    0xeb2(%rip),%rdi
call   1030 <system@plt>
lea    0xf0b(%rip),%rdi
call   1030 <system@plt>
lea    0xf15(%rip),%rdi
call   1030 <system@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reload_services>:
push   %rbx
mov    $0x1,%edi
call   1060 <sleep@plt>
lea    0xeae(%rip),%rdi
call   1030 <system@plt>
cmp    $0xffffffff,%eax
je     1176 <reload_services+0x36>
mov    %eax,%ebx
mov    %eax,%edi
call   1050 <WIFEXITED@plt>
test   %rax,%rax
je     1176 <reload_services+0x36>
mov    %ebx,%edi
call   1040 <WEXITSTATUS@plt>
test   %rax,%rax
je     119b <reload_services+0x5b>
lea    0xedc(%rip),%rdi
call   1030 <system@plt>
lea    0xf35(%rip),%rdi
call   1030 <system@plt>
lea    0xf3f(%rip),%rdi
pop    %rbx
jmp    1030 <system@plt>
lea    0xe7f(%rip),%rdi
jmp    117d <reload_services+0x3d>

LLVM IR (-O0):
@.str = [33 x i8] c"/bin/pidof afpd > /dev/zero 2>&1\00"
@.str.1 = [56 x i8] c"/bin/kill -HUP `cat /var/run/afpd.pid` > /dev/null 2>&1\00"
@.str.2 = [101 x i8] c"/bin/nice -n 19 /usr/sbin/afpd -F /etc/netatalk/afpd.conf -P /var/run/afpd.pid -c 7 > /dev/null 2>&1\00"
@.str.3 = [22 x i8] c"/usr/bin/killall afpd\00"
@.str.4 = [68 x i8] c"/usr/sbin/afpd -F /etc/netatalk/afpd.conf -P /var/run/afpd.pid -c 7\00"
define void @reload_services() {
%1 = alloca i32
%2 = call i32 @sleep(i32 1)
%3 = call i32 @system(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i32 %3, i32* %1
%4 = load i32, i32* %1
%5 = icmp ne i32 %4, -1
br i1 %5, label %6, label %16
6: ; preds = %0
%7 = load i32, i32* %1
%8 = call i64 @WIFEXITED(i32 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %6
%11 = load i32, i32* %1
%12 = call i64 @WEXITSTATUS(i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @system(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
br label %18
16: ; preds = %10, %6, %0
%17 = call i32 @system(i8* getelementptr inbounds ([101 x i8], [101 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %14
%19 = call i32 @system(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 @system(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"/bin/pidof afpd > /dev/zero 2>&1\00"
@.str.1 = [56 x i8] c"/bin/kill -HUP `cat /var/run/afpd.pid` > /dev/null 2>&1\00"
@.str.2 = [101 x i8] c"/bin/nice -n 19 /usr/sbin/afpd -F /etc/netatalk/afpd.conf -P /var/run/afpd.pid -c 7 > /dev/null 2>&1\00"
@.str.3 = [22 x i8] c"/usr/bin/killall afpd\00"
@.str.4 = [68 x i8] c"/usr/sbin/afpd -F /etc/netatalk/afpd.conf -P /var/run/afpd.pid -c 7\00"
define void @reload_services() {
%1 = tail call i32 @sleep(i32 1)
%2 = tail call i32 @system(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, -1
br i1 %3, label %10, label %4
4: ; preds = %0
%5 = tail call i64 @WIFEXITED(i32 %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i64 @WEXITSTATUS(i32 %2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %7, %4, %0
br label %11
11: ; preds = %7, %10
%12 = phi i8* [ getelementptr inbounds ([101 x i8], [101 x i8]* @.str.2, i64 0, i64 0), %10 ], [ getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), %7 ]
%13 = tail call i32 @system(i8* %12)
%14 = tail call i32 @system(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%15 = tail call i32 @system(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.4, i64 0, i64 0))
ret void
}