#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*/ gethostname(char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ write(int, char *, scalar_t__);
int smtp_sendGreeting(int socket) {
  char buf[1024];
  char hostname[1024];
  gethostname(hostname, 1024);
  snprintf(buf, 1024, "EHLO %s\r\n", hostname);
  write(socket, buf, 7 + strlen(hostname));
}


x86 assembly (clang, -O0):
<smtp_sendGreeting>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x810(%rbp),%rdi
mov    $0x400,%esi
call   1060 <gethostname@plt>
lea    -0x410(%rbp),%rdi
lea    -0x810(%rbp),%rcx
mov    $0x400,%esi
lea    0xe87(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x81c(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x818(%rbp)
lea    -0x810(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x81c(%rbp),%edi
mov    -0x818(%rbp),%rsi
mov    %rax,%rdx
add    $0x7,%rdx
call   1030 <write@plt>
mov    -0x4(%rbp),%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smtp_sendGreeting>:
push   %rbp
push   %r14
push   %rbx
sub    $0x800,%rsp
mov    %edi,%ebp
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1060 <gethostname@plt>
lea    0xe9c(%rip),%rdx
lea    0x400(%rsp),%r14
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rbx,%rcx
call   1050 <snprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x7(%rax),%rdx
mov    %ebp,%edi
mov    %r14,%rsi
call   1030 <write@plt>
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"EHLO %s\0D\0A\00"
define i32 @smtp_sendGreeting(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
store i32 %0, i32* %3
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%7 = call i32 @gethostname(i8* %6, i32 1024)
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%10 = call i32 @snprintf(i8* %8, i32 1024, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i32, i32* %3
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%14 = call i64 @strlen(i8* %13)
%15 = add nsw i64 7, %14
%16 = call i32 @write(i32 %11, i8* %12, i64 %15)
%17 = load i32, i32* %2
ret i32 %17
}

LLVM IR (-O2):
@.str = [10 x i8] c"EHLO %s\0D\0A\00"
define i32 @smtp_sendGreeting(i32 %0) {
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = call i32 @gethostname(i8* %5, i32 1024)
%7 = call i32 @snprintf(i8* %4, i32 1024, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %5)
%8 = call i64 @strlen(i8* %5)
%9 = add nsw i64 %8, 7
%10 = call i32 @write(i32 %0, i8* %4, i64 %9)
ret i32 undef
}