#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 add_makefile_entry_to_file(char *, char *, char *);
scalar_t__ file_exists(char *);
int /*<<< orphan*/ get_setting(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char);
int add_makefile_entry(char *section, char *entry) {
  char directory[512];
  char filename[512];
  get_setting("directory", directory);
  sprintf(filename, "%s%cMakefile", directory, '/');
  if (file_exists(filename) == 0)
    return -1;
  return add_makefile_entry_to_file(filename, section, entry);
}


x86 assembly (clang, -O0):
<add_makefile_entry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x220(%rbp),%rsi
lea    0xe9f(%rip),%rdi
call   1040 <get_setting@plt>
lea    -0x420(%rbp),%rdi
lea    -0x220(%rbp),%rdx
lea    0xe8f(%rip),%rsi
mov    $0x2f,%ecx
call   1050 <sprintf@plt>
lea    -0x420(%rbp),%rdi
call   1030 <file_exists@plt>
cmp    $0x0,%rax
jne    11a7 <add_makefile_entry+0x67>
movl   $0xffffffff,-0x4(%rbp)
jmp    11be <add_makefile_entry+0x7e>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <add_makefile_entry_to_file@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_makefile_entry>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xea5(%rip),%rdi
lea    0x200(%rsp),%r12
mov    %r12,%rsi
call   1040 <get_setting@plt>
lea    0xe98(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r12,%rdx
mov    $0x2f,%ecx
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <file_exists@plt>
test   %rax,%rax
je     11a2 <add_makefile_entry+0x62>
mov    %rsp,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1060 <add_makefile_entry_to_file@plt>
jmp    11a7 <add_makefile_entry+0x67>
mov    $0xffffffff,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"directory\00"
@.str.1 = [13 x i8] c"%s%cMakefile\00"
define i32 @add_makefile_entry(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [512 x i8]
%7 = alloca [512 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%9 = call i32 @get_setting(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%12 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %11, i8 signext 47)
%13 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%14 = call i64 @file_exists(i8* %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %2
store i32 -1, i32* %3
br label %22
17: ; preds = %2
%18 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%19 = load i8*, i8** %4
%20 = load i8*, i8** %5
%21 = call i32 @add_makefile_entry_to_file(i8* %18, i8* %19, i8* %20)
store i32 %21, i32* %3
br label %22
22: ; preds = %17, %16
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@.str = [10 x i8] c"directory\00"
@.str.1 = [13 x i8] c"%s%cMakefile\00"
define i32 @add_makefile_entry(i8* %0, i8* %1) {
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%7 = call i32 @get_setting(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %5)
%8 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8 signext 47)
%9 = call i64 @file_exists(i8* %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = call i32 @add_makefile_entry_to_file(i8* %6, i8* %0, i8* %1)
br label %13
13: ; preds = %2, %11
%14 = phi i32 [ %12, %11 ], [ -1, %2 ]
ret i32 %14
}