#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*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *, char *);
scalar_t__ strcmp(char const *, char *);
int Str_exists(const char *name1) {
  FILE *f = fopen("strvalues.tmp", "r");
  if (!f)
    return 0;
  char name[30];
  char value[1000];
  while (!feof(f)) {
    fscanf(f, "%s %s\n", name, value);
    if (strcmp(name1, name) == 0)
      return 1;
  }
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<Str_exists>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118d <Str_exists+0x3d>
movl   $0x0,-0x4(%rbp)
jmp    1203 <Str_exists+0xb3>
jmp    1192 <Str_exists+0x42>
mov    -0x18(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11b0 <Str_exists+0x60>
jmp    11f3 <Str_exists+0xa3>
mov    -0x18(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x430(%rbp),%rcx
lea    0xe4a(%rip),%rsi
call   1040 <fscanf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11ee <Str_exists+0x9e>
movl   $0x1,-0x4(%rbp)
jmp    1203 <Str_exists+0xb3>
jmp    1192 <Str_exists+0x42>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Str_exists>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x410,%rsp
mov    %rdi,%r14
lea    0xe96(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11cc <Str_exists+0x7c>
mov    %rax,%rbx
lea    0xe8b(%rip),%r15
mov    %rsp,%r12
lea    0x20(%rsp),%r13
nopl   (%rax)
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    11c4 <Str_exists+0x74>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
call   1040 <fscanf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1190 <Str_exists+0x40>
mov    $0x1,%eax
jmp    11ce <Str_exists+0x7e>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [14 x i8] c"strvalues.tmp\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [7 x i8] c"%s %s\0A\00"
define i32 @Str_exists(i8* %0) {
%2 = alloca [30 x i8]
%3 = alloca [1000 x i8]
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %20, label %6
6: ; preds = %1
%7 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
br label %9
9: ; preds = %12, %6
%10 = call i32 @feof(i32* %4)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %7, i8* %8)
%14 = call i64 @strcmp(i8* %0, i8* %7)
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %9
16: ; preds = %9
%17 = call i32 @fclose(i32* %4)
br label %18
18: ; preds = %12, %16
%19 = phi i32 [ 0, %16 ], [ 1, %12 ]
br label %20
20: ; preds = %1, %18
%21 = phi i32 [ %19, %18 ], [ 0, %1 ]
ret i32 %21
}