#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 */

/* Variables and functions */
int atoi(char *);
char *pipe2string(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int update_folder_count(char *folder_name, char *where_clause) {
  char sys_string[1024];
  char *results;
  sprintf(sys_string, "select.sh 'count(1)' %s \"%s\"", folder_name,
          where_clause);
  if ((results = pipe2string(sys_string))) {
    return atoi(results);
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<update_folder_count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xea7(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x420(%rbp),%rdi
call   1030 <pipe2string@plt>
mov    %rax,-0x428(%rbp)
cmp    $0x0,%rax
je     118f <update_folder_count+0x5f>
mov    -0x428(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x4(%rbp)
jmp    1196 <update_folder_count+0x66>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_folder_count>:
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%rcx
mov    %rdi,%rdx
lea    0xebb(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <pipe2string@plt>
test   %rax,%rax
je     1167 <update_folder_count+0x37>
mov    %rax,%rdi
call   1040 <atoi@plt>
jmp    1169 <update_folder_count+0x39>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"select.sh 'count(1)' %s \22%s\22\00"
define i32 @update_folder_count(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [1024 x i8]
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%9 = load i8*, i8** %4
%10 = load i8*, i8** %5
%11 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %10)
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%13 = call i8* @pipe2string(i8* %12)
store i8* %13, i8** %7
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = load i8*, i8** %7
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %3
br label %19
18: ; preds = %2
store i32 0, i32* %3
br label %19
19: ; preds = %18, %15
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@.str = [29 x i8] c"select.sh 'count(1)' %s \22%s\22\00"
define i32 @update_folder_count(i8* %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%6 = call i8* @pipe2string(i8* %4)
%7 = icmp eq i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = call i32 @atoi(i8* %6)
br label %10
10: ; preds = %2, %8
%11 = phi i32 [ %9, %8 ], [ 0, %2 ]
ret i32 %11
}