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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
void write_string_array_to_file(char *initial, char **strings,
                                char *betweenArray, char *end,
                                FILE *toWriteTo) {
  if (initial != NULL) {
    fprintf(toWriteTo, "%s", initial);
  }
  size_t count = 0;
  char *toCheck = strings[count];
  while (toCheck != NULL) {
    fprintf(toWriteTo, "%s", toCheck);
    toCheck = strings[++count];
    if (toCheck != NULL && betweenArray != NULL) {
      fprintf(toWriteTo, "%s", betweenArray);
    }
  }
  if (end != NULL) {
    fprintf(toWriteTo, "%s", end);
  }
}


x86 assembly (clang, -O0):
<write_string_array_to_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     114b <write_string_array_to_file+0x3b>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xeba(%rip),%rsi
call   1030 <fprintf@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     11cd <write_string_array_to_file+0xbd>
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xe83(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    0x8(%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     11c8 <write_string_array_to_file+0xb8>
cmpq   $0x0,-0x18(%rbp)
je     11c8 <write_string_array_to_file+0xb8>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe3d(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1163 <write_string_array_to_file+0x53>
cmpq   $0x0,-0x20(%rbp)
je     11ec <write_string_array_to_file+0xdc>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe19(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_string_array_to_file>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r8,%r15
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%rbx
test   %rdi,%rdi
je     1132 <write_string_array_to_file+0x22>
mov    %r15,%rsi
call   1030 <fputs@plt>
mov    (%rbx),%r13
test   %r13,%r13
je     116e <write_string_array_to_file+0x5e>
add    $0x8,%rbx
jmp    1149 <write_string_array_to_file+0x39>
add    $0x8,%rbx
test   %r13,%r13
je     116e <write_string_array_to_file+0x5e>
mov    %r13,%rdi
mov    %r15,%rsi
call   1030 <fputs@plt>
mov    (%rbx),%r13
test   %r12,%r12
je     1140 <write_string_array_to_file+0x30>
test   %r13,%r13
je     1140 <write_string_array_to_file+0x30>
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <fputs@plt>
jmp    1140 <write_string_array_to_file+0x30>
test   %r14,%r14
je     1187 <write_string_array_to_file+0x77>
mov    %r14,%rdi
mov    %r15,%rsi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <fputs@plt>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @write_string_array_to_file(i8* %0, i8** nocapture %1, i8* %2, i8* %3, i32* nocapture %4) {
%6 = icmp eq i8* %0, null
br i1 %6, label %9, label %7
7: ; preds = %5
%8 = tail call i32 @fputs(i8* %0, i32* %4)
br label %9
9: ; preds = %7, %5
%10 = load i8*, i8** %1
%11 = icmp eq i8* %10, null
br i1 %11, label %27, label %12
12: ; preds = %9
%13 = icmp ne i8* %2, null
br label %14
14: ; preds = %12, %25
%15 = phi i8* [ %10, %12 ], [ %20, %25 ]
%16 = phi i64 [ 0, %12 ], [ %18, %25 ]
%17 = tail call i32 @fputs(i8* %15, i32* %4)
%18 = add i64 %16, 1
%19 = getelementptr inbounds i8*, i8** %1, i64 %18
%20 = load i8*, i8** %19
%21 = icmp ne i8* %20, null
%22 = and i1 %13, %21
br i1 %22, label %23, label %25
23: ; preds = %14
%24 = tail call i32 @fputs(i8* %2, i32* %4)
br label %25
25: ; preds = %23, %14
%26 = icmp eq i8* %20, null
br i1 %26, label %27, label %14
27: ; preds = %25, %9
%28 = icmp eq i8* %3, null
br i1 %28, label %31, label %29
29: ; preds = %27
%30 = tail call i32 @fputs(i8* %3, i32* %4)
br label %31
31: ; preds = %29, %27
ret void
}