#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*/ dcc_argv_append(char **, int /*<<< orphan*/);
int dcc_convert_mt_to_dotd_target(char **, char **);
int dcc_copy_argv(char **, char ***, int);
int /*<<< orphan*/ strdup(char const *);
int /*<<< orphan*/ tweak_include_arguments_for_server(char **, char const *);
int /*<<< orphan*/ tweak_input_argument_for_server(char **, char const *);
int tweak_arguments_for_server(char **argv, const char *root_dir,
                               const char *deps_fname, char **dotd_target,
                               char ***tweaked_argv) {
  int ret;
  *dotd_target = 0;
  if ((ret = dcc_copy_argv(argv, tweaked_argv, 3)))
    return 1;
  if ((ret = dcc_convert_mt_to_dotd_target(*tweaked_argv, dotd_target)))
    return 1;
  dcc_argv_append(*tweaked_argv, strdup("-MMD"));
  dcc_argv_append(*tweaked_argv, strdup("-MF"));
  dcc_argv_append(*tweaked_argv, strdup(deps_fname));
  tweak_include_arguments_for_server(*tweaked_argv, root_dir);
  tweak_input_argument_for_server(*tweaked_argv, root_dir);
  return 0;
}


x86 assembly (clang, -O0):
<tweak_arguments_for_server>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    $0x3,%edx
call   1030 <dcc_copy_argv@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
je     11b1 <tweak_arguments_for_server+0x51>
movl   $0x1,-0x4(%rbp)
jmp    1263 <tweak_arguments_for_server+0x103>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <dcc_convert_mt_to_dotd_target@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
je     11d9 <tweak_arguments_for_server+0x79>
movl   $0x1,-0x4(%rbp)
jmp    1263 <tweak_arguments_for_server+0x103>
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
lea    0xe15(%rip),%rdi
call   1080 <strdup@plt>
mov    -0x50(%rbp),%rdi
mov    %eax,%esi
call   1060 <dcc_argv_append@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
lea    0xdf8(%rip),%rdi
call   1080 <strdup@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
call   1060 <dcc_argv_append@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <strdup@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
call   1060 <dcc_argv_append@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <tweak_include_arguments_for_server@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <tweak_input_argument_for_server@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tweak_arguments_for_server>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8,%r12
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%r14
movq   $0x0,(%rcx)
mov    %r8,%rsi
mov    $0x3,%edx
call   1030 <dcc_copy_argv@plt>
mov    $0x1,%ebp
test   %eax,%eax
jne    1205 <tweak_arguments_for_server+0xa5>
mov    (%r12),%rdi
mov    %rbx,%rsi
call   1040 <dcc_convert_mt_to_dotd_target@plt>
test   %eax,%eax
jne    1205 <tweak_arguments_for_server+0xa5>
mov    (%r12),%rbx
lea    0xe54(%rip),%rdi
call   1080 <strdup@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <dcc_argv_append@plt>
mov    (%r12),%rbx
lea    0xe3f(%rip),%rdi
call   1080 <strdup@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <dcc_argv_append@plt>
mov    (%r12),%rbx
mov    %r15,%rdi
call   1080 <strdup@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <dcc_argv_append@plt>
mov    (%r12),%rdi
mov    %r14,%rsi
call   1070 <tweak_include_arguments_for_server@plt>
mov    (%r12),%rdi
mov    %r14,%rsi
call   1050 <tweak_input_argument_for_server@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"-MMD\00"
@.str.1 = [4 x i8] c"-MF\00"
define i32 @tweak_arguments_for_server(i8** %0, i8* %1, i8* %2, i8** %3, i8*** %4) {
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8**
%11 = alloca i8***
%12 = alloca i32
store i8** %0, i8*** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8** %3, i8*** %10
store i8*** %4, i8**** %11
%13 = load i8**, i8*** %10
store i8* null, i8** %13
%14 = load i8**, i8*** %7
%15 = load i8***, i8**** %11
%16 = call i32 @dcc_copy_argv(i8** %14, i8*** %15, i32 3)
store i32 %16, i32* %12
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %5
store i32 1, i32* %6
br label %48
19: ; preds = %5
%20 = load i8***, i8**** %11
%21 = load i8**, i8*** %20
%22 = load i8**, i8*** %10
%23 = call i32 @dcc_convert_mt_to_dotd_target(i8** %21, i8** %22)
store i32 %23, i32* %12
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %19
store i32 1, i32* %6
br label %48
26: ; preds = %19
%27 = load i8***, i8**** %11
%28 = load i8**, i8*** %27
%29 = call i32 @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @dcc_argv_append(i8** %28, i32 %29)
%31 = load i8***, i8**** %11
%32 = load i8**, i8*** %31
%33 = call i32 @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%34 = call i32 @dcc_argv_append(i8** %32, i32 %33)
%35 = load i8***, i8**** %11
%36 = load i8**, i8*** %35
%37 = load i8*, i8** %9
%38 = call i32 @strdup(i8* %37)
%39 = call i32 @dcc_argv_append(i8** %36, i32 %38)
%40 = load i8***, i8**** %11
%41 = load i8**, i8*** %40
%42 = load i8*, i8** %8
%43 = call i32 @tweak_include_arguments_for_server(i8** %41, i8* %42)
%44 = load i8***, i8**** %11
%45 = load i8**, i8*** %44
%46 = load i8*, i8** %8
%47 = call i32 @tweak_input_argument_for_server(i8** %45, i8* %46)
store i32 0, i32* %6
br label %48
48: ; preds = %26, %25, %18
%49 = load i32, i32* %6
ret i32 %49
}

LLVM IR (-O2):
@.str = [5 x i8] c"-MMD\00"
@.str.1 = [4 x i8] c"-MF\00"
define i32 @tweak_arguments_for_server(i8** %0, i8* %1, i8* %2, i8** %3, i8*** %4) {
store i8* null, i8** %3
%6 = tail call i32 @dcc_copy_argv(i8** %0, i8*** %4, i32 3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %26
8: ; preds = %5
%9 = load i8**, i8*** %4
%10 = tail call i32 @dcc_convert_mt_to_dotd_target(i8** %9, i8** %3)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %26
12: ; preds = %8
%13 = load i8**, i8*** %4
%14 = tail call i32 @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 @dcc_argv_append(i8** %13, i32 %14)
%16 = load i8**, i8*** %4
%17 = tail call i32 @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 @dcc_argv_append(i8** %16, i32 %17)
%19 = load i8**, i8*** %4
%20 = tail call i32 @strdup(i8* %2)
%21 = tail call i32 @dcc_argv_append(i8** %19, i32 %20)
%22 = load i8**, i8*** %4
%23 = tail call i32 @tweak_include_arguments_for_server(i8** %22, i8* %1)
%24 = load i8**, i8*** %4
%25 = tail call i32 @tweak_input_argument_for_server(i8** %24, i8* %1)
br label %26
26: ; preds = %8, %5, %12
%27 = phi i32 [ 0, %12 ], [ 1, %5 ], [ 1, %8 ]
ret i32 %27
}