#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, char *,
                           char *, char *, char *);
int /*<<< orphan*/ free(char *);
char *get_src(char *);
int /*<<< orphan*/ print_function(char *);
int /*<<< orphan*/ stderr;
int add_function(char *path, char *hpath) {
  char *raw;
  if ((raw = get_src(path)) == NULL) {
    free(path);
    path = NULL;
    return (-1);
  }
  print_function(raw);
  fprintf(stderr, "Writed %s%s%s'functions into %s%s%s\n", "\033[32m", path,
          "\033[0m", "\033[32m", hpath, "\033[0m");
  free(raw);
  free(path);
  path = NULL;
  return (0);
}


x86 assembly (clang, -O0):
<add_function>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <get_src@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1184 <add_function+0x44>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x10(%rbp)
movl   $0xffffffff,-0x4(%rbp)
jmp    11e8 <add_function+0xa8>
mov    -0x20(%rbp),%rdi
call   1040 <print_function@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r10
lea    0xe5b(%rip),%rsi
lea    0xe79(%rip),%r9
lea    0xe78(%rip),%rax
mov    %r9,%rdx
mov    %rax,%r8
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_function>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1060 <get_src@plt>
test   %rax,%rax
je     119d <add_function+0x5d>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <print_function@plt>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xebb(%rip),%r8
lea    0xe89(%rip),%rsi
lea    0xea7(%rip),%rdx
mov    %r15,%rcx
mov    %rdx,%r9
push   %r8
push   %r14
call   1050 <fprintf@plt>
add    $0x10,%rsp
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
jmp    11a2 <add_function+0x62>
mov    $0xffffffff,%ebx
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [37 x i8] c"Writed %s%s%s'functions into %s%s%s\0A\00"
@.str.1 = [6 x i8] c"\1B[32m\00"
@.str.2 = [5 x i8] c"\1B[0m\00"
define i32 @add_function(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = call i8* @get_src(i8* %7)
store i8* %8, i8** %6
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = call i32 @free(i8* %11)
store i8* null, i8** %4
store i32 -1, i32* %3
br label %24
13: ; preds = %2
%14 = load i8*, i8** %6
%15 = call i32 @print_function(i8* %14)
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %4
%18 = load i8*, i8** %5
%19 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%20 = load i8*, i8** %6
%21 = call i32 @free(i8* %20)
%22 = load i8*, i8** %4
%23 = call i32 @free(i8* %22)
store i8* null, i8** %4
store i32 0, i32* %3
br label %24
24: ; preds = %13, %10
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [37 x i8] c"Writed %s%s%s'functions into %s%s%s\0A\00"
@.str.1 = [6 x i8] c"\1B[32m\00"
@.str.2 = [5 x i8] c"\1B[0m\00"
define i32 @add_function(i8* %0, i8* %1) {
%3 = tail call i8* @get_src(i8* %0)
%4 = icmp eq i8* %3, null
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = tail call i32 @print_function(i8* %3)
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 @free(i8* %3)
br label %10
10: ; preds = %2, %5
%11 = phi i32 [ 0, %5 ], [ -1, %2 ]
%12 = tail call i32 @free(i8* %0)
ret i32 %11
}