#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 smtp_errorCode(char *);
int sock_readLine(long, char *, int, unsigned long);
int sock_write(long, char *, unsigned long);
int smtp_sendCommand(long int sock, char *cmd, unsigned long timeout) {
  char buf[513];
  int err;
  err = sock_write(sock, cmd, timeout);
  if (err < 0)
    return err;
  err = sock_readLine(sock, buf, 513, timeout);
  if (err < 0)
    return err;
  return smtp_errorCode(buf);
}


x86 assembly (clang, -O0):
<smtp_sendCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <sock_write@plt>
mov    %eax,-0x234(%rbp)
cmpl   $0x0,-0x234(%rbp)
jge    1179 <smtp_sendCommand+0x49>
mov    -0x234(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c2 <smtp_sendCommand+0x92>
mov    -0x10(%rbp),%rdi
lea    -0x230(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    $0x201,%edx
call   1040 <sock_readLine@plt>
mov    %eax,-0x234(%rbp)
cmpl   $0x0,-0x234(%rbp)
jge    11b3 <smtp_sendCommand+0x83>
mov    -0x234(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c2 <smtp_sendCommand+0x92>
lea    -0x230(%rbp),%rdi
call   1030 <smtp_errorCode@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smtp_sendCommand>:
push   %r14
push   %rbx
sub    $0x208,%rsp
mov    %rdx,%r14
mov    %rdi,%rbx
call   1050 <sock_write@plt>
test   %eax,%eax
js     1168 <smtp_sendCommand+0x38>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x201,%edx
mov    %r14,%rcx
call   1040 <sock_readLine@plt>
test   %eax,%eax
js     1168 <smtp_sendCommand+0x38>
mov    %rsp,%rdi
call   1030 <smtp_errorCode@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @smtp_sendCommand(i64 %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i64
%8 = alloca [513 x i8]
%9 = alloca i32
store i64 %0, i64* %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%10 = load i64, i64* %5
%11 = load i8*, i8** %6
%12 = load i64, i64* %7
%13 = call i32 @sock_write(i64 %10, i8* %11, i64 %12)
store i32 %13, i32* %9
%14 = load i32, i32* %9
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = load i32, i32* %9
store i32 %17, i32* %4
br label %30
18: ; preds = %3
%19 = load i64, i64* %5
%20 = getelementptr inbounds [513 x i8], [513 x i8]* %8, i64 0, i64 0
%21 = load i64, i64* %7
%22 = call i32 @sock_readLine(i64 %19, i8* %20, i32 513, i64 %21)
store i32 %22, i32* %9
%23 = load i32, i32* %9
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %18
%26 = load i32, i32* %9
store i32 %26, i32* %4
br label %30
27: ; preds = %18
%28 = getelementptr inbounds [513 x i8], [513 x i8]* %8, i64 0, i64 0
%29 = call i32 @smtp_errorCode(i8* %28)
store i32 %29, i32* %4
br label %30
30: ; preds = %27, %25, %16
%31 = load i32, i32* %4
ret i32 %31
}

LLVM IR (-O2):
define i32 @smtp_sendCommand(i64 %0, i8* %1, i64 %2) {
%4 = alloca [513 x i8]
%5 = getelementptr inbounds [513 x i8], [513 x i8]* %4, i64 0, i64 0
%6 = tail call i32 @sock_write(i64 %0, i8* %1, i64 %2)
%7 = icmp slt i32 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %3
%9 = call i32 @sock_readLine(i64 %0, i8* %5, i32 513, i64 %2)
%10 = icmp slt i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = call i32 @smtp_errorCode(i8* %5)
br label %13
13: ; preds = %8, %3, %11
%14 = phi i32 [ %12, %11 ], [ %6, %3 ], [ %9, %8 ]
ret i32 %14
}