#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 */
struct client {
  int dummy;
};

/* Variables and functions */
struct client *get_client(int);
int /*<<< orphan*/ server_close_client(struct client *);
int write(int, char *, int);
struct client *protocol_smtp_newclient(int fd) {
  int r;
  struct client *from = get_client(fd);
  r = write(fd, "220 PubSub Server\r\n", 19);
  if (r < 0) {
    server_close_client(from);
    return NULL;
  }
  return from;
}


x86 assembly (clang, -O0):
<protocol_smtp_newclient>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <get_client@plt>
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
lea    0xeaf(%rip),%rsi
mov    $0x13,%edx
call   1030 <write@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    117e <protocol_smtp_newclient+0x4e>
mov    -0x18(%rbp),%rdi
call   1050 <server_close_client@plt>
movq   $0x0,-0x8(%rbp)
jmp    1186 <protocol_smtp_newclient+0x56>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<protocol_smtp_newclient>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
call   1040 <get_client@plt>
mov    %rax,%rbx
lea    0xebc(%rip),%rsi
mov    %ebp,%edi
mov    $0x13,%edx
call   1030 <write@plt>
test   %eax,%eax
jns    115e <protocol_smtp_newclient+0x2e>
mov    %rbx,%rdi
call   1050 <server_close_client@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.client = type { i32 }
@.str = [20 x i8] c"220 PubSub Server\0D\0A\00"
define %struct.client* @protocol_smtp_newclient(i32 %0) {
%2 = alloca %struct.client*
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.client*
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = call %struct.client* @get_client(i32 %6)
store %struct.client* %7, %struct.client** %5
%8 = load i32, i32* %3
%9 = call i32 @write(i32 %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 19)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = load %struct.client*, %struct.client** %5
%14 = call i32 @server_close_client(%struct.client* %13)
store %struct.client* null, %struct.client** %2
br label %17
15: ; preds = %1
%16 = load %struct.client*, %struct.client** %5
store %struct.client* %16, %struct.client** %2
br label %17
17: ; preds = %15, %12
%18 = load %struct.client*, %struct.client** %2
ret %struct.client* %18
}

LLVM IR (-O2):
%struct.client = type { i32 }
@.str = [20 x i8] c"220 PubSub Server\0D\0A\00"
define %struct.client* @protocol_smtp_newclient(i32 %0) {
%2 = tail call %struct.client* @get_client(i32 %0)
%3 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 19)
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @server_close_client(%struct.client* %2)
br label %7
7: ; preds = %1, %5
%8 = phi %struct.client* [ null, %5 ], [ %2, %1 ]
ret %struct.client* %8
}