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


x86 assembly (clang, -O0):
<Str_update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <Str_exists@plt>
cmp    $0x0,%rax
je     1351 <Str_update+0x1d1>
lea    0xe53(%rip),%rdi
lea    0xe5f(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x438(%rbp)
lea    0xe47(%rip),%rdi
lea    0xe47(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x440(%rbp)
mov    -0x438(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11fb <Str_update+0x7b>
jmp    1273 <Str_update+0xf3>
mov    -0x438(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x430(%rbp),%rcx
lea    0xe04(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1250 <Str_update+0xd0>
mov    -0x440(%rbp),%rdi
lea    -0x40(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xdd2(%rip),%rsi
call   1070 <fprintf@plt>
jmp    126e <Str_update+0xee>
mov    -0x440(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x430(%rbp),%rcx
lea    0xdaf(%rip),%rsi
call   1070 <fprintf@plt>
jmp    11da <Str_update+0x5a>
mov    -0x438(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x440(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xd6e(%rip),%rdi
lea    0xd7c(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x438(%rbp)
lea    0xd62(%rip),%rdi
lea    0xd60(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x440(%rbp)
mov    -0x440(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12e0 <Str_update+0x160>
jmp    1321 <Str_update+0x1a1>
mov    -0x440(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x430(%rbp),%rcx
lea    0xd1f(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x438(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x430(%rbp),%rcx
lea    0xd01(%rip),%rsi
call   1070 <fprintf@plt>
jmp    12bf <Str_update+0x13f>
mov    -0x438(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x440(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xcce(%rip),%rdi
call   1030 <remove@plt>
movl   $0x1,-0x4(%rbp)
jmp    1358 <Str_update+0x1d8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Str_update>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rsi,0x8(%rsp)
mov    %rdi,%r15
call   1090 <Str_exists@plt>
test   %rax,%rax
je     1291 <Str_update+0x111>
lea    0xe52(%rip),%rdi
lea    0xe5e(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbx
lea    0xe4a(%rip),%rdi
lea    0xe4a(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     12a5 <Str_update+0x125>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
lea    0xe06(%rip),%rdi
lea    0xe14(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r14
lea    0xdfe(%rip),%rdi
lea    0xdfc(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    126e <Str_update+0xee>
lea    0xde6(%rip),%r15
lea    0x10(%rsp),%r12
lea    0x30(%rsp),%rbx
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
call   1050 <fscanf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
call   1070 <fprintf@plt>
mov    %rbp,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     1240 <Str_update+0xc0>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
lea    0xd89(%rip),%rdi
call   1030 <remove@plt>
mov    $0x1,%eax
jmp    1293 <Str_update+0x113>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd6c(%rip),%r13
lea    0x10(%rsp),%rbp
lea    0x30(%rsp),%r14
jmp    12d8 <Str_update+0x158>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rcx
call   1070 <fprintf@plt>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    11e3 <Str_update+0x63>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %r14,%rcx
call   1050 <fscanf@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1060 <strcmp@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
test   %rax,%rax
jne    12c0 <Str_update+0x140>
mov    0x8(%rsp),%rcx
jmp    12c3 <Str_update+0x143>

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

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"wppstr\00"
@.str.3 = [3 x i8] c"w+\00"
@.str.4 = [7 x i8] c"%s %s\0A\00"
define i32 @Str_update(i8* %0, i8* %1) {
%3 = alloca [30 x i8]
%4 = alloca [1000 x i8]
%5 = tail call i64 @Str_exists(i8* %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %41, label %7
7: ; preds = %2
%8 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%10 = 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))
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @feof(i32* %10)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %25
14: ; preds = %7, %22
%15 = call i32 @fscanf(i32* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %8, i8* %9)
%16 = call i64 @strcmp(i8* %0, i8* %8)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %8, i8* %1)
br label %22
20: ; preds = %14
%21 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %8, i8* %9)
br label %22
22: ; preds = %20, %18
%23 = call i32 @feof(i32* %10)
%24 = icmp eq i32 %23, 0
br i1 %24, label %14, label %25
25: ; preds = %22, %7
%26 = call i32 @fclose(i32* %10)
%27 = call i32 @fclose(i32* %11)
%28 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%29 = call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%30 = call i32 @feof(i32* %29)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %25, %32
%33 = call i32 @fscanf(i32* %29, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %8, i8* %9)
%34 = call i32 @fprintf(i32* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %8, i8* %9)
%35 = call i32 @feof(i32* %29)
%36 = icmp eq i32 %35, 0
br i1 %36, label %32, label %37
37: ; preds = %32, %25
%38 = call i32 @fclose(i32* %28)
%39 = call i32 @fclose(i32* %29)
%40 = call i32 @remove(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %41
41: ; preds = %2, %37
%42 = phi i32 [ 1, %37 ], [ 0, %2 ]
ret i32 %42
}