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

/* Variables and functions */
int /*<<< orphan*/ bzero(char *, int);
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int, char *, int);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ write(int, char *, int);
void func(int sockfd) {
  char buff[80];
  int n;
  for (;;) {
    bzero(buff, sizeof(buff));
    printf("Enter the string : ");
    n = 0;
    while ((buff[n++] = getchar()) != '\n')
      ;
    write(sockfd, buff, sizeof(buff));
    bzero(buff, sizeof(buff));
    read(sockfd, buff, sizeof(buff));
    printf("From Server : %s", buff);
    if ((strncmp(buff, "exit", 4)) == 0) {
      printf("Client Exit...\n");
      break;
    }
  }
}


x86 assembly (clang, -O0):
<func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
mov    $0x50,%esi
call   1080 <bzero@plt>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x64(%rbp)
mov    $0x0,%al
call   1070 <getchar@plt>
mov    -0x64(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x64(%rbp)
movslq %ecx,%rcx
mov    %al,-0x60(%rbp,%rcx,1)
movsbl %al,%eax
cmp    $0xa,%eax
je     11b8 <func+0x58>
jmp    118e <func+0x2e>
mov    -0x4(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x50,%edx
call   1040 <write@plt>
lea    -0x60(%rbp),%rdi
mov    $0x50,%esi
call   1080 <bzero@plt>
mov    -0x4(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x50,%edx
call   1060 <read@plt>
lea    -0x60(%rbp),%rsi
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x60(%rbp),%rdi
lea    0xe20(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    122c <func+0xcc>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1231 <func+0xd1>
jmp    116b <func+0xb>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<func>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %edi,%r13d
mov    %rsp,%rbp
lea    0xe75(%rip),%r14
lea    0xe82(%rip),%r15
lea    0xe8c(%rip),%r12
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    $0x50,%esi
call   1090 <bzero@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rbx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <getchar@plt>
mov    %al,(%rbx)
add    $0x1,%rbx
cmp    $0xa,%al
jne    11c0 <func+0x50>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0x50,%edx
call   1050 <write@plt>
mov    %rbp,%rdi
mov    $0x50,%esi
call   1090 <bzero@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0x50,%edx
call   1070 <read@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11a0 <func+0x30>
lea    0xe03(%rip),%rdi
call   1040 <puts@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter the string : \00"
@.str.1 = [17 x i8] c"From Server : %s\00"
@.str.2 = [5 x i8] c"exit\00"
@.str.3 = [16 x i8] c"Client Exit...\0A\00"
define void @func(i32 %0) {
%2 = alloca i32
%3 = alloca [80 x i8]
%4 = alloca i32
store i32 %0, i32* %2
br label %5
5: ; preds = %34, %1
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%7 = call i32 @bzero(i8* %6, i32 80)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %9
9: ; preds = %17, %5
%10 = call signext i8 (...) @getchar()
%11 = load i32, i32* %4
%12 = add nsw i32 %11, 1
store i32 %12, i32* %4
%13 = sext i32 %11 to i64
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %13
store i8 %10, i8* %14
%15 = sext i8 %10 to i32
%16 = icmp ne i32 %15, 10
br i1 %16, label %17, label %18
17: ; preds = %9
br label %9
18: ; preds = %9
%19 = load i32, i32* %2
%20 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%21 = call i32 @write(i32 %19, i8* %20, i32 80)
%22 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%23 = call i32 @bzero(i8* %22, i32 80)
%24 = load i32, i32* %2
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%26 = call i32 @read(i32 %24, i8* %25, i32 80)
%27 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%30 = call i64 @strncmp(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %18
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %35
34: ; preds = %18
br label %5
35: ; preds = %32
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter the string : \00"
@.str.1 = [17 x i8] c"From Server : %s\00"
@.str.2 = [5 x i8] c"exit\00"
@str = [15 x i8] c"Client Exit...\00"
define void @func(i32 %0) {
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %13, %1
%5 = call i32 @bzero(i8* %3, i32 80)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %7, %4
%8 = phi i64 [ %10, %7 ], [ 0, %4 ]
%9 = call signext i8 (...) @getchar()
%10 = add nuw i64 %8, 1
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %8
store i8 %9, i8* %11
%12 = icmp eq i8 %9, 10
br i1 %12, label %13, label %7
13: ; preds = %7
%14 = call i32 @write(i32 %0, i8* %3, i32 80)
%15 = call i32 @bzero(i8* %3, i32 80)
%16 = call i32 @read(i32 %0, i8* %3, i32 80)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%18 = call i64 @strncmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %4
20: ; preds = %13
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
ret void
}