#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*/ error(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ receive_msg(int, char *);
scalar_t__ send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *);
scalar_t__ strcmp(char *, char *);
void authenticate(int fd, char *user, char *psw) {
  char both[256], temp_buf[32768];
  sprintf(both, "%s %s:%s\n", "login", user, psw);
  if (send(fd, both, 256, 0) < 0)
    error("ERROR sending message");
  receive_msg(fd, temp_buf);
  printf("%s", temp_buf);
  if (strcmp(temp_buf, "Access denied\n") == 0)
    exit(0);
}


x86 assembly (clang, -O0):
<authenticate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8120,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0xe64(%rip),%rsi
lea    0xe67(%rip),%rdx
call   1080 <sprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1030 <send@plt>
cmp    $0x0,%rax
jge    11d4 <authenticate+0x64>
lea    0xe41(%rip),%rdi
call   1070 <error@plt>
mov    -0x4(%rbp),%edi
lea    -0x8120(%rbp),%rsi
call   1050 <receive_msg@plt>
lea    -0x8120(%rbp),%rsi
lea    0xe35(%rip),%rdi
call   1040 <printf@plt>
lea    -0x8120(%rbp),%rdi
lea    0xe25(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    121a <authenticate+0xaa>
xor    %edi,%edi
call   1090 <exit@plt>
add    $0x8120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<authenticate>:
push   %rbp
push   %r14
push   %rbx
sub    $0x8100,%rsp
mov    %rdx,%r8
mov    %rsi,%rcx
mov    %edi,%ebp
lea    0xe76(%rip),%rsi
lea    0xe79(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
call   1080 <sprintf@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1030 <send@plt>
test   %rax,%rax
jns    11be <authenticate+0x4e>
lea    0xe57(%rip),%rdi
call   1070 <error@plt>
lea    0x100(%rsp),%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1050 <receive_msg@plt>
lea    0xe4f(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xe43(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11ff <authenticate+0x8f>
add    $0x8100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"%s %s:%s\0A\00"
@.str.1 = [6 x i8] c"login\00"
@.str.2 = [22 x i8] c"ERROR sending message\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [15 x i8] c"Access denied\0A\00"
define void @authenticate(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [256 x i8]
%8 = alloca [32768 x i8]
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%10 = load i8*, i8** %5
%11 = load i8*, i8** %6
%12 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %10, i8* %11)
%13 = load i32, i32* %4
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%15 = call i64 @send(i32 %13, i8* %14, i32 256, i32 0)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %3
%18 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %17, %3
%20 = load i32, i32* %4
%21 = getelementptr inbounds [32768 x i8], [32768 x i8]* %8, i64 0, i64 0
%22 = call i32 @receive_msg(i32 %20, i8* %21)
%23 = getelementptr inbounds [32768 x i8], [32768 x i8]* %8, i64 0, i64 0
%24 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds [32768 x i8], [32768 x i8]* %8, i64 0, i64 0
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %19
%29 = call i32 @exit(i32 0)
unreachable
30: ; preds = %19
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"%s %s:%s\0A\00"
@.str.1 = [6 x i8] c"login\00"
@.str.2 = [22 x i8] c"ERROR sending message\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [15 x i8] c"Access denied\0A\00"
define void @authenticate(i32 %0, i8* %1, i8* %2) {
%4 = alloca [256 x i8]
%5 = alloca [32768 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [32768 x i8], [32768 x i8]* %5, i64 0, i64 0
%8 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %2)
%9 = call i64 @send(i32 %0, i8* %6, i32 256, i32 0)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %3
%14 = call i32 @receive_msg(i32 %0, i8* %7)
%15 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%16 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 @exit(i32 0)
unreachable
20: ; preds = %13
ret void
}