#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 */
char *appaserver_get_error_filename(char *);
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ pipe2string(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, int, char *);
int appaserver_library_get_reference_number(char *application_name,
                                            int insert_rows_number) {
  char sys_string[1024];
  sprintf(sys_string, "reference_number.sh \"%s\" %d 2>>%s", application_name,
          insert_rows_number, appaserver_get_error_filename(application_name));
  return atoi(pipe2string(sys_string));
}


x86 assembly (clang, -O0):
<appaserver_library_get_reference_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x428(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x420(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x414(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <appaserver_get_error_filename@plt>
mov    -0x428(%rbp),%rdi
mov    -0x420(%rbp),%rdx
mov    -0x414(%rbp),%ecx
mov    %rax,%r8
lea    0xe65(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x410(%rbp),%rdi
call   1030 <pipe2string@plt>
mov    %eax,%edi
call   1050 <atoi@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<appaserver_library_get_reference_number>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
call   1040 <appaserver_get_error_filename@plt>
lea    0xea4(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %ebp,%ecx
mov    %rax,%r8
call   1060 <sprintf@plt>
mov    %r14,%rdi
call   1030 <pipe2string@plt>
mov    %eax,%edi
call   1050 <atoi@plt>
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"reference_number.sh \22%s\22 %d 2>>%s\00"
define i32 @appaserver_library_get_reference_number(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [1024 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%7 = load i8*, i8** %3
%8 = load i32, i32* %4
%9 = load i8*, i8** %3
%10 = call i8* @appaserver_get_error_filename(i8* %9)
%11 = call i32 @sprintf(i8* %6, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %7, i32 %8, i8* %10)
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%13 = call i32 @pipe2string(i8* %12)
%14 = call i32 @atoi(i32 %13)
ret i32 %14
}

LLVM IR (-O2):
@.str = [34 x i8] c"reference_number.sh \22%s\22 %d 2>>%s\00"
define i32 @appaserver_library_get_reference_number(i8* %0, i32 %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = tail call i8* @appaserver_get_error_filename(i8* %0)
%6 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1, i8* %5)
%7 = call i32 @pipe2string(i8* %4)
%8 = call i32 @atoi(i32 %7)
ret i32 %8
}