#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*/ *fopen(char const *, char *);
int /*<<< orphan*/ format_sql_values_str(char **, int, char *);
int /*<<< orphan*/ freeMem(char *, int);
int get_file_content(int /*<<< orphan*/ *, char **, int *);
char *mallocMem(int);
int /*<<< orphan*/ printf(char *, char *, int);
int parzeFileContentToSqlStr(const char *file, char *sqlstr) {
  FILE *fp = NULL;
  int i = 0;
  char *content[(4096)];
  int total_line = 0;
  if ((fp = fopen(file, "r")) == NULL) {
    printf("\n%s,%d:failed to open file!",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/Sunfe/sas/refs/heads/master/source/"
           "sas_parze_file.c",
           72);
    return (0x1 << 1);
  }
  for (i = 0; i < (4096); i++)
    content[i] = mallocMem((1024));
  if ((0x0) != get_file_content(fp, content, &total_line))
    return (0x1 << 0);
  format_sql_values_str(content, total_line, sqlstr);
  for (i = 0; i < (4096); i++)
    freeMem(content[i], (1024));
  fclose(fp);
  return (0x0);
}


x86 assembly (clang, -O0):
<parzeFileContentToSqlStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8040,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x8034(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11de <parzeFileContentToSqlStr+0x6e>
lea    0xe41(%rip),%rdi
lea    0xe56(%rip),%rsi
mov    $0x48,%edx
call   1050 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    12a6 <parzeFileContentToSqlStr+0x136>
movl   $0x0,-0x24(%rbp)
cmpl   $0x1000,-0x24(%rbp)
jge    1219 <parzeFileContentToSqlStr+0xa9>
mov    $0x400,%edi
call   1070 <mallocMem@plt>
mov    %rax,%rcx
movslq -0x24(%rbp),%rax
mov    %rcx,-0x8030(%rbp,%rax,8)
ff
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11e5 <parzeFileContentToSqlStr+0x75>
mov    -0x20(%rbp),%rdi
lea    -0x8030(%rbp),%rsi
lea    -0x8034(%rbp),%rdx
call   1030 <get_file_content@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     1248 <parzeFileContentToSqlStr+0xd8>
movl   $0x1,-0x4(%rbp)
jmp    12a6 <parzeFileContentToSqlStr+0x136>
lea    -0x8030(%rbp),%rdi
mov    -0x8034(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1090 <format_sql_values_str@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x1000,-0x24(%rbp)
jge    1296 <parzeFileContentToSqlStr+0x126>
movslq -0x24(%rbp),%rax
mov    -0x8030(%rbp,%rax,8),%rdi
ff
mov    $0x400,%esi
call   1060 <freeMem@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1265 <parzeFileContentToSqlStr+0xf5>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x8040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parzeFileContentToSqlStr>:
push   %r15
push   %r14
push   %rbx
sub    $0x8010,%rsp
mov    %rsi,%r14
movl   $0x0,0xc(%rsp)
lea    0xe72(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1228 <parzeFileContentToSqlStr+0xb8>
mov    %rax,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x400,%edi
call   1070 <mallocMem@plt>
mov    %rax,0x10(%rsp,%rbx,8)
add    $0x1,%rbx
cmp    $0x1000,%rbx
jne    11b0 <parzeFileContentToSqlStr+0x40>
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %r15,%rdi
call   1030 <get_file_content@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
jne    1245 <parzeFileContentToSqlStr+0xd5>
mov    0xc(%rsp),%esi
lea    0x10(%rsp),%rdi
mov    %r14,%rdx
call   1090 <format_sql_values_str@plt>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    0x10(%rsp,%rbx,8),%rdi
mov    $0x400,%esi
call   1060 <freeMem@plt>
add    $0x1,%rbx
cmp    $0x1000,%rbx
jne    1200 <parzeFileContentToSqlStr+0x90>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    1245 <parzeFileContentToSqlStr+0xd5>
lea    0xdd3(%rip),%rdi
lea    0xde8(%rip),%rsi
mov    $0x48,%edx
call   1050 <printf@plt>
mov    $0x2,%eax
add    $0x8010,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [28 x i8] c"\0A%s,%d:failed to open file!\00"
@.str.2 = [142 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Sunfe/sas/refs/heads/master/source/sas_parze_file.c\00"
define i32 @parzeFileContentToSqlStr(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca [4096 x i8*]
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* null, i32** %6
store i32 0, i32* %7
store i32 0, i32* %9
%10 = load i8*, i8** %4
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %6
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.2, i64 0, i64 0), i32 72)
store i32 2, i32* %3
br label %53
15: ; preds = %2
store i32 0, i32* %7
br label %16
16: ; preds = %24, %15
%17 = load i32, i32* %7
%18 = icmp slt i32 %17, 4096
br i1 %18, label %19, label %27
19: ; preds = %16
%20 = call i8* @mallocMem(i32 1024)
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [4096 x i8*], [4096 x i8*]* %8, i64 0, i64 %22
store i8* %20, i8** %23
br label %24
24: ; preds = %19
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %16
27: ; preds = %16
%28 = load i32*, i32** %6
%29 = getelementptr inbounds [4096 x i8*], [4096 x i8*]* %8, i64 0, i64 0
%30 = call i32 @get_file_content(i32* %28, i8** %29, i32* %9)
%31 = icmp ne i32 0, %30
br i1 %31, label %32, label %33
32: ; preds = %27
store i32 1, i32* %3
br label %53
33: ; preds = %27
%34 = getelementptr inbounds [4096 x i8*], [4096 x i8*]* %8, i64 0, i64 0
%35 = load i32, i32* %9
%36 = load i8*, i8** %5
%37 = call i32 @format_sql_values_str(i8** %34, i32 %35, i8* %36)
store i32 0, i32* %7
br label %38
38: ; preds = %47, %33
%39 = load i32, i32* %7
%40 = icmp slt i32 %39, 4096
br i1 %40, label %41, label %50
41: ; preds = %38
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [4096 x i8*], [4096 x i8*]* %8, i64 0, i64 %43
%45 = load i8*, i8** %44
%46 = call i32 @freeMem(i8* %45, i32 1024)
br label %47
47: ; preds = %41
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
store i32 %49, i32* %7
br label %38
50: ; preds = %38
%51 = load i32*, i32** %6
%52 = call i32 @fclose(i32* %51)
store i32 0, i32* %3
br label %53
53: ; preds = %50, %32, %13
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [28 x i8] c"\0A%s,%d:failed to open file!\00"
@.str.2 = [142 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Sunfe/sas/refs/heads/master/source/sas_parze_file.c\00"
define i32 @parzeFileContentToSqlStr(i8* nocapture %0, i8* %1) {
%3 = alloca [4096 x i8*]
%4 = alloca i32
%5 = bitcast [4096 x i8*]* %3 to i8*
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.2, i64 0, i64 0), i32 72)
br label %33
11: ; preds = %2, %11
%12 = phi i64 [ %15, %11 ], [ 0, %2 ]
%13 = tail call i8* @mallocMem(i32 1024)
%14 = getelementptr inbounds [4096 x i8*], [4096 x i8*]* %3, i64 0, i64 %12
store i8* %13, i8** %14
%15 = add nuw nsw i64 %12, 1
%16 = icmp eq i64 %15, 4096
br i1 %16, label %17, label %11
17: ; preds = %11
%18 = getelementptr inbounds [4096 x i8*], [4096 x i8*]* %3, i64 0, i64 0
%19 = call i32 @get_file_content(i32* %7, i8** %18, i32* %4)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %33
21: ; preds = %17
%22 = load i32, i32* %4
%23 = call i32 @format_sql_values_str(i8** %18, i32 %22, i8* %1)
br label %24
24: ; preds = %21, %24
%25 = phi i64 [ 0, %21 ], [ %29, %24 ]
%26 = getelementptr inbounds [4096 x i8*], [4096 x i8*]* %3, i64 0, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 @freeMem(i8* %27, i32 1024)
%29 = add nuw nsw i64 %25, 1
%30 = icmp eq i64 %29, 4096
br i1 %30, label %31, label %24
31: ; preds = %24
%32 = call i32 @fclose(i32* %7)
br label %33
33: ; preds = %17, %31, %9
%34 = phi i32 [ 2, %9 ], [ 0, %31 ], [ 1, %17 ]
ret i32 %34
}