#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*/ sprintf(char *, char *, ...);
int GetDhcpString(int dhcpDns_enable, char *dns_a, char *dns_b, char *string) {
  if (dhcpDns_enable != 0 && dhcpDns_enable != 1)
    return -1;
  if (string == NULL)
    return -1;
  if (dhcpDns_enable == 0) {
    sprintf(string, "mode_name=netcore_set&conntype=1&dns_a=&dns_b=&wan_set=1");
  } else {
    if (dns_a == NULL && dns_b == NULL)
      return -1;
    sprintf(string,
            "mode_name=netcore_set&conntype=1&dns_a=%s&dns_b=%s&wan_set=1",
            dns_a, dns_b);
  }
  return 0;
}


x86 assembly (clang, -O0):
<GetDhcpString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1147 <GetDhcpString+0x37>
cmpl   $0x1,-0x8(%rbp)
je     1147 <GetDhcpString+0x37>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c2 <GetDhcpString+0xb2>
cmpq   $0x0,-0x20(%rbp)
jne    115e <GetDhcpString+0x4e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c2 <GetDhcpString+0xb2>
cmpl   $0x0,-0x8(%rbp)
jne    117f <GetDhcpString+0x6f>
mov    -0x20(%rbp),%rdi
lea    0xe8d(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    11bb <GetDhcpString+0xab>
cmpq   $0x0,-0x10(%rbp)
jne    11a1 <GetDhcpString+0x91>
cmpq   $0x0,-0x18(%rbp)
jne    11a1 <GetDhcpString+0x91>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c2 <GetDhcpString+0xb2>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetDhcpString>:
push   %rbx
mov    $0xffffffff,%ebx
cmp    $0x1,%edi
ja     1174 <GetDhcpString+0x64>
test   %rcx,%rcx
je     1174 <GetDhcpString+0x64>
test   %edi,%edi
je     1147 <GetDhcpString+0x37>
mov    %rdx,%rax
mov    %rsi,%rdx
or     %rax,%rsi
je     1174 <GetDhcpString+0x64>
lea    0xf03(%rip),%rsi
xor    %ebx,%ebx
mov    %rcx,%rdi
mov    %rax,%rcx
xor    %eax,%eax
call   1030 <sprintf@plt>
jmp    1174 <GetDhcpString+0x64>
movups 0xedb(%rip),%xmm0
movups %xmm0,0x29(%rcx)
movups 0xec7(%rip),%xmm0
movups %xmm0,0x20(%rcx)
movups 0xeac(%rip),%xmm0
movups %xmm0,0x10(%rcx)
movups 0xe91(%rip),%xmm0
movups %xmm0,(%rcx)
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [57 x i8] c"mode_name=netcore_set&conntype=1&dns_a=&dns_b=&wan_set=1\00"
@.str.1 = [61 x i8] c"mode_name=netcore_set&conntype=1&dns_a=%s&dns_b=%s&wan_set=1\00"
define i32 @GetDhcpString(i32 %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i32 %0, i32* %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
%10 = load i32, i32* %6
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %4
%13 = load i32, i32* %6
%14 = icmp ne i32 %13, 1
br i1 %14, label %15, label %16
15: ; preds = %12
store i32 -1, i32* %5
br label %39
16: ; preds = %12, %4
%17 = load i8*, i8** %9
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %20
19: ; preds = %16
store i32 -1, i32* %5
br label %39
20: ; preds = %16
%21 = load i32, i32* %6
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i8*, i8** %9
%25 = call i32 (i8*, i8*, ...) @sprintf(i8* %24, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
br label %38
26: ; preds = %20
%27 = load i8*, i8** %7
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i8*, i8** %8
%31 = icmp eq i8* %30, null
br i1 %31, label %32, label %33
32: ; preds = %29
store i32 -1, i32* %5
br label %39
33: ; preds = %29, %26
%34 = load i8*, i8** %9
%35 = load i8*, i8** %7
%36 = load i8*, i8** %8
%37 = call i32 (i8*, i8*, ...) @sprintf(i8* %34, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0), i8* %35, i8* %36)
br label %38
38: ; preds = %33, %23
store i32 0, i32* %5
br label %39
39: ; preds = %38, %32, %19, %15
%40 = load i32, i32* %5
ret i32 %40
}

LLVM IR (-O2):
@.str = [57 x i8] c"mode_name=netcore_set&conntype=1&dns_a=&dns_b=&wan_set=1\00"
@.str.1 = [61 x i8] c"mode_name=netcore_set&conntype=1&dns_a=%s&dns_b=%s&wan_set=1\00"
define i32 @GetDhcpString(i32 %0, i8* %1, i8* %2, i8* writeonly %3) {
%5 = icmp ugt i32 %0, 1
%6 = icmp eq i8* %3, null
%7 = or i1 %5, %6
br i1 %7, label %17, label %8
8: ; preds = %4
%9 = icmp eq i32 %0, 0
br i1 %9, label %10, label %11
10: ; preds = %8
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(57) %3, i8* align 1 dereferenceable(57) getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i64 57, i1 false)
br label %17
11: ; preds = %8
%12 = icmp eq i8* %1, null
%13 = icmp eq i8* %2, null
%14 = and i1 %12, %13
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = tail call i32 (i8*, i8*, ...) @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %2)
br label %17
17: ; preds = %10, %15, %11, %4
%18 = phi i32 [ -1, %4 ], [ -1, %11 ], [ 0, %15 ], [ 0, %10 ]
ret i32 %18
}