#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*/ fgets(char *, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ *popen(char *, char *);
void get_connection_info(char *buf, size_t buf_len) {
  FILE *pf;
  pf = popen("~/scripts/dwmstatus-connection-info.sh", "r");
  if (NULL == pf) {
    perror("connection info");
  } else {
    fgets(buf, buf_len, pf);
    pclose(pf);
  }
}


x86 assembly (clang, -O0):
<get_connection_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea9(%rip),%rdi
lea    0xec9(%rip),%rsi
call   1050 <popen@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    1184 <get_connection_info+0x44>
lea    0xeaf(%rip),%rdi
call   1060 <perror@plt>
jmp    119e <get_connection_info+0x5e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <fgets@plt>
mov    -0x18(%rbp),%rdi
call   1030 <pclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_connection_info>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xeae(%rip),%rdi
lea    0xece(%rip),%rsi
call   1050 <popen@plt>
test   %rax,%rax
je     1181 <get_connection_info+0x41>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1040 <fgets@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <pclose@plt>
lea    0xea1(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <perror@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"~/scripts/dwmstatus-connection-info.sh\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [16 x i8] c"connection info\00"
define void @get_connection_info(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32*
store i8* %0, i8** %3
store i64 %1, i64* %4
%6 = call i32* @popen(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %5
%7 = load i32*, i32** %5
%8 = icmp eq i32* null, %7
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %18
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = load i64, i64* %4
%14 = load i32*, i32** %5
%15 = call i32 @fgets(i8* %12, i64 %13, i32* %14)
%16 = load i32*, i32** %5
%17 = call i32 @pclose(i32* %16)
br label %18
18: ; preds = %11, %9
ret void
}

LLVM IR (-O2):
@.str = [39 x i8] c"~/scripts/dwmstatus-connection-info.sh\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [16 x i8] c"connection info\00"
define void @get_connection_info(i8* %0, i64 %1) {
%3 = tail call i32* @popen(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %10
7: ; preds = %2
%8 = tail call i32 @fgets(i8* %0, i64 %1, i32* %3)
%9 = tail call i32 @pclose(i32* %3)
br label %10
10: ; preds = %7, %5
ret void
}