#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*/ SIGCHLD;
int /*<<< orphan*/ SIGPIPE;
int /*<<< orphan*/ SIG_IGN;
int broadcast_receiver_run();
char *network_get_wifi_ip_address();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
int main(int argc, char **argv) {
  const char *ip_addr;
  int result;
  signal(SIGPIPE, SIG_IGN);
  signal(SIGCHLD, SIG_IGN);
  printf("NX500 remote capture daemon\n");
  while (true) {
    ip_addr = network_get_wifi_ip_address();
    if (ip_addr == NULL) {
      sleep(1);
      continue;
    }
    printf("wifi check completed\n");
    result = broadcast_receiver_run();
    if (result == 0) {
      break;
    }
    sleep(3);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
mov    0x2e6a(%rip),%rax
mov    (%rax),%esi
call   1050 <signal@plt>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
mov    0x2e53(%rip),%rax
mov    (%rax),%esi
call   1050 <signal@plt>
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <network_get_wifi_ip_address@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c5 <main+0x75>
mov    $0x1,%edi
call   1070 <sleep@plt>
jmp    11a0 <main+0x50>
lea    0xe51(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <broadcast_receiver_run@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    11ea <main+0x9a>
jmp    11f9 <main+0xa9>
mov    $0x3,%edi
call   1070 <sleep@plt>
jmp    11a0 <main+0x50>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
mov    0x2e7f(%rip),%rbx
mov    (%rbx),%esi
call   1050 <signal@plt>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%esi
call   1050 <signal@plt>
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
lea    0xe91(%rip),%rbx
jmp    119a <main+0x4a>
nopl   (%rax)
mov    $0x1,%edi
call   1070 <sleep@plt>
xor    %eax,%eax
call   1060 <network_get_wifi_ip_address@plt>
test   %rax,%rax
je     1190 <main+0x40>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <broadcast_receiver_run@plt>
mov    $0x3,%edi
test   %eax,%eax
jne    1195 <main+0x45>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@SIGPIPE = global i32 0
@SIG_IGN = global i32 0
@SIGCHLD = global i32 0
@.str = [29 x i8] c"NX500 remote capture daemon\0A\00"
@.str.1 = [22 x i8] c"wifi check completed\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* @SIGPIPE
%9 = load i32, i32* @SIG_IGN
%10 = call i32 @signal(i32 %8, i32 %9)
%11 = load i32, i32* @SIGCHLD
%12 = load i32, i32* @SIG_IGN
%13 = call i32 @signal(i32 %11, i32 %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %2, %19, %27
%16 = call i8* (...) @network_get_wifi_ip_address()
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @sleep(i32 1)
br label %15
21: ; preds = %15
%22 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 (...) @broadcast_receiver_run()
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %21
br label %29
27: ; preds = %21
%28 = call i32 @sleep(i32 3)
br label %15
29: ; preds = %26
ret i32 0
}

LLVM IR (-O2):
@SIGPIPE = global i32 0
@SIG_IGN = global i32 0
@SIGCHLD = global i32 0
@str = [28 x i8] c"NX500 remote capture daemon\00"
@str.2 = [21 x i8] c"wifi check completed\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @SIGPIPE
%4 = load i32, i32* @SIG_IGN
%5 = tail call i32 @signal(i32 %3, i32 %4)
%6 = load i32, i32* @SIGCHLD
%7 = load i32, i32* @SIG_IGN
%8 = tail call i32 @signal(i32 %6, i32 %7)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %13, %2
%11 = tail call i8* (...) @network_get_wifi_ip_address()
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %10, %16
%14 = phi i32 [ 3, %16 ], [ 1, %10 ]
%15 = tail call i32 @sleep(i32 %14)
br label %10
16: ; preds = %10
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.2, i64 0, i64 0))
%18 = tail call i32 (...) @broadcast_receiver_run()
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %13
20: ; preds = %16
ret i32 0
}