#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
char *strstr(char *, char *);
void remove_upstream_inputs(char *node_name, char (*node_names)[256],
                            char *graph_file, int (*edit_var)[50]) {
  int i, j;
  char buffer[1024], parent_name[256], *p, *q;
  FILE *infile;
  infile = fopen(graph_file, "r");
  if (infile == NULL) {
    fprintf(stderr, "file open error, %s\n", graph_file);
    fflush(NULL);
  }
  while (fgets(buffer, 1024, infile)) {
    if (p = strstr(buffer, "->")) {
      if ((q = strstr(p, node_name))) {
        i = 0;
        while (buffer[i] != ':')
          parent_name[i++] = buffer[i];
        parent_name[i] = 0x0;
        for (i = 0; i < 100; i++)
          for (j = 0; j < 50; j++)
            if (!strcmp(node_names[i], parent_name) && edit_var[i][j])
              edit_var[i][j] = 1;
        remove_upstream_inputs(parent_name, node_names, graph_file, edit_var);
      }
    }
  }
  fclose(infile);
  return;
}


x86 assembly (clang, -O0):
<remove_upstream_inputs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x550,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x548(%rbp)
cmpq   $0x0,-0x548(%rbp)
jne    11e2 <remove_upstream_inputs+0x62>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe2e(%rip),%rsi
call   1070 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <fflush@plt>
jmp    11e7 <remove_upstream_inputs+0x67>
lea    -0x430(%rbp),%rdi
mov    -0x548(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1365 <remove_upstream_inputs+0x1e5>
lea    -0x430(%rbp),%rdi
lea    0xe00(%rip),%rsi
call   10a0 <strstr@plt>
mov    %rax,-0x538(%rbp)
cmp    $0x0,%rax
je     1360 <remove_upstream_inputs+0x1e0>
mov    -0x538(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   10a0 <strstr@plt>
mov    %rax,-0x540(%rbp)
cmp    $0x0,%rax
je     135b <remove_upstream_inputs+0x1db>
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
movsbl -0x430(%rbp,%rax,1),%eax
ff
cmp    $0x3a,%eax
je     128e <remove_upstream_inputs+0x10e>
movslq -0x24(%rbp),%rax
mov    -0x430(%rbp,%rax,1),%cl
mov    -0x24(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x24(%rbp)
cltq
mov    %cl,-0x530(%rbp,%rax,1)
jmp    1255 <remove_upstream_inputs+0xd5>
movslq -0x24(%rbp),%rax
movb   $0x0,-0x530(%rbp,%rax,1)
movl   $0x0,-0x24(%rbp)
cmpl   $0x64,-0x24(%rbp)
jge    1343 <remove_upstream_inputs+0x1c3>
movl   $0x0,-0x28(%rbp)
cmpl   $0x32,-0x28(%rbp)
jge    1330 <remove_upstream_inputs+0x1b0>
mov    -0x10(%rbp),%rdi
movslq -0x24(%rbp),%rax
shl    $0x8,%rax
add    %rax,%rdi
lea    -0x530(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    131d <remove_upstream_inputs+0x19d>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0xc8,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     131d <remove_upstream_inputs+0x19d>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0xc8,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
jmp    1322 <remove_upstream_inputs+0x1a2>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    12b2 <remove_upstream_inputs+0x132>
jmp    1335 <remove_upstream_inputs+0x1b5>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12a1 <remove_upstream_inputs+0x121>
lea    -0x530(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1040 <remove_upstream_inputs@plt>
jmp    1360 <remove_upstream_inputs+0x1e0>
jmp    11e7 <remove_upstream_inputs+0x67>
mov    -0x548(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x550,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_upstream_inputs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x528,%rsp
mov    %rcx,%r14
mov    %rsi,%rbx
mov    %rdi,0x18(%rsp)
lea    0xe5d(%rip),%rsi
mov    %rdx,(%rsp)
mov    %rdx,%rdi
call   1090 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    11d7 <remove_upstream_inputs+0x57>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
lea    0xe3b(%rip),%rsi
mov    (%rsp),%rdx
call   1070 <fprintf@plt>
xor    %edi,%edi
call   1080 <fflush@plt>
lea    0x120(%rsp),%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     132a <remove_upstream_inputs+0x1aa>
lea    0xe1b(%rip),%r12
lea    0x120(%rsp),%r13
lea    0x20(%rsp),%rbp
mov    %r15,0x8(%rsp)
mov    %r14,0x10(%rsp)
jmp    1264 <remove_upstream_inputs+0xe4>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    (%rsp),%rdx
mov    0x10(%rsp),%r14
mov    %r14,%rcx
call   1040 <remove_upstream_inputs@plt>
mov    0x8(%rsp),%r15
lea    0xdd4(%rip),%r12
lea    0x120(%rsp),%r13
mov    %r13,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     132a <remove_upstream_inputs+0x1aa>
mov    %r13,%rdi
mov    %r12,%rsi
call   10a0 <strstr@plt>
test   %rax,%rax
je     124b <remove_upstream_inputs+0xcb>
mov    %rax,%rdi
mov    0x18(%rsp),%rsi
call   10a0 <strstr@plt>
test   %rax,%rax
je     124b <remove_upstream_inputs+0xcb>
mov    0x120(%rsp),%al
cmp    $0x3a,%al
jne    1295 <remove_upstream_inputs+0x115>
xor    %ecx,%ecx
jmp    12b7 <remove_upstream_inputs+0x137>
xor    %edx,%edx
nopw   0x0(%rax,%rax,1)
lea    0x1(%rdx),%rcx
mov    %al,0x20(%rsp,%rdx,1)
movzbl 0x121(%rsp,%rdx,1),%eax
mov    %rcx,%rdx
cmp    $0x3a,%al
jne    12a0 <remove_upstream_inputs+0x120>
mov    %ecx,%eax
movb   $0x0,0x20(%rsp,%rax,1)
mov    %r14,%r15
xor    %r13d,%r13d
jmp    12e5 <remove_upstream_inputs+0x165>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r13
add    $0xc8,%r15
cmp    $0x64,%r13
je     1220 <remove_upstream_inputs+0xa0>
mov    %r13,%r12
shl    $0x8,%r12
add    %rbx,%r12
xor    %r14d,%r14d
jmp    130a <remove_upstream_inputs+0x18a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r14
cmp    $0x32,%r14
je     12d0 <remove_upstream_inputs+0x150>
mov    %r12,%rdi
mov    %rbp,%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    1300 <remove_upstream_inputs+0x180>
cmpl   $0x0,(%r15,%r14,4)
je     1300 <remove_upstream_inputs+0x180>
movl   $0x1,(%r15,%r14,4)
jmp    1300 <remove_upstream_inputs+0x180>
mov    %r15,%rdi
call   1030 <fclose@plt>
add    $0x528,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [21 x i8] c"file open error, %s\0A\00"
@.str.2 = [3 x i8] c"->\00"
define void @remove_upstream_inputs(i8* %0, [256 x i8]* %1, i8* %2, [50 x i32]* %3) {
%5 = alloca i8*
%6 = alloca [256 x i8]*
%7 = alloca i8*
%8 = alloca [50 x i32]*
%9 = alloca i32
%10 = alloca i32
%11 = alloca [1024 x i8]
%12 = alloca [256 x i8]
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i32*
store i8* %0, i8** %5
store [256 x i8]* %1, [256 x i8]** %6
store i8* %2, i8** %7
store [50 x i32]* %3, [50 x i32]** %8
%16 = load i8*, i8** %7
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %15
%18 = load i32*, i32** %15
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %25
20: ; preds = %4
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %7
%23 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = call i32 @fflush(i32* null)
br label %25
25: ; preds = %20, %4
br label %26
26: ; preds = %109, %25
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%28 = load i32*, i32** %15
%29 = call i64 @fgets(i8* %27, i32 1024, i32* %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %110
31: ; preds = %26
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%33 = call i8* @strstr(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %33, i8** %13
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %109
35: ; preds = %31
%36 = load i8*, i8** %13
%37 = load i8*, i8** %5
%38 = call i8* @strstr(i8* %36, i8* %37)
store i8* %38, i8** %14
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %108
40: ; preds = %35
store i32 0, i32* %9
br label %41
41: ; preds = %48, %40
%42 = load i32, i32* %9
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp ne i32 %46, 58
br i1 %47, label %48, label %57
48: ; preds = %41
%49 = load i32, i32* %9
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = load i32, i32* %9
%54 = add nsw i32 %53, 1
store i32 %54, i32* %9
%55 = sext i32 %53 to i64
%56 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 %55
store i8 %52, i8* %56
br label %41
57: ; preds = %41
%58 = load i32, i32* %9
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 %59
store i8 0, i8* %60
store i32 0, i32* %9
br label %61
61: ; preds = %100, %57
%62 = load i32, i32* %9
%63 = icmp slt i32 %62, 100
br i1 %63, label %64, label %103
64: ; preds = %61
store i32 0, i32* %10
br label %65
65: ; preds = %96, %64
%66 = load i32, i32* %10
%67 = icmp slt i32 %66, 50
br i1 %67, label %68, label %99
68: ; preds = %65
%69 = load [256 x i8]*, [256 x i8]** %6
%70 = load i32, i32* %9
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [256 x i8], [256 x i8]* %69, i64 %71
%73 = getelementptr inbounds [256 x i8], [256 x i8]* %72, i64 0, i64 0
%74 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%75 = call i32 @strcmp(i8* %73, i8* %74)
%76 = icmp ne i32 %75, 0
br i1 %76, label %95, label %77
77: ; preds = %68
%78 = load [50 x i32]*, [50 x i32]** %8
%79 = load i32, i32* %9
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [50 x i32], [50 x i32]* %78, i64 %80
%82 = load i32, i32* %10
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [50 x i32], [50 x i32]* %81, i64 0, i64 %83
%85 = load i32, i32* %84
%86 = icmp ne i32 %85, 0
br i1 %86, label %87, label %95
87: ; preds = %77
%88 = load [50 x i32]*, [50 x i32]** %8
%89 = load i32, i32* %9
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [50 x i32], [50 x i32]* %88, i64 %90
%92 = load i32, i32* %10
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds [50 x i32], [50 x i32]* %91, i64 0, i64 %93
store i32 1, i32* %94
br label %95
95: ; preds = %87, %77, %68
br label %96
96: ; preds = %95
%97 = load i32, i32* %10
%98 = add nsw i32 %97, 1
store i32 %98, i32* %10
br label %65
99: ; preds = %65
br label %100
100: ; preds = %99
%101 = load i32, i32* %9
%102 = add nsw i32 %101, 1
store i32 %102, i32* %9
br label %61
103: ; preds = %61
%104 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%105 = load [256 x i8]*, [256 x i8]** %6
%106 = load i8*, i8** %7
%107 = load [50 x i32]*, [50 x i32]** %8
br label %108
108: ; preds = %103, %35
br label %109
109: ; preds = %108, %31
br label %26
110: ; preds = %26
%111 = load i32*, i32** %15
%112 = call i32 @fclose(i32* %111)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [21 x i8] c"file open error, %s\0A\00"
@.str.2 = [3 x i8] c"->\00"
define void @remove_upstream_inputs(i8* nocapture %0, [256 x i8]* nocapture %1, i8* %2, [50 x i32]* nocapture %3) {
%5 = alloca [1024 x i8]
%6 = alloca [256 x i8]
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%9 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %15
11: ; preds = %4
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%14 = tail call i32 @fflush(i32* null)
br label %15
15: ; preds = %11, %4
%16 = call i64 @fgets(i8* %7, i32 1024, i32* %9)
%17 = icmp eq i64 %16, 0
br i1 %17, label %61, label %18
18: ; preds = %15, %58
%19 = call i8* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i8* %19, null
br i1 %20, label %58, label %21
21: ; preds = %18
%22 = call i8* @strstr(i8* %19, i8* dereferenceable(1) %0)
%23 = icmp eq i8* %22, null
br i1 %23, label %58, label %24
24: ; preds = %21
%25 = load i8, i8* %7
%26 = icmp eq i8 %25, 58
br i1 %26, label %35, label %27
27: ; preds = %24, %27
%28 = phi i64 [ %30, %27 ], [ 0, %24 ]
%29 = phi i8 [ %33, %27 ], [ %25, %24 ]
%30 = add nuw nsw i64 %28, 1
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %28
store i8 %29, i8* %31
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %30
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 58
br i1 %34, label %35, label %27
35: ; preds = %27, %24
%36 = phi i64 [ 0, %24 ], [ %30, %27 ]
%37 = and i64 %36, 4294967295
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %37
store i8 0, i8* %38
br label %39
39: ; preds = %35, %54
%40 = phi i64 [ 0, %35 ], [ %55, %54 ]
%41 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 %40, i64 0
br label %42
42: ; preds = %39, %51
%43 = phi i64 [ 0, %39 ], [ %52, %51 ]
%44 = call i32 @strcmp(i8* dereferenceable(1) %41, i8* %8)
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %51
46: ; preds = %42
%47 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 %40, i64 %43
%48 = load i32, i32* %47
%49 = icmp eq i32 %48, 0
br i1 %49, label %51, label %50
50: ; preds = %46
store i32 1, i32* %47
br label %51
51: ; preds = %42, %46, %50
%52 = add nuw nsw i64 %43, 1
%53 = icmp eq i64 %52, 50
br i1 %53, label %54, label %42
54: ; preds = %51
%55 = add nuw nsw i64 %40, 1
%56 = icmp eq i64 %55, 100
br i1 %56, label %57, label %39
57: ; preds = %54
br label %58
58: ; preds = %21, %57, %18
%59 = call i64 @fgets(i8* %7, i32 1024, i32* %9)
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %18
61: ; preds = %58, %15
%62 = call i32 @fclose(i32* %9)
ret void
}