#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*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int buildDigCmd(char *server, char *hostName, char *port, char *serviceType,
                char *domain, char *query, char *cmd) {
  strcpy(cmd, "dig @");
  if (server == NULL || strcmp(server, "") == 0) {
    strcat(cmd, "224.0.0.251");
  } else {
    strcat(cmd, server);
  }
  strcat(cmd, " ");
  strcat(cmd, "-p");
  strcat(cmd, port);
  strcat(cmd, " ");
  strcat(cmd, hostName);
  strcat(cmd, ".");
  strcat(cmd, serviceType);
  strcat(cmd, ".");
  strcat(cmd, domain);
  strcat(cmd, " ");
  strcat(cmd, query);
  return 0;
}


x86 assembly (clang, -O0):
<buildDigCmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    0x10(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1030 <strcpy@plt>
cmpq   $0x0,-0x8(%rbp)
je     1189 <buildDigCmd+0x59>
mov    -0x8(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    119e <buildDigCmd+0x6e>
mov    0x10(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1050 <strcat@plt>
jmp    11ab <buildDigCmd+0x7b>
mov    0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <strcat@plt>
mov    0x10(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1050 <strcat@plt>
mov    0x10(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1050 <strcat@plt>
mov    0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcat@plt>
mov    0x10(%rbp),%rdi
lea    0xe2f(%rip),%rsi
call   1050 <strcat@plt>
mov    0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcat@plt>
mov    0x10(%rbp),%rdi
lea    0xe17(%rip),%rsi
call   1050 <strcat@plt>
mov    0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strcat@plt>
mov    0x10(%rbp),%rdi
lea    0xdfa(%rip),%rsi
call   1050 <strcat@plt>
mov    0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <strcat@plt>
mov    0x10(%rbp),%rdi
lea    0xdd8(%rip),%rsi
call   1050 <strcat@plt>
mov    0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1050 <strcat@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buildDigCmd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,0x8(%rsp)
mov    %rcx,%r12
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%rbp
mov    0x50(%rsp),%rbx
lea    0xea0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
test   %rbp,%rbp
je     1189 <buildDigCmd+0x59>
lea    0xe9f(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1189 <buildDigCmd+0x59>
mov    %rbx,%rdi
mov    %rbp,%rsi
jmp    1193 <buildDigCmd+0x63>
lea    0xe76(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
lea    0xe73(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcat@plt>
lea    0xe63(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <strcat@plt>
lea    0xe36(%rip),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    0x8(%rsp),%rsi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    0x10(%rsp),%rsi
call   1050 <strcat@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"dig @\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [12 x i8] c"224.0.0.251\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [3 x i8] c"-p\00"
@.str.5 = [2 x i8] c".\00"
define i32 @buildDigCmd(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5, i8* %6) {
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
store i8* %0, i8** %8
store i8* %1, i8** %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i8* %4, i8** %12
store i8* %5, i8** %13
store i8* %6, i8** %14
%15 = load i8*, i8** %14
%16 = call i32 @strcpy(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%17 = load i8*, i8** %8
%18 = icmp eq i8* %17, null
br i1 %18, label %23, label %19
19: ; preds = %7
%20 = load i8*, i8** %8
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19, %7
%24 = load i8*, i8** %14
%25 = call i32 @strcat(i8* %24, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %30
26: ; preds = %19
%27 = load i8*, i8** %14
%28 = load i8*, i8** %8
%29 = call i32 @strcat(i8* %27, i8* %28)
br label %30
30: ; preds = %26, %23
%31 = load i8*, i8** %14
%32 = call i32 @strcat(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%33 = load i8*, i8** %14
%34 = call i32 @strcat(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%35 = load i8*, i8** %14
%36 = load i8*, i8** %10
%37 = call i32 @strcat(i8* %35, i8* %36)
%38 = load i8*, i8** %14
%39 = call i32 @strcat(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%40 = load i8*, i8** %14
%41 = load i8*, i8** %9
%42 = call i32 @strcat(i8* %40, i8* %41)
%43 = load i8*, i8** %14
%44 = call i32 @strcat(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%45 = load i8*, i8** %14
%46 = load i8*, i8** %11
%47 = call i32 @strcat(i8* %45, i8* %46)
%48 = load i8*, i8** %14
%49 = call i32 @strcat(i8* %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%50 = load i8*, i8** %14
%51 = load i8*, i8** %12
%52 = call i32 @strcat(i8* %50, i8* %51)
%53 = load i8*, i8** %14
%54 = call i32 @strcat(i8* %53, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%55 = load i8*, i8** %14
%56 = load i8*, i8** %13
%57 = call i32 @strcat(i8* %55, i8* %56)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"dig @\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [12 x i8] c"224.0.0.251\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [3 x i8] c"-p\00"
@.str.5 = [2 x i8] c".\00"
define i32 @buildDigCmd(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5, i8* %6) {
%8 = tail call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i8* %0, null
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10, %7
%14 = tail call i32 @strcat(i8* %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %17
15: ; preds = %10
%16 = tail call i32 @strcat(i8* %6, i8* %0)
br label %17
17: ; preds = %15, %13
%18 = tail call i32 @strcat(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%19 = tail call i32 @strcat(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%20 = tail call i32 @strcat(i8* %6, i8* %2)
%21 = tail call i32 @strcat(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%22 = tail call i32 @strcat(i8* %6, i8* %1)
%23 = tail call i32 @strcat(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%24 = tail call i32 @strcat(i8* %6, i8* %3)
%25 = tail call i32 @strcat(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%26 = tail call i32 @strcat(i8* %6, i8* %4)
%27 = tail call i32 @strcat(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%28 = tail call i32 @strcat(i8* %6, i8* %5)
ret i32 0
}