#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 */
struct sigma_dut {
  int dummy;
};
struct sigma_conn {
  int dummy;
};
struct sigma_cmd {
  int dummy;
};

/* Variables and functions */
scalar_t__ system(char *);
int /*<<< orphan*/ usleep(int);
int cmd_power_switch_reset(struct sigma_dut *dut, struct sigma_conn *conn,
                           struct sigma_cmd *cmd) {
  if (system("killall hostapd") == 0) {
    int i;
    for (i = 0; i < 10; i++) {
      usleep(500000);
      if (system("pidof hostapd") != 0)
        break;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<cmd_power_switch_reset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xec5(%rip),%rdi
call   1030 <system@plt>
cmp    $0x0,%rax
jne    1198 <cmd_power_switch_reset+0x78>
movl   $0x0,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    1193 <cmd_power_switch_reset+0x73>
mov    $0x7a120,%edi
call   1040 <usleep@plt>
lea    0xea4(%rip),%rdi
call   1030 <system@plt>
cmp    $0x0,%rax
je     1180 <cmd_power_switch_reset+0x60>
jmp    1193 <cmd_power_switch_reset+0x73>
jmp    1185 <cmd_power_switch_reset+0x65>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1151 <cmd_power_switch_reset+0x31>
jmp    1198 <cmd_power_switch_reset+0x78>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_power_switch_reset>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <system@plt>
test   %rax,%rax
jne    1253 <cmd_power_switch_reset+0x133>
mov    $0x7a120,%edi
call   1040 <usleep@plt>
lea    0xec9(%rip),%rdi
call   1030 <system@plt>
test   %rax,%rax
jne    1253 <cmd_power_switch_reset+0x133>
mov    $0x7a120,%edi
call   1040 <usleep@plt>
lea    0xeaa(%rip),%rdi
call   1030 <system@plt>
test   %rax,%rax
jne    1253 <cmd_power_switch_reset+0x133>
mov    $0x7a120,%edi
call   1040 <usleep@plt>
lea    0xe8b(%rip),%rdi
call   1030 <system@plt>
test   %rax,%rax
jne    1253 <cmd_power_switch_reset+0x133>
mov    $0x7a120,%edi
call   1040 <usleep@plt>
lea    0xe6c(%rip),%rdi
call   1030 <system@plt>
test   %rax,%rax
jne    1253 <cmd_power_switch_reset+0x133>
mov    $0x7a120,%edi
call   1040 <usleep@plt>
lea    0xe4d(%rip),%rdi
call   1030 <system@plt>
test   %rax,%rax
jne    1253 <cmd_power_switch_reset+0x133>
mov    $0x7a120,%edi
call   1040 <usleep@plt>
lea    0xe2e(%rip),%rdi
call   1030 <system@plt>
test   %rax,%rax
jne    1253 <cmd_power_switch_reset+0x133>
mov    $0x7a120,%edi
call   1040 <usleep@plt>
lea    0xe13(%rip),%rdi
call   1030 <system@plt>
test   %rax,%rax
jne    1253 <cmd_power_switch_reset+0x133>
mov    $0x7a120,%edi
call   1040 <usleep@plt>
lea    0xdf8(%rip),%rdi
call   1030 <system@plt>
test   %rax,%rax
jne    1253 <cmd_power_switch_reset+0x133>
mov    $0x7a120,%edi
call   1040 <usleep@plt>
lea    0xddd(%rip),%rdi
call   1030 <system@plt>
test   %rax,%rax
jne    1253 <cmd_power_switch_reset+0x133>
mov    $0x7a120,%edi
call   1040 <usleep@plt>
lea    0xdc2(%rip),%rdi
call   1030 <system@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.sigma_dut = type { i32 }
%struct.sigma_conn = type { i32 }
%struct.sigma_cmd = type { i32 }
@.str = [16 x i8] c"killall hostapd\00"
@.str.1 = [14 x i8] c"pidof hostapd\00"
define i32 @cmd_power_switch_reset(%struct.sigma_dut* %0, %struct.sigma_conn* %1, %struct.sigma_cmd* %2) {
%4 = alloca %struct.sigma_dut*
%5 = alloca %struct.sigma_conn*
%6 = alloca %struct.sigma_cmd*
%7 = alloca i32
store %struct.sigma_dut* %0, %struct.sigma_dut** %4
store %struct.sigma_conn* %1, %struct.sigma_conn** %5
store %struct.sigma_cmd* %2, %struct.sigma_cmd** %6
%8 = call i64 @system(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %24
10: ; preds = %3
store i32 0, i32* %7
br label %11
11: ; preds = %20, %10
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 10
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = call i32 @usleep(i32 500000)
%16 = call i64 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
br label %23
19: ; preds = %14
br label %20
20: ; preds = %19
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 1
store i32 %22, i32* %7
br label %11
23: ; preds = %18, %11
br label %24
24: ; preds = %23, %3
ret i32 1
}

LLVM IR (-O2):
%struct.sigma_dut = type { i32 }
%struct.sigma_conn = type { i32 }
%struct.sigma_cmd = type { i32 }
@.str = [16 x i8] c"killall hostapd\00"
@.str.1 = [14 x i8] c"pidof hostapd\00"
define i32 @cmd_power_switch_reset(%struct.sigma_dut* nocapture readnone %0, %struct.sigma_conn* nocapture readnone %1, %struct.sigma_cmd* nocapture readnone %2) {
%4 = tail call i64 @system(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %45
6: ; preds = %3
%7 = tail call i32 @usleep(i32 500000)
%8 = tail call i64 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %45
10: ; preds = %6
%11 = tail call i32 @usleep(i32 500000)
%12 = tail call i64 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %45
14: ; preds = %10
%15 = tail call i32 @usleep(i32 500000)
%16 = tail call i64 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %45
18: ; preds = %14
%19 = tail call i32 @usleep(i32 500000)
%20 = tail call i64 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %45
22: ; preds = %18
%23 = tail call i32 @usleep(i32 500000)
%24 = tail call i64 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %45
26: ; preds = %22
%27 = tail call i32 @usleep(i32 500000)
%28 = tail call i64 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %45
30: ; preds = %26
%31 = tail call i32 @usleep(i32 500000)
%32 = tail call i64 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %45
34: ; preds = %30
%35 = tail call i32 @usleep(i32 500000)
%36 = tail call i64 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %34
%39 = tail call i32 @usleep(i32 500000)
%40 = tail call i64 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = tail call i32 @usleep(i32 500000)
%44 = tail call i64 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %45
45: ; preds = %42, %6, %10, %14, %18, %22, %26, %30, %34, %38, %3
ret i32 1
}