#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *_PATH_SENDMAIL;
int /*<<< orphan*/ err(char *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
FILE *open_sendmail() {
  FILE *fp;
  char buf[100];
  sprintf(buf, "%s -odq -t", _PATH_SENDMAIL);
  if ((fp = popen(buf, "w")) == NULL)
    err("cannot start sendmail");
  return fp;
}


x86 assembly (clang, -O0):
<open_sendmail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    -0x70(%rbp),%rdi
mov    0x2ea5(%rip),%rax
mov    (%rax),%rdx
lea    0xeb3(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    0xeae(%rip),%rsi
call   1040 <popen@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    117c <open_sendmail+0x4c>
lea    0xe96(%rip),%rdi
call   1030 <err@plt>
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_sendmail>:
push   %rbx
sub    $0x70,%rsp
mov    0x2eac(%rip),%rax
mov    (%rax),%rdx
lea    0xeba(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <sprintf@plt>
lea    0xeb3(%rip),%rsi
mov    %rbx,%rdi
call   1040 <popen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1174 <open_sendmail+0x44>
lea    0xe9e(%rip),%rdi
call   1030 <err@plt>
mov    %rbx,%rax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%s -odq -t\00"
@_PATH_SENDMAIL = global i8* null
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [22 x i8] c"cannot start sendmail\00"
define i32* @open_sendmail() {
%1 = alloca i32*
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%4 = load i8*, i8** @_PATH_SENDMAIL
%5 = call i32 @sprintf(i8* %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = call i32* @popen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %1
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @err(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %9, %0
%12 = load i32*, i32** %1
ret i32* %12
}

LLVM IR (-O2):
@.str = [11 x i8] c"%s -odq -t\00"
@_PATH_SENDMAIL = global i8* null
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [22 x i8] c"cannot start sendmail\00"
define noalias i32* @open_sendmail() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = load i8*, i8** @_PATH_SENDMAIL
%4 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = call i32* @popen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @err(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
ret i32* %5
}