#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 */
int /*<<< orphan*/ fputs(char const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char const *, char *);
int /*<<< orphan*/ printf(char *, char const *);
void sendBuffer(const char *buffer, const char *prgname) {
  FILE *x = popen(prgname, "ew");
  if (x) {
    fputs(buffer, x);
    pclose(x);
  } else {
    printf("RFIDer: unable to exec %s\n", prgname);
  }
}


x86 assembly (clang, -O0):
<sendBuffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     118a <sendBuffer+0x4a>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <fputs@plt>
mov    -0x18(%rbp),%rdi
call   1040 <pclose@plt>
jmp    119a <sendBuffer+0x5a>
mov    -0x10(%rbp),%rsi
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendBuffer>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xeae(%rip),%rsi
mov    %r15,%rdi
call   1060 <popen@plt>
test   %rax,%rax
je     117a <sendBuffer+0x3a>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <fputs@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <pclose@plt>
lea    0xe82(%rip),%rdi
mov    %r15,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"ew\00"
@.str.1 = [27 x i8] c"RFIDer: unable to exec %s\0A\00"
define void @sendBuffer(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = call i32* @popen(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %5
%8 = load i32*, i32** %5
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = load i32*, i32** %5
%13 = call i32 @fputs(i8* %11, i32* %12)
%14 = load i32*, i32** %5
%15 = call i32 @pclose(i32* %14)
br label %19
16: ; preds = %2
%17 = load i8*, i8** %4
%18 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %16, %10
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"ew\00"
@.str.1 = [27 x i8] c"RFIDer: unable to exec %s\0A\00"
define void @sendBuffer(i8* nocapture %0, i8* %1) {
%3 = tail call i32* @popen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 @fputs(i8* %0, i32* %3)
%7 = tail call i32 @pclose(i32* %3)
br label %10
8: ; preds = %2
%9 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %10
10: ; preds = %8, %5
ret void
}