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


x86 assembly (clang, -O0):
<Var_exists>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xe76(%rip),%rdi
lea    0xe7a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b1 <Var_exists+0x51>
movl   $0x0,-0x4(%rbp)
jmp    122c <Var_exists+0xcc>
mov    -0x18(%rbp),%rdi
call   1040 <rewind@plt>
mov    -0x18(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11d8 <Var_exists+0x78>
jmp    121c <Var_exists+0xbc>
mov    -0x18(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    0xe26(%rip),%rsi
lea    -0x20(%rbp),%rcx
lea    -0x1c(%rbp),%r8
call   1050 <fscanf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1217 <Var_exists+0xb7>
movl   $0x1,-0x4(%rbp)
jmp    122c <Var_exists+0xcc>
jmp    11ba <Var_exists+0x5a>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Var_exists>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%r12
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xe78(%rip),%rdi
lea    0xe7c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbp
xor    %eax,%eax
test   %rbp,%rbp
je     1201 <Var_exists+0xa1>
mov    %rbp,%rdi
call   1040 <rewind@plt>
lea    0xe60(%rip),%r15
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%r13
lea    0xc(%rsp),%r14
nopl   0x0(%rax)
mov    %rbp,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    11f7 <Var_exists+0x97>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r13,%rcx
mov    %r14,%r8
call   1050 <fscanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11c0 <Var_exists+0x60>
mov    $0x1,%eax
jmp    1201 <Var_exists+0xa1>
mov    %rbp,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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