#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 */
char EOF;
int /*<<< orphan*/ exit(int);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *const, char *const);
int main(int argc, char *const argv[]) {
  if (argc < 1) {
    printf("Passing some arguments\n");
    exit(1);
  }
  char command[200];
  int counter = 0;
  sprintf(command, "%s %s", argv[1], argv[2]);
  FILE *pipe_descr = popen(command, "r");
  char sym;
  sym = fgetc(pipe_descr);
  if (sym == '0')
    ++counter;
  while (sym != EOF) {
    sym = fgetc(pipe_descr);
    if (sym == '0') {
      ++counter;
    }
  }
  printf("%d\n", counter);
  pclose(pipe_descr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    119b <main+0x3b>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movl   $0x0,-0xe4(%rbp)
lea    -0xe0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xe55(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0xe0(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,-0xf0(%rbp)
mov    -0xf0(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0xf1(%rbp)
movsbl -0xf1(%rbp),%eax
cmp    $0x30,%eax
jne    1213 <main+0xb3>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    1218 <main+0xb8>
movsbl -0xf1(%rbp),%eax
mov    0x2dc2(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1267 <main+0x107>
mov    -0xf0(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0xf1(%rbp)
movsbl -0xf1(%rbp),%eax
cmp    $0x30,%eax
jne    1262 <main+0x102>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    1218 <main+0xb8>
mov    -0xe4(%rbp),%esi
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xf0(%rbp),%rdi
call   1040 <pclose@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0xd0,%rsp
test   %edi,%edi
jle    120c <main+0x9c>
mov    0x8(%rsi),%rdx
mov    0x10(%rsi),%rcx
lea    0xe6e(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1080 <sprintf@plt>
lea    0xe62(%rip),%rsi
mov    %rbx,%rdi
call   1070 <popen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <fgetc@plt>
xor    %ebp,%ebp
cmp    $0x30,%al
sete   %bpl
mov    0x2e22(%rip),%r14
cmp    (%r14),%al
je     11e6 <main+0x76>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <fgetc@plt>
xor    %ecx,%ecx
cmp    $0x30,%al
sete   %cl
add    %ecx,%ebp
cmp    (%r14),%al
jne    11d0 <main+0x60>
lea    0xe1b(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <pclose@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xdf9(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"Passing some arguments\0A\00"
@.str.1 = [6 x i8] c"%s %s\00"
@.str.2 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [200 x i8]
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 1
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
store i32 0, i32* %7
%16 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %19, i8* %22)
%24 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%25 = call i32* @popen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %25, i32** %8
%26 = load i32*, i32** %8
%27 = call signext i8 @fgetc(i32* %26)
store i8 %27, i8* %9
%28 = load i8, i8* %9
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 48
br i1 %30, label %31, label %34
31: ; preds = %15
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %34
34: ; preds = %31, %15
br label %35
35: ; preds = %50, %34
%36 = load i8, i8* %9
%37 = sext i8 %36 to i32
%38 = load i8, i8* @EOF
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %37, %39
br i1 %40, label %41, label %51
41: ; preds = %35
%42 = load i32*, i32** %8
%43 = call signext i8 @fgetc(i32* %42)
store i8 %43, i8* %9
%44 = load i8, i8* %9
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 48
br i1 %46, label %47, label %50
47: ; preds = %41
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
store i32 %49, i32* %7
br label %50
50: ; preds = %47, %41
br label %35
51: ; preds = %35
%52 = load i32, i32* %7
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %52)
%54 = load i32*, i32** %8
%55 = call i32 @pclose(i32* %54)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%s %s\00"
@.str.2 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.3 = [4 x i8] c"%d\0A\00"
@str = [23 x i8] c"Passing some arguments\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [200 x i8]
%4 = icmp slt i32 %0, 1
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %11, i8* %13)
%15 = call i32* @popen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call signext i8 @fgetc(i32* %15)
%17 = icmp eq i8 %16, 48
%18 = zext i1 %17 to i32
%19 = load i8, i8* @EOF
%20 = icmp eq i8 %16, %19
br i1 %20, label %29, label %21
21: ; preds = %8, %21
%22 = phi i32 [ %26, %21 ], [ %18, %8 ]
%23 = tail call signext i8 @fgetc(i32* %15)
%24 = icmp eq i8 %23, 48
%25 = zext i1 %24 to i32
%26 = add nuw nsw i32 %22, %25
%27 = load i8, i8* @EOF
%28 = icmp eq i8 %23, %27
br i1 %28, label %29, label %21
29: ; preds = %21, %8
%30 = phi i32 [ %18, %8 ], [ %26, %21 ]
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = tail call i32 @pclose(i32* %15)
ret i32 0
}