#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int get_ind_count(char *fname) {
  char command[100] = "";
  sprintf(command, "wc -l %s", fname);
  FILE *fp = popen(command, "r");
  int n = 0;
  fscanf(fp, "%d", &n);
  printf("# samples = %d\n", n);
  fclose(fp);
  return n;
}


x86 assembly (clang, -O0):
<get_ind_count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe72(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1070 <popen@plt>
mov    %rax,-0x78(%rbp)
movl   $0x0,-0x7c(%rbp)
mov    -0x78(%rbp),%rdi
lea    0xe52(%rip),%rsi
lea    -0x7c(%rbp),%rdx
call   1060 <fscanf@plt>
mov    -0x7c(%rbp),%esi
lea    0xe42(%rip),%rdi
call   1040 <printf@plt>
mov    -0x78(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x7c(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_ind_count>:
push   %rbx
sub    $0x80,%rsp
mov    %rdi,%rdx
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
lea    0xe75(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <sprintf@plt>
lea    0xe6a(%rip),%rsi
mov    %rbx,%rdi
call   1060 <popen@plt>
mov    %rax,%rbx
movl   $0x0,0xc(%rsp)
lea    0xe52(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
call   1050 <fscanf@plt>
mov    0xc(%rsp),%esi
lea    0xe3d(%rip),%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    0xc(%rsp),%eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"wc -l %s\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [16 x i8] c"# samples = %d\0A\00"
define i32 @get_ind_count(i8* %0) {
%2 = alloca i8*
%3 = alloca [100 x i8]
%4 = alloca i32*
%5 = alloca i32
store i8* %0, i8** %2
%6 = bitcast [100 x i8]* %3 to i8*
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = load i8*, i8** %2
%9 = call i32 @sprintf(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%11 = call i32* @popen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %4
store i32 0, i32* %5
%12 = load i32*, i32** %4
%13 = call i32 @fscanf(i32* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%14 = load i32, i32* %5
%15 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = load i32*, i32** %4
%17 = call i32 @fclose(i32* %16)
%18 = load i32, i32* %5
ret i32 %18
}

LLVM IR (-O2):
@.str = [9 x i8] c"wc -l %s\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [16 x i8] c"# samples = %d\0A\00"
define i32 @get_ind_count(i8* %0) {
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = call i32* @popen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
%10 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%11 = call i32 @fclose(i32* %6)
%12 = load i32, i32* %3
ret i32 %12
}