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

/* Variables and functions */
int /*<<< orphan*/ free(char *);
char *receiveMsgFromClient(int);
int /*<<< orphan*/ sendMsgToClient(int, char *);
scalar_t__ strcmp(char *, char *);
int showInSuffBal(int clientFD) {
  int n;
  int toRet = -1;
  char *buff = NULL;
  sendMsgToClient(clientFD,
                  "Insufficient Balance. Do you want to continue?[Y/N]");
  while (1) {
    if (buff != NULL)
      free(buff);
    buff = receiveMsgFromClient(clientFD);
    if (strcmp(buff, "N") == 0) {
      toRet - 1;
      break;
    } else if (strcmp(buff, "Y") == 0) {
      toRet = 1;
      break;
    } else {
      sendMsgToClient(clientFD, "Unknow Query. Enter [Y/N]");
    }
  }
  if (buff != NULL)
    free(buff);
  buff = NULL;
  return toRet;
}


x86 assembly (clang, -O0):
<showInSuffBal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0xffffffff,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x4(%rbp),%edi
lea    0xe9c(%rip),%rsi
call   1050 <sendMsgToClient@plt>
cmpq   $0x0,-0x18(%rbp)
je     117d <showInSuffBal+0x3d>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%edi
call   1060 <receiveMsgFromClient@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11a8 <showInSuffBal+0x68>
jmp    11e7 <showInSuffBal+0xa7>
mov    -0x18(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ce <showInSuffBal+0x8e>
movl   $0x1,-0xc(%rbp)
jmp    11e7 <showInSuffBal+0xa7>
mov    -0x4(%rbp),%edi
lea    0xe60(%rip),%rsi
call   1050 <sendMsgToClient@plt>
jmp    11e2 <showInSuffBal+0xa2>
jmp    1169 <showInSuffBal+0x29>
cmpq   $0x0,-0x18(%rbp)
je     11fb <showInSuffBal+0xbb>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showInSuffBal>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%ebp
lea    0xeaf(%rip),%rsi
xor    %ebx,%ebx
lea    0xeda(%rip),%r14
lea    0xed5(%rip),%r15
lea    0xed0(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1050 <sendMsgToClient@plt>
test   %rbx,%rbx
je     1184 <showInSuffBal+0x44>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%edi
call   1060 <receiveMsgFromClient@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11bd <showInSuffBal+0x7d>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
mov    %r12,%rsi
test   %rax,%rax
jne    1170 <showInSuffBal+0x30>
mov    $0x1,%ebp
test   %rbx,%rbx
jne    11c7 <showInSuffBal+0x87>
jmp    11cf <showInSuffBal+0x8f>
mov    $0xffffffff,%ebp
test   %rbx,%rbx
je     11cf <showInSuffBal+0x8f>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [52 x i8] c"Insufficient Balance. Do you want to continue?[Y/N]\00"
@.str.1 = [2 x i8] c"N\00"
@.str.2 = [2 x i8] c"Y\00"
@.str.3 = [26 x i8] c"Unknow Query. Enter [Y/N]\00"
define i32 @showInSuffBal(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %2
store i32 -1, i32* %4
store i8* null, i8** %5
%6 = load i32, i32* %2
%7 = call i32 @sendMsgToClient(i32 %6, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %1, %32
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i8*, i8** %5
%13 = call i32 @free(i8* %12)
br label %14
14: ; preds = %11, %8
%15 = load i32, i32* %2
%16 = call i8* @receiveMsgFromClient(i32 %15)
store i8* %16, i8** %5
%17 = load i8*, i8** %5
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, 1
br label %33
23: ; preds = %14
%24 = load i8*, i8** %5
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 1, i32* %4
br label %33
28: ; preds = %23
%29 = load i32, i32* %2
%30 = call i32 @sendMsgToClient(i32 %29, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %31
31: ; preds = %28
br label %32
32: ; preds = %31
br label %8
33: ; preds = %27, %20
%34 = load i8*, i8** %5
%35 = icmp ne i8* %34, null
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i8*, i8** %5
%38 = call i32 @free(i8* %37)
br label %39
39: ; preds = %36, %33
store i8* null, i8** %5
%40 = load i32, i32* %4
ret i32 %40
}

LLVM IR (-O2):
@.str = [52 x i8] c"Insufficient Balance. Do you want to continue?[Y/N]\00"
@.str.1 = [2 x i8] c"N\00"
@.str.2 = [2 x i8] c"Y\00"
@.str.3 = [26 x i8] c"Unknow Query. Enter [Y/N]\00"
define i32 @showInSuffBal(i32 %0) {
br label %2
2: ; preds = %13, %1
%3 = phi i8* [ getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), %13 ]
%4 = phi i8* [ null, %1 ], [ %10, %13 ]
%5 = tail call i32 @sendMsgToClient(i32 %0, i8* %3)
%6 = icmp eq i8* %4, null
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @free(i8* %4)
br label %9
9: ; preds = %7, %2
%10 = tail call i8* @receiveMsgFromClient(i32 %0)
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %9
%14 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %2
16: ; preds = %13, %9
%17 = phi i32 [ -1, %9 ], [ 1, %13 ]
%18 = icmp eq i8* %10, null
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = tail call i32 @free(i8* %10)
br label %21
21: ; preds = %19, %16
ret i32 %17
}