#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *openFileForWriting(char const *);
void writeStringArrayToFileWithSuffix(const char *file, char **strings,
                                      const unsigned numStrings,
                                      const char *suffix) {
  FILE *targetFile = openFileForWriting(file);
  for (unsigned i = 0; i < numStrings; i++) {
    fputs(strings[i], targetFile);
    fputs(suffix, targetFile);
  }
  fclose(targetFile);
}


x86 assembly (clang, -O0):
<writeStringArrayToFileWithSuffix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <openFileForWriting@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1196 <writeStringArrayToFileWithSuffix+0x66>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <fputs@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <fputs@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115b <writeStringArrayToFileWithSuffix+0x2b>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeStringArrayToFileWithSuffix>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %edx,%ebp
mov    %rsi,%r15
call   1050 <openFileForWriting@plt>
mov    %rax,%rbx
test   %ebp,%ebp
je     1180 <writeStringArrayToFileWithSuffix+0x50>
mov    %ebp,%r12d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbp,8),%rdi
mov    %rbx,%rsi
call   1040 <fputs@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <fputs@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1160 <writeStringArrayToFileWithSuffix+0x30>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
define void @writeStringArrayToFileWithSuffix(i8* %0, i8** %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%11 = load i8*, i8** %5
%12 = call i32* @openFileForWriting(i8* %11)
store i32* %12, i32** %9
store i32 0, i32* %10
br label %13
13: ; preds = %28, %4
%14 = load i32, i32* %10
%15 = load i32, i32* %7
%16 = icmp ult i32 %14, %15
br i1 %16, label %17, label %31
17: ; preds = %13
%18 = load i8**, i8*** %6
%19 = load i32, i32* %10
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = load i32*, i32** %9
%24 = call i32 @fputs(i8* %22, i32* %23)
%25 = load i8*, i8** %8
%26 = load i32*, i32** %9
%27 = call i32 @fputs(i8* %25, i32* %26)
br label %28
28: ; preds = %17
%29 = load i32, i32* %10
%30 = add i32 %29, 1
store i32 %30, i32* %10
br label %13
31: ; preds = %13
%32 = load i32*, i32** %9
%33 = call i32 @fclose(i32* %32)
ret void
}

LLVM IR (-O2):
define void @writeStringArrayToFileWithSuffix(i8* %0, i8** nocapture %1, i32 %2, i8* nocapture %3) {
%5 = tail call i32* @openFileForWriting(i8* %0)
%6 = icmp eq i32 %2, 0
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = zext i32 %2 to i64
br label %11
9: ; preds = %11, %4
%10 = tail call i32 @fclose(i32* %5)
ret void
11: ; preds = %7, %11
%12 = phi i64 [ 0, %7 ], [ %17, %11 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i32 @fputs(i8* %14, i32* %5)
%16 = tail call i32 @fputs(i8* %3, i32* %5)
%17 = add nuw nsw i64 %12, 1
%18 = icmp eq i64 %17, %8
br i1 %18, label %9, label %11
}