#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 get_line(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
char *strdup(char *);
char *get_line_system(char *sys_string) {
  char buffer[4096];
  FILE *p;
  int return_value;
  p = popen(sys_string, "r");
  return_value = get_line(buffer, p);
  pclose(p);
  if (!return_value)
    return (char *)0;
  else
    return strdup(buffer);
}


x86 assembly (clang, -O0):
<get_line_system>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1050 <popen@plt>
mov    %rax,-0x1018(%rbp)
lea    -0x1010(%rbp),%rdi
mov    -0x1018(%rbp),%rsi
call   1030 <get_line@plt>
mov    %eax,-0x101c(%rbp)
mov    -0x1018(%rbp),%rdi
call   1040 <pclose@plt>
cmpl   $0x0,-0x101c(%rbp)
jne    11a5 <get_line_system+0x65>
movq   $0x0,-0x8(%rbp)
jmp    11b5 <get_line_system+0x75>
lea    -0x1010(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_line_system>:
push   %rbp
push   %rbx
sub    $0x1008,%rsp
lea    0xeb0(%rip),%rsi
call   1050 <popen@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    %rax,%rsi
call   1030 <get_line@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <pclose@plt>
test   %ebp,%ebp
je     117b <get_line_system+0x3b>
mov    %rsp,%rdi
call   1060 <strdup@plt>
jmp    117d <get_line_system+0x3d>
xor    %eax,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i8* @get_line_system(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [4096 x i8]
%5 = alloca i32*
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i32* @popen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %5
%9 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%10 = load i32*, i32** %5
%11 = call i32 @get_line(i8* %9, i32* %10)
store i32 %11, i32* %6
%12 = load i32*, i32** %5
%13 = call i32 @pclose(i32* %12)
%14 = load i32, i32* %6
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %1
store i8* null, i8** %2
br label %20
17: ; preds = %1
%18 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%19 = call i8* @strdup(i8* %18)
store i8* %19, i8** %2
br label %20
20: ; preds = %17, %16
%21 = load i8*, i8** %2
ret i8* %21
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define noalias i8* @get_line_system(i8* nocapture %0) {
%2 = alloca [4096 x i8]
%3 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%4 = tail call i32* @popen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @get_line(i8* %3, i32* %4)
%6 = call i32 @pclose(i32* %4)
%7 = icmp eq i32 %5, 0
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = call i8* @strdup(i8* %3)
br label %10
10: ; preds = %1, %8
%11 = phi i8* [ %9, %8 ], [ null, %1 ]
ret i8* %11
}