#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*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ get_line(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
int strlen(char *);
main() {
  char input_line[128];
  char shef_alias_string[128], shef_code[128];
  char sys_string[1024];
  FILE *p;
  int i = 0;
  sprintf(sys_string, "./shef_alias_list.sh %s %s", "everglades", "hydrology");
  fprintf(stderr, "%s\n", sys_string);
  p = popen(sys_string, "r");
  while (get_line(input_line, p)) {
    input_line[strlen(input_line) - 1] = '\0';
    fprintf(stderr, "got = %s\n", input_line);
  }
  pclose(p);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x5a0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x59c(%rbp)
lea    -0x590(%rbp),%rdi
lea    0xe76(%rip),%rsi
lea    0xe8a(%rip),%rdx
lea    0xe8e(%rip),%rcx
call   1080 <sprintf@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    -0x590(%rbp),%rdx
lea    0xe84(%rip),%rsi
call   1060 <fprintf@plt>
lea    -0x590(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1070 <popen@plt>
mov    %rax,-0x598(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x598(%rbp),%rsi
call   1030 <get_line@plt>
cmp    $0x0,%rax
je     122a <main+0xca>
lea    -0x90(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x90(%rbp,%rax,1)
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
lea    -0x90(%rbp),%rdx
lea    0xe12(%rip),%rsi
call   1060 <fprintf@plt>
jmp    11d3 <main+0x73>
mov    -0x598(%rbp),%rdi
call   1050 <pclose@plt>
mov    -0x4(%rbp),%eax
add    $0x5a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x488,%rsp
lea    0xe8b(%rip),%rsi
lea    0xe9f(%rip),%rdx
lea    0xea3(%rip),%rcx
lea    0x80(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <sprintf@plt>
mov    0x2e46(%rip),%r12
mov    (%r12),%edi
lea    0xe93(%rip),%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
lea    0xe7c(%rip),%rsi
mov    %rbx,%rdi
call   1070 <popen@plt>
mov    %rax,%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <get_line@plt>
test   %rax,%rax
je     120e <main+0xae>
lea    0xe59(%rip),%r15
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    (%r12),%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <get_line@plt>
test   %rax,%rax
jne    11e0 <main+0x80>
mov    %r14,%rdi
call   1050 <pclose@plt>
xor    %eax,%eax
add    $0x488,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [27 x i8] c"./shef_alias_list.sh %s %s\00"
@.str.1 = [11 x i8] c"everglades\00"
@.str.2 = [10 x i8] c"hydrology\00"
@stderr = global i32 0
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [10 x i8] c"got = %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [128 x i8]
%3 = alloca [128 x i8]
%4 = alloca [128 x i8]
%5 = alloca [1024 x i8]
%6 = alloca i32*
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %7
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%9 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32, i32* @stderr
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%12 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%14 = call i32* @popen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %14, i32** %6
br label %15
15: ; preds = %20, %0
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%17 = load i32*, i32** %6
%18 = call i64 @get_line(i8* %16, i32* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %29
20: ; preds = %15
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%22 = call i32 @strlen(i8* %21)
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %24
store i8 0, i8* %25
%26 = load i32, i32* @stderr
%27 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%28 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %27)
br label %15
29: ; preds = %15
%30 = load i32*, i32** %6
%31 = call i32 @pclose(i32* %30)
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@.str = [27 x i8] c"./shef_alias_list.sh %s %s\00"
@.str.1 = [11 x i8] c"everglades\00"
@.str.2 = [10 x i8] c"hydrology\00"
@stderr = global i32 0
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [10 x i8] c"got = %s\0A\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%8 = call i32* @popen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%9 = call i64 @get_line(i8* %3, i32* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %20, label %11
11: ; preds = %0, %11
%12 = call i32 @strlen(i8* %3)
%13 = add nsw i32 %12, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 %14
store i8 0, i8* %15
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %3)
%18 = call i64 @get_line(i8* %3, i32* %8)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %11
20: ; preds = %11, %0
%21 = call i32 @pclose(i32* %8)
ret i32 0
}