#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*/ printf(char *, char *);
int /*<<< orphan*/ read(int, char *, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ write(int, char *, int);
void serve_client(int cfd) {
  char buffer[256] = {0};
  write(cfd, "You are now connected.\nEnter username:", 38);
  read(cfd, buffer, 256);
  if (strcmp(buffer, "arjun024")) {
    write(cfd, "Authentication failed", 21);
    printf("A user tried to login using: %s\n", buffer);
    return;
  }
  write(cfd, "Authentication success", 22);
  printf("%s has logged in.\n", buffer);
  return;
}


x86 assembly (clang, -O0):
<serve_client>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
mov    -0x4(%rbp),%edi
lea    0xe85(%rip),%rsi
mov    $0x26,%edx
call   1030 <write@plt>
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    $0x100,%edx
call   1060 <read@plt>
lea    -0x110(%rbp),%rdi
lea    0xe80(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     11e2 <serve_client+0x92>
mov    -0x4(%rbp),%edi
lea    0xe70(%rip),%rsi
mov    $0x15,%edx
call   1030 <write@plt>
lea    -0x110(%rbp),%rsi
lea    0xe6e(%rip),%rdi
call   1040 <printf@plt>
jmp    1209 <serve_client+0xb9>
mov    -0x4(%rbp),%edi
lea    0xe7b(%rip),%rsi
mov    $0x16,%edx
call   1030 <write@plt>
lea    -0x110(%rbp),%rsi
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serve_client>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %edi,%ebx
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xe43(%rip),%rsi
mov    $0x26,%edx
call   1030 <write@plt>
mov    %rsp,%r14
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x100,%edx
call   1050 <read@plt>
lea    0xe47(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1209 <serve_client+0xc9>
lea    0xe3c(%rip),%rsi
mov    %ebx,%edi
mov    $0x15,%edx
call   1030 <write@plt>
lea    0xe3f(%rip),%rdi
jmp    1223 <serve_client+0xe3>
lea    0xe57(%rip),%rsi
mov    %ebx,%edi
mov    $0x16,%edx
call   1030 <write@plt>
lea    0xe5b(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [39 x i8] c"You are now connected.\0AEnter username:\00"
@.str.1 = [9 x i8] c"arjun024\00"
@.str.2 = [22 x i8] c"Authentication failed\00"
@.str.3 = [33 x i8] c"A user tried to login using: %s\0A\00"
@.str.4 = [23 x i8] c"Authentication success\00"
@.str.5 = [19 x i8] c"%s has logged in.\0A\00"
define void @serve_client(i32 %0) {
%2 = alloca i32
%3 = alloca [256 x i8]
store i32 %0, i32* %2
%4 = bitcast [256 x i8]* %3 to i8*
%5 = load i32, i32* %2
%6 = call i32 @write(i32 %5, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 38)
%7 = load i32, i32* %2
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%9 = call i32 @read(i32 %7, i8* %8, i32 256)
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %1
%14 = load i32, i32* %2
%15 = call i32 @write(i32 %14, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 21)
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %16)
br label %23
18: ; preds = %1
%19 = load i32, i32* %2
%20 = call i32 @write(i32 %19, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 22)
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%22 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %18, %13
ret void
}

LLVM IR (-O2):
@.str = [39 x i8] c"You are now connected.\0AEnter username:\00"
@.str.1 = [9 x i8] c"arjun024\00"
@.str.2 = [22 x i8] c"Authentication failed\00"
@.str.3 = [33 x i8] c"A user tried to login using: %s\0A\00"
@.str.4 = [23 x i8] c"Authentication success\00"
@.str.5 = [19 x i8] c"%s has logged in.\0A\00"
define void @serve_client(i32 %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 38)
%5 = call i32 @read(i32 %0, i8* %3, i32 256)
%6 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = call i32 @write(i32 %0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 21)
br label %12
10: ; preds = %1
%11 = call i32 @write(i32 %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 22)
br label %12
12: ; preds = %10, %8
%13 = phi i8* [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), %10 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), %8 ]
%14 = call i32 @printf(i8* %13, i8* %3)
ret void
}