#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
addaline_persistant_values(char *thefilename, int readback, char *thetext) {
  static int firstrun = 1;
  static FILE *fp[200];
  if (firstrun == 1) {
    int x;
    firstrun = 0;
    for (x = 0; x < 200; x++)
      fp[x] = NULL;
  }
  if (fp[readback] == NULL)
    fp[readback] = fopen(thefilename, "a+");
  fprintf(fp[readback], "%s\n", thetext);
}


x86 assembly (clang, -O0):
<addaline_persistant_values>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpl   $0x1,0x2ef6(%rip)
jne    1184 <addaline_persistant_values+0x64>
movl   $0x0,0x2ee6(%rip)
movl   $0x0,-0x24(%rbp)
cmpl   $0xc8,-0x24(%rbp)
jge    117f <addaline_persistant_values+0x5f>
movslq -0x24(%rbp),%rcx
lea    0x2ee7(%rip),%rax
movq   $0x0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1151 <addaline_persistant_values+0x31>
jmp    1184 <addaline_persistant_values+0x64>
movslq -0x14(%rbp),%rcx
lea    0x2ec1(%rip),%rax
cmpq   $0x0,(%rax,%rcx,8)
jne    11bc <addaline_persistant_values+0x9c>
mov    -0x10(%rbp),%rdi
lea    0xe5b(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%rdx
movslq -0x14(%rbp),%rcx
lea    0x2e98(%rip),%rax
mov    %rdx,(%rax,%rcx,8)
movslq -0x14(%rbp),%rcx
lea    0x2e89(%rip),%rax
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe2d(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addaline_persistant_values>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%r14
cmpb   $0x0,0x2f0a(%rip)
jne    1162 <addaline_persistant_values+0x32>
movb   $0x1,0x2f01(%rip)
lea    0x2f0a(%rip),%rdi
mov    $0x640,%edx
xor    %esi,%esi
call   1030 <memset@plt>
movslq %ebp,%rbp
lea    0x2ef4(%rip),%r15
mov    (%r15,%rbp,8),%rdi
test   %rdi,%rdi
jne    118b <addaline_persistant_values+0x5b>
lea    0xe84(%rip),%rsi
mov    %r14,%rdi
call   1050 <fopen@plt>
mov    %rax,%rdi
mov    %rax,(%r15,%rbp,8)
lea    0xe71(%rip),%rsi
mov    %rbx,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@addaline_persistant_values.firstrun = internal global i32 1
@addaline_persistant_values.fp = internal global [200 x i32*] zeroinitializer
@.str = [3 x i8] c"a+\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @addaline_persistant_values(i8* %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%9 = load i32, i32* @addaline_persistant_values.firstrun
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %23
11: ; preds = %3
store i32 0, i32* @addaline_persistant_values.firstrun
store i32 0, i32* %8
br label %12
12: ; preds = %19, %11
%13 = load i32, i32* %8
%14 = icmp slt i32 %13, 200
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32, i32* %8
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [200 x i32*], [200 x i32*]* @addaline_persistant_values.fp, i64 0, i64 %17
store i32* null, i32** %18
br label %19
19: ; preds = %15
%20 = load i32, i32* %8
%21 = add nsw i32 %20, 1
store i32 %21, i32* %8
br label %12
22: ; preds = %12
br label %23
23: ; preds = %22, %3
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [200 x i32*], [200 x i32*]* @addaline_persistant_values.fp, i64 0, i64 %25
%27 = load i32*, i32** %26
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %35
29: ; preds = %23
%30 = load i8*, i8** %5
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [200 x i32*], [200 x i32*]* @addaline_persistant_values.fp, i64 0, i64 %33
store i32* %31, i32** %34
br label %35
35: ; preds = %29, %23
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [200 x i32*], [200 x i32*]* @addaline_persistant_values.fp, i64 0, i64 %37
%39 = load i32*, i32** %38
%40 = load i8*, i8** %7
%41 = call i32 @fprintf(i32* %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %40)
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
@addaline_persistant_values.firstrun = internal unnamed_addr global i1 false
@addaline_persistant_values.fp = internal unnamed_addr global [200 x i32*] zeroinitializer
@.str = [3 x i8] c"a+\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @addaline_persistant_values(i8* nocapture %0, i32 %1, i8* %2) {
%4 = load i1, i1* @addaline_persistant_values.firstrun
br i1 %4, label %6, label %5
5: ; preds = %3
store i1 true, i1* @addaline_persistant_values.firstrun
br label %6
6: ; preds = %5, %3
%7 = sext i32 %1 to i64
%8 = getelementptr inbounds [200 x i32*], [200 x i32*]* @addaline_persistant_values.fp, i64 0, i64 %7
%9 = load i32*, i32** %8
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %8
br label %13
13: ; preds = %11, %6
%14 = phi i32* [ %12, %11 ], [ %9, %6 ]
%15 = tail call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
ret i32 undef
}