#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 */
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ perror(char *);
int sscanf(char *, char *, char *, char *);
scalar_t__ strcmp(char *, char *);
size_t strlen(char *);
int readFile(char name[], FILE *ofp) {
  FILE *fp;
  char line[1024], word[1024], word2[1024];
  size_t len = strlen(name);
  if (name[len - 1] == '"')
    name[len - 1] = '\0';
  if (name[0] == '"') {
    name++;
  }
  if ((fp = fopen(name, "r")) == 0) {
    perror("open");
    return 1;
  }
  while (fgets(line, 1024, fp)) {
    if (sscanf(line, "%s%s", word, word2) == 2 && strcmp(word, "import") == 0) {
      readFile(word2, ofp);
    } else
      fprintf(ofp, "%s", line);
  }
}


x86 assembly (clang, -O0):
<readFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0xc28(%rbp)
mov    -0x10(%rbp),%rax
mov    -0xc28(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x22,%eax
jne    11d2 <readFile+0x52>
mov    -0x10(%rbp),%rax
mov    -0xc28(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    11ee <readFile+0x6e>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe07(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1224 <readFile+0xa4>
lea    0xdef(%rip),%rdi
call   1090 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    12c0 <readFile+0x140>
jmp    1229 <readFile+0xa9>
lea    -0x420(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x400,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     12c0 <readFile+0x140>
lea    -0x420(%rbp),%rdi
lea    -0x820(%rbp),%rdx
lea    -0xc20(%rbp),%rcx
lea    0xda3(%rip),%rsi
call   1070 <sscanf@plt>
cmp    $0x2,%eax
jne    12a4 <readFile+0x124>
lea    -0x820(%rbp),%rdi
lea    0xd8c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12a4 <readFile+0x124>
lea    -0xc20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10a0 <readFile@plt>
jmp    12bb <readFile+0x13b>
mov    -0x18(%rbp),%rdi
lea    -0x420(%rbp),%rdx
lea    0xd53(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1229 <readFile+0xa9>
mov    -0x4(%rbp),%eax
add    $0xc30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc08,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmpb   $0x22,-0x1(%rax,%rbx,1)
jne    11a8 <readFile+0x28>
movb   $0x0,-0x1(%rbx,%rax,1)
xor    %edi,%edi
cmpb   $0x22,(%rbx)
sete   %dil
add    %rbx,%rdi
lea    0xe45(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1267 <readFile+0xe7>
mov    %rax,%r12
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1273 <readFile+0xf3>
lea    0xe1b(%rip),%r15
mov    %rsp,%rbx
lea    0x800(%rsp),%r13
lea    0x400(%rsp),%rbp
jmp    1230 <readFile+0xb0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <fputs@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r12,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1273 <readFile+0xf3>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
call   1070 <sscanf@plt>
cmp    $0x2,%eax
jne    1210 <readFile+0x90>
mov    %r13,%rdi
lea    0xdbc(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1210 <readFile+0x90>
mov    %rbp,%rdi
mov    %r14,%rsi
call   10a0 <readFile@plt>
jmp    121b <readFile+0x9b>
lea    0xd94(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%eax
add    $0xc08,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [5 x i8] c"%s%s\00"
@.str.3 = [7 x i8] c"import\00"
@.str.4 = [3 x i8] c"%s\00"
define i32 @readFile(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca [1024 x i8]
%8 = alloca [1024 x i8]
%9 = alloca [1024 x i8]
%10 = alloca i64
store i8* %0, i8** %4
store i32* %1, i32** %5
%11 = load i8*, i8** %4
%12 = call i64 @strlen(i8* %11)
store i64 %12, i64* %10
%13 = load i8*, i8** %4
%14 = load i64, i64* %10
%15 = sub i64 %14, 1
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 34
br i1 %19, label %20, label %25
20: ; preds = %2
%21 = load i8*, i8** %4
%22 = load i64, i64* %10
%23 = sub i64 %22, 1
%24 = getelementptr inbounds i8, i8* %21, i64 %23
store i8 0, i8* %24
br label %25
25: ; preds = %20, %2
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 0
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 34
br i1 %30, label %31, label %34
31: ; preds = %25
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %4
br label %34
34: ; preds = %31, %25
%35 = load i8*, i8** %4
%36 = call i32* @fopen(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %36, i32** %6
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %65
40: ; preds = %34
br label %41
41: ; preds = %64, %40
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%43 = load i32*, i32** %6
%44 = call i64 @fgets(i8* %42, i32 1024, i32* %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %65
46: ; preds = %41
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%48 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%50 = call i32 @sscanf(i8* %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %48, i8* %49)
%51 = icmp eq i32 %50, 2
br i1 %51, label %52, label %60
52: ; preds = %46
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%54 = call i64 @strcmp(i8* %53, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %60
56: ; preds = %52
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%58 = load i32*, i32** %5
%59 = call i32 @readFile(i8* %57, i32* %58)
br label %64
60: ; preds = %52, %46
%61 = load i32*, i32** %5
%62 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%63 = call i32 @fprintf(i32* %61, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %62)
br label %64
64: ; preds = %60, %56
br label %41
65: ; preds = %38, %41
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [5 x i8] c"%s%s\00"
@.str.3 = [7 x i8] c"import\00"
define i32 @readFile(i8* nocapture %0, i32* nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%9 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%10 = add i64 %9, -1
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 34
br i1 %13, label %14, label %15
14: ; preds = %2
store i8 0, i8* %11
br label %15
15: ; preds = %14, %2
%16 = load i8, i8* %0
%17 = icmp eq i8 %16, 34
%18 = zext i1 %17 to i64
%19 = getelementptr i8, i8* %0, i64 %18
%20 = tail call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %25, label %22
22: ; preds = %15
%23 = call i64 @fgets(i8* %6, i32 1024, i32* %20)
%24 = icmp eq i64 %23, 0
br i1 %24, label %40, label %27
25: ; preds = %15
%26 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %40
27: ; preds = %22, %37
%28 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %7, i8* %8)
%29 = icmp eq i32 %28, 2
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 @readFile(i8* %8, i32* %1)
br label %37
35: ; preds = %30, %27
%36 = call i32 @fputs(i8* %6, i32* %1)
br label %37
37: ; preds = %35, %33
%38 = call i64 @fgets(i8* %6, i32 1024, i32* %20)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %27
40: ; preds = %37, %22, %25
ret i32 1
}