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


x86 assembly (clang, -O0):
<Var_update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
mov    %esi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <Var_exists@plt>
cmp    $0x0,%rax
je     1363 <Var_update+0x1e3>
lea    0xe52(%rip),%rdi
lea    0xe56(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    0xe48(%rip),%rdi
lea    0xe45(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11fa <Var_update+0x7a>
cmpq   $0x0,-0x28(%rbp)
jne    1206 <Var_update+0x86>
movl   $0x0,-0x4(%rbp)
jmp    136a <Var_update+0x1ea>
jmp    120b <Var_update+0x8b>
mov    -0x20(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1229 <Var_update+0xa9>
jmp    129e <Var_update+0x11e>
mov    -0x20(%rbp),%rdi
lea    -0x50(%rbp),%rdx
lea    0xddc(%rip),%rsi
lea    -0x30(%rbp),%rcx
lea    -0x2c(%rbp),%r8
call   1050 <fscanf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    127d <Var_update+0xfd>
mov    -0x28(%rbp),%rdi
lea    -0x50(%rbp),%rdx
mov    -0x18(%rbp),%ecx
movss  -0x14(%rbp),%xmm0
lea    0xda1(%rip),%rsi
call   1070 <fprintf@plt>
jmp    1299 <Var_update+0x119>
mov    -0x28(%rbp),%rdi
lea    -0x50(%rbp),%rdx
mov    -0x30(%rbp),%ecx
movss  -0x2c(%rbp),%xmm0
lea    0xd80(%rip),%rsi
call   1070 <fprintf@plt>
jmp    120b <Var_update+0x8b>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xd49(%rip),%rdi
lea    0xd53(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    0xd3f(%rip),%rdi
lea    0xd36(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12fc <Var_update+0x17c>
jmp    1339 <Var_update+0x1b9>
mov    -0x28(%rbp),%rdi
lea    -0x50(%rbp),%rdx
lea    0xd09(%rip),%rsi
lea    -0x30(%rbp),%rcx
lea    -0x2c(%rbp),%r8
call   1050 <fscanf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x50(%rbp),%rdx
mov    -0x30(%rbp),%ecx
movss  -0x2c(%rbp),%xmm0
lea    0xce5(%rip),%rsi
call   1070 <fprintf@plt>
jmp    12de <Var_update+0x15e>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xcbb(%rip),%rdi
call   1030 <remove@plt>
movl   $0x1,-0x4(%rbp)
jmp    136a <Var_update+0x1ea>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Var_update>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %esi,0xc(%rsp)
movss  %xmm0,0x8(%rsp)
mov    %rdi,%r15
call   1090 <Var_exists@plt>
test   %rax,%rax
je     12ca <Var_update+0x14a>
lea    0xe50(%rip),%rdi
lea    0xe54(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbp
lea    0xe47(%rip),%rdi
lea    0xe44(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r12
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
xor    %eax,%eax
test   %rbp,%rbp
je     12cc <Var_update+0x14c>
test   %r12,%r12
je     12cc <Var_update+0x14c>
mov    %rbp,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     12db <Var_update+0x15b>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
lea    0xde1(%rip),%rdi
lea    0xdeb(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r14
lea    0xdd8(%rip),%rdi
lea    0xdcf(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    12a7 <Var_update+0x127>
lea    0xdbd(%rip),%r15
lea    0x10(%rsp),%rbx
mov    %rsp,%r12
lea    0x4(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1050 <fscanf@plt>
mov    (%rsp),%ecx
movss  0x4(%rsp),%xmm0
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1070 <fprintf@plt>
mov    %rbp,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     1270 <Var_update+0xf0>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
lea    0xd4f(%rip),%rdi
call   1030 <remove@plt>
mov    $0x1,%eax
jmp    12cc <Var_update+0x14c>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd32(%rip),%r13
lea    0x10(%rsp),%rbx
lea    0x4(%rsp),%r14
jmp    1317 <Var_update+0x197>
xchg   %ax,%ax
mov    (%rsp),%ecx
movss  0x4(%rsp),%xmm0
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1070 <fprintf@plt>
mov    %rbp,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    1208 <Var_update+0x88>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %rsp,%rcx
mov    %r14,%r8
call   1050 <fscanf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    12f0 <Var_update+0x170>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    0xc(%rsp),%ecx
movss  0x8(%rsp),%xmm0
jmp    1302 <Var_update+0x182>

LLVM IR (-O0):
@.str = [11 x i8] c"values.tmp\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"wpp\00"
@.str.3 = [3 x i8] c"w+\00"
@.str.4 = [10 x i8] c"%s %d %f\0A\00"
define i32 @Var_update(i8* %0, float %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca float
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca float
%11 = alloca i32
%12 = alloca [30 x i8]
store i8* %0, i8** %5
store float %1, float* %6
store i32 %2, i32* %7
%13 = load i8*, i8** %5
%14 = call i64 @Var_exists(i8* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %79
16: ; preds = %3
%17 = 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* %17, i32** %8
%18 = call i32* @fopen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %18, i32** %9
store float 0.000000e+00, float* %10
store i32 0, i32* %11
%19 = load i32*, i32** %8
%20 = icmp ne i32* %19, null
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = load i32*, i32** %9
%23 = icmp ne i32* %22, null
br i1 %23, label %25, label %24
24: ; preds = %21, %16
store i32 0, i32* %4
br label %80
25: ; preds = %21
br label %26
26: ; preds = %51, %25
%27 = load i32*, i32** %8
%28 = call i32 @feof(i32* %27)
%29 = icmp ne i32 %28, 0
%30 = xor i1 %29, true
br i1 %30, label %31, label %52
31: ; preds = %26
%32 = load i32*, i32** %8
%33 = getelementptr inbounds [30 x i8], [30 x i8]* %12, i64 0, i64 0
%34 = call i32 @fscanf(i32* %32, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %33, i32* %11, float* %10)
%35 = getelementptr inbounds [30 x i8], [30 x i8]* %12, i64 0, i64 0
%36 = load i8*, i8** %5
%37 = call i64 @strcmp(i8* %35, i8* %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %45
39: ; preds = %31
%40 = load i32*, i32** %9
%41 = getelementptr inbounds [30 x i8], [30 x i8]* %12, i64 0, i64 0
%42 = load i32, i32* %7
%43 = load float, float* %6
%44 = call i32 @fprintf(i32* %40, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %41, i32 %42, float %43)
br label %51
45: ; preds = %31
%46 = load i32*, i32** %9
%47 = getelementptr inbounds [30 x i8], [30 x i8]* %12, i64 0, i64 0
%48 = load i32, i32* %11
%49 = load float, float* %10
%50 = call i32 @fprintf(i32* %46, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %47, i32 %48, float %49)
br label %51
51: ; preds = %45, %39
br label %26
52: ; preds = %26
%53 = load i32*, i32** %8
%54 = call i32 @fclose(i32* %53)
%55 = load i32*, i32** %9
%56 = call i32 @fclose(i32* %55)
%57 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %57, i32** %8
%58 = call i32* @fopen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %58, i32** %9
br label %59
59: ; preds = %64, %52
%60 = load i32*, i32** %9
%61 = call i32 @feof(i32* %60)
%62 = icmp ne i32 %61, 0
%63 = xor i1 %62, true
br i1 %63, label %64, label %73
64: ; preds = %59
%65 = load i32*, i32** %9
%66 = getelementptr inbounds [30 x i8], [30 x i8]* %12, i64 0, i64 0
%67 = call i32 @fscanf(i32* %65, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %66, i32* %11, float* %10)
%68 = load i32*, i32** %8
%69 = getelementptr inbounds [30 x i8], [30 x i8]* %12, i64 0, i64 0
%70 = load i32, i32* %11
%71 = load float, float* %10
%72 = call i32 @fprintf(i32* %68, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %69, i32 %70, float %71)
br label %59
73: ; preds = %59
%74 = load i32*, i32** %8
%75 = call i32 @fclose(i32* %74)
%76 = load i32*, i32** %9
%77 = call i32 @fclose(i32* %76)
%78 = call i32 @remove(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %4
br label %80
79: ; preds = %3
store i32 0, i32* %4
br label %80
80: ; preds = %79, %73, %24
%81 = load i32, i32* %4
ret i32 %81
}

LLVM IR (-O2):
@.str = [11 x i8] c"values.tmp\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"wpp\00"
@.str.3 = [3 x i8] c"w+\00"
@.str.4 = [10 x i8] c"%s %d %f\0A\00"
define i32 @Var_update(i8* %0, float %1, i32 %2) {
%4 = alloca float
%5 = alloca i32
%6 = alloca [30 x i8]
%7 = tail call i64 @Var_exists(i8* %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %54, label %9
9: ; preds = %3
%10 = 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))
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%12 = bitcast float* %4 to i8*
store float 0.000000e+00, float* %4
%13 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%14 = getelementptr inbounds [30 x i8], [30 x i8]* %6, i64 0, i64 0
%15 = icmp ne i32* %10, null
%16 = icmp ne i32* %11, null
%17 = and i1 %15, %16
br i1 %17, label %18, label %52
18: ; preds = %9
%19 = call i32 @feof(i32* %10)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %34
21: ; preds = %18, %31
%22 = call i32 @fscanf(i32* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %14, i32* %5, float* %4)
%23 = call i64 @strcmp(i8* %14, i8* %0)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %14, i32 %2, float %1)
br label %31
27: ; preds = %21
%28 = load i32, i32* %5
%29 = load float, float* %4
%30 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %14, i32 %28, float %29)
br label %31
31: ; preds = %27, %25
%32 = call i32 @feof(i32* %10)
%33 = icmp eq i32 %32, 0
br i1 %33, label %21, label %34
34: ; preds = %31, %18
%35 = call i32 @fclose(i32* %10)
%36 = call i32 @fclose(i32* %11)
%37 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%38 = call i32* @fopen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%39 = call i32 @feof(i32* %38)
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %48
41: ; preds = %34, %41
%42 = call i32 @fscanf(i32* %38, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %14, i32* %5, float* %4)
%43 = load i32, i32* %5
%44 = load float, float* %4
%45 = call i32 @fprintf(i32* %37, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %14, i32 %43, float %44)
%46 = call i32 @feof(i32* %38)
%47 = icmp eq i32 %46, 0
br i1 %47, label %41, label %48
48: ; preds = %41, %34
%49 = call i32 @fclose(i32* %37)
%50 = call i32 @fclose(i32* %38)
%51 = call i32 @remove(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %52
52: ; preds = %9, %48
%53 = phi i32 [ 1, %48 ], [ 0, %9 ]
br label %54
54: ; preds = %3, %52
%55 = phi i32 [ %53, %52 ], [ 0, %3 ]
ret i32 %55
}