#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 */
int /*<<< orphan*/ do_global_include(char *, char *);
scalar_t__ dupe_file(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ parse_f(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
void do_local_include(char *hdrname, char *pathname) {
  FILE *f;
  char tmp[512];
  sprintf(tmp, "%s/%s", pathname, hdrname);
  if (dupe_file(tmp)) {
    return;
  }
  if ((f = fopen(tmp, "r")) == NULL) {
    do_global_include(hdrname, pathname);
    return;
  }
  sprintf(tmp, "%s ", tmp);
  parse_f(f, pathname);
  printf("\\\n  %s ", tmp);
  fclose(f);
}


x86 assembly (clang, -O0):
<do_local_include>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x8(%rbp),%rcx
lea    0xe67(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x220(%rbp),%rdi
call   1080 <dupe_file@plt>
cmp    $0x0,%rax
je     11bb <do_local_include+0x4b>
jmp    1233 <do_local_include+0xc3>
lea    -0x220(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11ee <do_local_include+0x7e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <do_global_include@plt>
jmp    1233 <do_local_include+0xc3>
lea    -0x220(%rbp),%rdi
lea    -0x220(%rbp),%rdx
lea    0xe09(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <parse_f@plt>
lea    -0x220(%rbp),%rsi
lea    0xde3(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_local_include>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xe75(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %rbx,%rdi
call   1080 <dupe_file@plt>
test   %rax,%rax
jne    1208 <do_local_include+0x98>
lea    0xe54(%rip),%rsi
mov    %rsp,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     11fd <do_local_include+0x8d>
mov    %rax,%r15
lea    0xe43(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <parse_f@plt>
lea    0xe1d(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
jmp    1208 <do_local_include+0x98>
mov    %r12,%rdi
mov    %r14,%rsi
call   1050 <do_global_include@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%s \00"
@.str.3 = [8 x i8] c"\\\0A %s \00"
define void @do_local_include(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca [512 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%8 = load i8*, i8** %4
%9 = load i8*, i8** %3
%10 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %9)
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%12 = call i64 @dupe_file(i8* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %2
br label %34
15: ; preds = %2
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %5
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = load i8*, i8** %3
%21 = load i8*, i8** %4
%22 = call i32 @do_global_include(i8* %20, i8* %21)
br label %34
23: ; preds = %15
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%26 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = load i32*, i32** %5
%28 = load i8*, i8** %4
%29 = call i32 @parse_f(i32* %27, i8* %28)
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%31 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %30)
%32 = load i32*, i32** %5
%33 = call i32 @fclose(i32* %32)
br label %34
34: ; preds = %23, %19, %14
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%s \00"
@.str.3 = [8 x i8] c"\\\0A %s \00"
define void @do_local_include(i8* %0, i8* %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %0)
%6 = call i64 @dupe_file(i8* %4)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %2
%9 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 @do_global_include(i8* %0, i8* %1)
br label %18
13: ; preds = %8
%14 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%15 = call i32 @parse_f(i32* %9, i8* %1)
%16 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%17 = call i32 @fclose(i32* %9)
br label %18
18: ; preds = %2, %13, %11
ret void
}