#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*/ addStrings(char **, char *, char);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
char *readFromFile(int /*<<< orphan*/ *);
int /*<<< orphan*/ sendMsgToClient(int, char *);
int /*<<< orphan*/ strcpy(char *, char *);
size_t strlen(char *);
char *strtok(char *, char *);
void printMiniStatement(int clientFD, char *fileName) {
  FILE *fp = fopen(fileName, "r");
  char delim[] = "\n";
  char *str = readFromFile(fp);
  fclose(fp);
  char *miniSt = NULL;
  char *tok = strtok(str, delim);
  int cnt = 0;
  do {
    if (cnt == 0 && tok != NULL) {
      miniSt = (char *)malloc(((strlen(tok) + 1)) * sizeof(char));
      strcpy(miniSt, tok);
      miniSt[strlen(tok)] = 0;
    } else
      addStrings(&miniSt, tok, '\n');
    tok = NULL;
    cnt++;
  } while ((tok = strtok(NULL, delim)) != NULL && cnt < 5);
  if (str != NULL)
    free(str);
  if (miniSt == NULL)
    sendMsgToClient(clientFD, "None");
  else
    sendMsgToClient(clientFD, miniSt);
  if (miniSt != NULL)
    free(miniSt);
  miniSt = NULL;
  str = NULL;
}


x86 assembly (clang, -O0):
<printMiniStatement>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe46(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    0xe38(%rip),%ax
mov    %ax,-0x1a(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <readFromFile@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x1a(%rbp),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    1263 <printMiniStatement+0xc3>
cmpq   $0x0,-0x38(%rbp)
je     1263 <printMiniStatement+0xc3>
mov    -0x38(%rbp),%rdi
call   1060 <strlen@plt>
add    $0x1,%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x38(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
jmp    1275 <printMiniStatement+0xd5>
mov    -0x38(%rbp),%rsi
lea    -0x30(%rbp),%rdi
mov    $0xa,%edx
call   10a0 <addStrings@plt>
movq   $0x0,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
lea    -0x1a(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <strtok@plt>
mov    %rax,%rcx
mov    %rcx,-0x38(%rbp)
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x49(%rbp)
je     12b3 <printMiniStatement+0x113>
cmpl   $0x5,-0x3c(%rbp)
setl   %al
mov    %al,-0x49(%rbp)
mov    -0x49(%rbp),%al
test   $0x1,%al
jne    1204 <printMiniStatement+0x64>
cmpq   $0x0,-0x28(%rbp)
je     12d2 <printMiniStatement+0x132>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x30(%rbp)
jne    12f1 <printMiniStatement+0x151>
mov    -0x4(%rbp),%edi
lea    0xd1d(%rip),%rsi
call   1090 <sendMsgToClient@plt>
jmp    12fd <printMiniStatement+0x15d>
mov    -0x4(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1090 <sendMsgToClient@plt>
cmpq   $0x0,-0x30(%rbp)
je     1311 <printMiniStatement+0x171>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x28(%rbp)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printMiniStatement>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rax
mov    %edi,0x14(%rsp)
lea    0xe44(%rip),%rsi
mov    %rax,%rdi
call   10b0 <fopen@plt>
mov    %rax,%rbx
movw   $0xa,0x6(%rsp)
mov    %rax,%rdi
call   1070 <readFromFile@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1050 <fclose@plt>
movq   $0x0,0x8(%rsp)
lea    0x6(%rsp),%r13
mov    %r15,%rdi
mov    %r13,%rsi
call   10c0 <strtok@plt>
mov    %rax,%rbx
xor    %ebp,%ebp
lea    0x8(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %ebp,%ebp
jne    1250 <printMiniStatement+0xb0>
test   %rbx,%rbx
je     1250 <printMiniStatement+0xb0>
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%edi
call   1080 <malloc@plt>
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    0x8(%rsp),%r14
mov    %rbx,%rdi
call   1060 <strlen@plt>
movb   $0x0,(%r14,%rax,1)
jmp    1260 <printMiniStatement+0xc0>
nopl   (%rax)
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
call   10a0 <addStrings@plt>
xor    %edi,%edi
mov    %r13,%rsi
call   10c0 <strtok@plt>
test   %rax,%rax
je     127c <printMiniStatement+0xdc>
mov    %rax,%rbx
lea    0x1(%rbp),%eax
cmp    $0x4,%ebp
mov    %eax,%ebp
jb     1210 <printMiniStatement+0x70>
test   %r15,%r15
je     1289 <printMiniStatement+0xe9>
mov    %r15,%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
jne    129a <printMiniStatement+0xfa>
lea    0xd68(%rip),%rsi
mov    0x14(%rsp),%edi
call   1090 <sendMsgToClient@plt>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     12b2 <printMiniStatement+0x112>
call   1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@__const.printMiniStatement.delim = [2 x i8] c"\0A\00"
@.str.1 = [5 x i8] c"None\00"
define void @printMiniStatement(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca [2 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%11 = load i8*, i8** %4
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %5
%13 = bitcast [2 x i8]* %6 to i8*
%14 = load i32*, i32** %5
%15 = call i8* @readFromFile(i32* %14)
store i8* %15, i8** %7
%16 = load i32*, i32** %5
%17 = call i32 @fclose(i32* %16)
store i8* null, i8** %8
%18 = load i8*, i8** %7
%19 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%20 = call i8* @strtok(i8* %18, i8* %19)
store i8* %20, i8** %9
store i32 0, i32* %10
br label %21
21: ; preds = %55, %2
%22 = load i32, i32* %10
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %42
24: ; preds = %21
%25 = load i8*, i8** %9
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %42
27: ; preds = %24
%28 = load i8*, i8** %9
%29 = call i64 @strlen(i8* %28)
%30 = add i64 %29, 1
%31 = mul i64 %30, 1
%32 = trunc i64 %31 to i32
%33 = call i64 @malloc(i32 %32)
%34 = inttoptr i64 %33 to i8*
store i8* %34, i8** %8
%35 = load i8*, i8** %8
%36 = load i8*, i8** %9
%37 = call i32 @strcpy(i8* %35, i8* %36)
%38 = load i8*, i8** %8
%39 = load i8*, i8** %9
%40 = call i64 @strlen(i8* %39)
%41 = getelementptr inbounds i8, i8* %38, i64 %40
store i8 0, i8* %41
br label %45
42: ; preds = %24, %21
%43 = load i8*, i8** %9
%44 = call i32 @addStrings(i8** %8, i8* %43, i8 signext 10)
br label %45
45: ; preds = %42, %27
store i8* null, i8** %9
%46 = load i32, i32* %10
%47 = add nsw i32 %46, 1
store i32 %47, i32* %10
br label %48
48: ; preds = %45
%49 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%50 = call i8* @strtok(i8* null, i8* %49)
store i8* %50, i8** %9
%51 = icmp ne i8* %50, null
br i1 %51, label %52, label %55
52: ; preds = %48
%53 = load i32, i32* %10
%54 = icmp slt i32 %53, 5
br label %55
55: ; preds = %52, %48
%56 = phi i1 [ false, %48 ], [ %54, %52 ]
br i1 %56, label %21, label %57
57: ; preds = %55
%58 = load i8*, i8** %7
%59 = icmp ne i8* %58, null
br i1 %59, label %60, label %63
60: ; preds = %57
%61 = load i8*, i8** %7
%62 = call i32 @free(i8* %61)
br label %63
63: ; preds = %60, %57
%64 = load i8*, i8** %8
%65 = icmp eq i8* %64, null
br i1 %65, label %66, label %69
66: ; preds = %63
%67 = load i32, i32* %3
%68 = call i32 @sendMsgToClient(i32 %67, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %73
69: ; preds = %63
%70 = load i32, i32* %3
%71 = load i8*, i8** %8
%72 = call i32 @sendMsgToClient(i32 %70, i8* %71)
br label %73
73: ; preds = %69, %66
%74 = load i8*, i8** %8
%75 = icmp ne i8* %74, null
br i1 %75, label %76, label %79
76: ; preds = %73
%77 = load i8*, i8** %8
%78 = call i32 @free(i8* %77)
br label %79
79: ; preds = %76, %73
store i8* null, i8** %8
store i8* null, i8** %7
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [5 x i8] c"None\00"
define void @printMiniStatement(i32 %0, i8* nocapture %1) {
%3 = alloca i16
%4 = alloca i8*
%5 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = bitcast i16* %3 to i8*
store i16 10, i16* %3
%7 = tail call i8* @readFromFile(i32* %5)
%8 = tail call i32 @fclose(i32* %5)
%9 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%10 = call i8* @strtok(i8* %7, i8* %6)
br label %11
11: ; preds = %29, %2
%12 = phi i8* [ %10, %2 ], [ %31, %29 ]
%13 = phi i32 [ 0, %2 ], [ %30, %29 ]
%14 = icmp eq i32 %13, 0
%15 = icmp ne i8* %12, null
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %17, label %27
17: ; preds = %11
%18 = call i64 @strlen(i8* %12)
%19 = trunc i64 %18 to i32
%20 = add i32 %19, 1
%21 = call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to i8*
store i8* %22, i8** %4
%23 = call i32 @strcpy(i8* %22, i8* %12)
%24 = load i8*, i8** %4
%25 = call i64 @strlen(i8* %12)
%26 = getelementptr inbounds i8, i8* %24, i64 %25
store i8 0, i8* %26
br label %29
27: ; preds = %11
%28 = call i32 @addStrings(i8** %4, i8* %12, i8 signext 10)
br label %29
29: ; preds = %27, %17
%30 = add nuw nsw i32 %13, 1
%31 = call i8* @strtok(i8* null, i8* %6)
%32 = icmp ne i8* %31, null
%33 = icmp ult i32 %13, 4
%34 = select i1 %32, i1 %33, i1 false
br i1 %34, label %11, label %35
35: ; preds = %29
%36 = icmp eq i8* %7, null
br i1 %36, label %39, label %37
37: ; preds = %35
%38 = call i32 @free(i8* %7)
br label %39
39: ; preds = %37, %35
%40 = load i8*, i8** %4
%41 = icmp eq i8* %40, null
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = call i32 @sendMsgToClient(i32 %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %46
44: ; preds = %39
%45 = call i32 @sendMsgToClient(i32 %0, i8* %40)
br label %46
46: ; preds = %44, %42
%47 = load i8*, i8** %4
%48 = icmp eq i8* %47, null
br i1 %48, label %51, label %49
49: ; preds = %46
%50 = call i32 @free(i8* %47)
br label %51
51: ; preds = %49, %46
ret void
}