#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 */
scalar_t__ chaz_CC_is_msvc();
char *chaz_Util_join(char *, char *, char const *, char const *, ...);
int /*<<< orphan*/ free(char *);
char *chaz_CC_format_archiver_command(const char *target, const char *objects) {
  if (chaz_CC_is_msvc()) {
    char *out = chaz_Util_join("", "/OUT:", target, NULL);
    char *command = chaz_Util_join(" ", "lib", "/NOLOGO", objects, out, NULL);
    free(out);
    return command;
  } else {
    return chaz_Util_join(" ", "ar", "rcs", target, objects, NULL);
  }
}


x86 assembly (clang, -O0):
<chaz_CC_format_archiver_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x0,%al
call   1050 <chaz_CC_is_msvc@plt>
cmp    $0x0,%rax
je     11b5 <chaz_CC_format_archiver_command+0x85>
mov    -0x10(%rbp),%rdx
lea    0xeab(%rip),%rdi
lea    0xe9d(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    $0x0,%al
call   1040 <chaz_Util_join@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xe85(%rip),%rdi
lea    0xe80(%rip),%rsi
lea    0xe7d(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r9d
mov    $0x0,%al
call   1040 <chaz_Util_join@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11e2 <chaz_CC_format_archiver_command+0xb2>
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0xe42(%rip),%rdi
lea    0xe49(%rip),%rsi
lea    0xe45(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r9d
mov    $0x0,%al
call   1040 <chaz_Util_join@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chaz_CC_format_archiver_command>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1050 <chaz_CC_is_msvc@plt>
test   %rax,%rax
je     119e <chaz_CC_format_archiver_command+0x6e>
lea    0xeba(%rip),%rdi
lea    0xeac(%rip),%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <chaz_Util_join@plt>
mov    %rax,%rbx
lea    0xe9c(%rip),%rdi
lea    0xe97(%rip),%rsi
lea    0xe94(%rip),%rdx
mov    %r14,%rcx
mov    %rax,%r8
xor    %r9d,%r9d
xor    %eax,%eax
call   1040 <chaz_Util_join@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe61(%rip),%rdi
lea    0xe68(%rip),%rsi
lea    0xe64(%rip),%rdx
mov    %rbx,%rcx
mov    %r14,%r8
xor    %r9d,%r9d
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <chaz_Util_join@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [6 x i8] c"/OUT:\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [4 x i8] c"lib\00"
@.str.4 = [8 x i8] c"/NOLOGO\00"
@.str.5 = [3 x i8] c"ar\00"
@.str.6 = [4 x i8] c"rcs\00"
define i8* @chaz_CC_format_archiver_command(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = call i64 (...) @chaz_CC_is_msvc()
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = call i8* (i8*, i8*, i8*, i8*, ...) @chaz_Util_join(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %11, i8* null)
store i8* %12, i8** %6
%13 = load i8*, i8** %5
%14 = load i8*, i8** %6
%15 = call i8* (i8*, i8*, i8*, i8*, ...) @chaz_Util_join(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %13, i8* %14, i8* null)
store i8* %15, i8** %7
%16 = load i8*, i8** %6
%17 = call i32 @free(i8* %16)
%18 = load i8*, i8** %7
store i8* %18, i8** %3
br label %23
19: ; preds = %2
%20 = load i8*, i8** %4
%21 = load i8*, i8** %5
%22 = call i8* (i8*, i8*, i8*, i8*, ...) @chaz_Util_join(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %20, i8* %21, i8* null)
store i8* %22, i8** %3
br label %23
23: ; preds = %19, %10
%24 = load i8*, i8** %3
ret i8* %24
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [6 x i8] c"/OUT:\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [4 x i8] c"lib\00"
@.str.4 = [8 x i8] c"/NOLOGO\00"
@.str.5 = [3 x i8] c"ar\00"
@.str.6 = [4 x i8] c"rcs\00"
define i8* @chaz_CC_format_archiver_command(i8* %0, i8* %1) {
%3 = tail call i64 (...) @chaz_CC_is_msvc()
%4 = icmp eq i64 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = tail call i8* (i8*, i8*, i8*, i8*, ...) @chaz_Util_join(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* null)
%7 = tail call i8* (i8*, i8*, i8*, i8*, ...) @chaz_Util_join(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %1, i8* %6, i8* null)
%8 = tail call i32 @free(i8* %6)
br label %11
9: ; preds = %2
%10 = tail call i8* (i8*, i8*, i8*, i8*, ...) @chaz_Util_join(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %0, i8* %1, i8* null)
br label %11
11: ; preds = %9, %5
%12 = phi i8* [ %7, %5 ], [ %10, %9 ]
ret i8* %12
}