#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 */

/* Variables and functions */
int addValue(char *, char const *, char const *, char *, int);
int /*<<< orphan*/ formatResultBuffer(char *, char *);
int readConfigurationFileBuffer(char *);
int writeConfigurationFileBuffer(char *);
int setConfigurationValue(const char *targetKey, const char *value) {
  char configurationFileBuffer[2048];
  char resultConfigurationBuffer[2048];
  char formatedResultConfigurationBuffer[2048];
  if (readConfigurationFileBuffer(configurationFileBuffer) == 1)
    return 1;
  if (addValue(configurationFileBuffer, targetKey, value,
               resultConfigurationBuffer, 2048) == 1)
    return 1;
  formatResultBuffer(resultConfigurationBuffer,
                     formatedResultConfigurationBuffer);
  if (writeConfigurationFileBuffer(formatedResultConfigurationBuffer) == 1)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<setConfigurationValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1820,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x820(%rbp),%rdi
call   1040 <readConfigurationFileBuffer@plt>
cmp    $0x1,%eax
jne    1174 <setConfigurationValue+0x34>
movl   $0x1,-0x4(%rbp)
jmp    11e5 <setConfigurationValue+0xa5>
lea    -0x820(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x1020(%rbp),%rcx
mov    $0x800,%r8d
call   1030 <addValue@plt>
cmp    $0x1,%eax
jne    11aa <setConfigurationValue+0x6a>
movl   $0x1,-0x4(%rbp)
jmp    11e5 <setConfigurationValue+0xa5>
lea    -0x1020(%rbp),%rdi
lea    -0x1820(%rbp),%rsi
call   1060 <formatResultBuffer@plt>
lea    -0x1820(%rbp),%rdi
call   1050 <writeConfigurationFileBuffer@plt>
cmp    $0x1,%eax
jne    11de <setConfigurationValue+0x9e>
movl   $0x1,-0x4(%rbp)
jmp    11e5 <setConfigurationValue+0xa5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setConfigurationValue>:
push   %r15
push   %r14
push   %rbx
sub    $0x1800,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x800(%rsp),%rdi
call   1040 <readConfigurationFileBuffer@plt>
mov    $0x1,%ebx
cmp    $0x1,%eax
je     11ad <setConfigurationValue+0x6d>
lea    0x800(%rsp),%rdi
mov    %rsp,%rcx
mov    %r15,%rsi
mov    %r14,%rdx
mov    $0x800,%r8d
call   1030 <addValue@plt>
cmp    $0x1,%eax
je     11ad <setConfigurationValue+0x6d>
mov    %rsp,%rdi
lea    0x1000(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <formatResultBuffer@plt>
mov    %rbx,%rdi
call   1050 <writeConfigurationFileBuffer@plt>
xor    %ebx,%ebx
cmp    $0x1,%eax
sete   %bl
mov    %ebx,%eax
add    $0x1800,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @setConfigurationValue(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [2048 x i8]
%7 = alloca [2048 x i8]
%8 = alloca [2048 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%10 = call i32 @readConfigurationFileBuffer(i8* %9)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 1, i32* %3
br label %30
13: ; preds = %2
%14 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%15 = load i8*, i8** %4
%16 = load i8*, i8** %5
%17 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%18 = call i32 @addValue(i8* %14, i8* %15, i8* %16, i8* %17, i32 2048)
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %21
20: ; preds = %13
store i32 1, i32* %3
br label %30
21: ; preds = %13
%22 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%23 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%24 = call i32 @formatResultBuffer(i8* %22, i8* %23)
%25 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%26 = call i32 @writeConfigurationFileBuffer(i8* %25)
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %29
28: ; preds = %21
store i32 1, i32* %3
br label %30
29: ; preds = %21
store i32 0, i32* %3
br label %30
30: ; preds = %29, %28, %20, %12
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
define i32 @setConfigurationValue(i8* %0, i8* %1) {
%3 = alloca [2048 x i8]
%4 = alloca [2048 x i8]
%5 = alloca [2048 x i8]
%6 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%9 = call i32 @readConfigurationFileBuffer(i8* %6)
%10 = icmp eq i32 %9, 1
br i1 %10, label %19, label %11
11: ; preds = %2
%12 = call i32 @addValue(i8* %6, i8* %0, i8* %1, i8* %7, i32 2048)
%13 = icmp eq i32 %12, 1
br i1 %13, label %19, label %14
14: ; preds = %11
%15 = call i32 @formatResultBuffer(i8* %7, i8* %8)
%16 = call i32 @writeConfigurationFileBuffer(i8* %8)
%17 = icmp eq i32 %16, 1
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %14, %11, %2
%20 = phi i32 [ 1, %2 ], [ 1, %11 ], [ %18, %14 ]
ret i32 %20
}