#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*/ sigset_t;

/* Variables and functions */
int /*<<< orphan*/ SIGCHLD;
int /*<<< orphan*/ SIGUSR2;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sigwait(int /*<<< orphan*/ *, int *);
scalar_t__ startDhcpClient(void *);
int /*<<< orphan*/ zteLog(char *);
void *startDhcpClientAdapter(void *ptr) {
  zteLog("DHCP Client thread start\n");
  sigset_t sigset;
  sigemptyset(&sigset);
  sigaddset(&sigset, SIGUSR2);
  sigaddset(&sigset, SIGCHLD);
  signal(SIGCHLD, SIG_IGN);
  int sig;
  while (1) {
    sigwait(&sigset, &sig);
    while (startDhcpClient(ptr))
      ;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<startDhcpClientAdapter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe8d(%rip),%rdi
call   1060 <zteLog@plt>
lea    -0xc(%rbp),%rdi
call   1050 <sigemptyset@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1080 <sigaddset@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1080 <sigaddset@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
mov    0x2e2b(%rip),%rax
mov    (%rax),%esi
call   1040 <signal@plt>
lea    -0xc(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <sigwait@plt>
mov    -0x8(%rbp),%rdi
call   1030 <startDhcpClient@plt>
cmp    $0x0,%rax
je     11e1 <startDhcpClientAdapter+0x81>
jmp    11c9 <startDhcpClientAdapter+0x69>
jmp    11bc <startDhcpClientAdapter+0x5c>

x86 assembly (clang, -O2):
<startDhcpClientAdapter>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xe8d(%rip),%rdi
call   1060 <zteLog@plt>
lea    0xc(%rsp),%r14
mov    %r14,%rdi
call   1050 <sigemptyset@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1080 <sigaddset@plt>
mov    0x2e4b(%rip),%r15
mov    (%r15),%esi
mov    %r14,%rdi
call   1080 <sigaddset@plt>
mov    (%r15),%edi
mov    0x2e2e(%rip),%rax
mov    (%rax),%esi
call   1040 <signal@plt>
lea    0x8(%rsp),%r15
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <sigwait@plt>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <startDhcpClient@plt>
test   %rax,%rax
jne    11d0 <startDhcpClientAdapter+0x70>
jmp    11c0 <startDhcpClientAdapter+0x60>

LLVM IR (-O0):
@.str = [26 x i8] c"DHCP Client thread start\0A\00"
@SIGUSR2 = global i32 0
@SIGCHLD = global i32 0
@SIG_IGN = global i32 0
define i8* @startDhcpClientAdapter(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i32 @zteLog(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @sigemptyset(i32* %3)
%7 = load i32, i32* @SIGUSR2
%8 = call i32 @sigaddset(i32* %3, i32 %7)
%9 = load i32, i32* @SIGCHLD
%10 = call i32 @sigaddset(i32* %3, i32 %9)
%11 = load i32, i32* @SIGCHLD
%12 = load i32, i32* @SIG_IGN
%13 = call i32 @signal(i32 %11, i32 %12)
br label %14
14: ; preds = %1, %21
%15 = call i32 @sigwait(i32* %3, i32* %4)
br label %16
16: ; preds = %20, %14
%17 = load i8*, i8** %2
%18 = call i64 @startDhcpClient(i8* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
br label %16
21: ; preds = %16
br label %14
}

LLVM IR (-O2):
@.str = [26 x i8] c"DHCP Client thread start\0A\00"
@SIGUSR2 = global i32 0
@SIGCHLD = global i32 0
@SIG_IGN = global i32 0
define noalias i8* @startDhcpClientAdapter(i8* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = tail call i32 @zteLog(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%5 = bitcast i32* %2 to i8*
%6 = call i32 @sigemptyset(i32* %2)
%7 = load i32, i32* @SIGUSR2
%8 = call i32 @sigaddset(i32* %2, i32 %7)
%9 = load i32, i32* @SIGCHLD
%10 = call i32 @sigaddset(i32* %2, i32 %9)
%11 = load i32, i32* @SIGCHLD
%12 = load i32, i32* @SIG_IGN
%13 = call i32 @signal(i32 %11, i32 %12)
%14 = bitcast i32* %3 to i8*
br label %15
15: ; preds = %17, %1
%16 = call i32 @sigwait(i32* %2, i32* %3)
br label %17
17: ; preds = %17, %15
%18 = call i64 @startDhcpClient(i8* %0)
%19 = icmp eq i64 %18, 0
br i1 %19, label %15, label %17
}