#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 /*<<< orphan*/ free(char *);
int /*<<< orphan*/ logMallocError();
char *strdup(char const *);
int changeStringSetting(char **setting, const char *value) {
  if (value == *setting)
    return 1;
  char *string;
  if (!value) {
    string = NULL;
  } else if (!(string = strdup(value))) {
    logMallocError();
    return 0;
  }
  if (*setting)
    free(*setting);
  *setting = string;
  return 1;
}


x86 assembly (clang, -O0):
<changeStringSetting>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
jne    115d <changeStringSetting+0x2d>
movl   $0x1,-0x4(%rbp)
jmp    11d0 <changeStringSetting+0xa0>
cmpq   $0x0,-0x18(%rbp)
jne    1175 <changeStringSetting+0x45>
movq   $0x0,-0x20(%rbp)
jmp    11a4 <changeStringSetting+0x74>
mov    -0x18(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    119f <changeStringSetting+0x6f>
mov    $0x0,%al
call   1040 <logMallocError@plt>
movl   $0x0,-0x4(%rbp)
jmp    11d0 <changeStringSetting+0xa0>
jmp    11a4 <changeStringSetting+0x74>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     11be <changeStringSetting+0x8e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<changeStringSetting>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%rbp
mov    $0x1,%r14d
cmp    %rsi,%rbp
je     117c <changeStringSetting+0x4c>
mov    %rdi,%rbx
test   %rsi,%rsi
je     1169 <changeStringSetting+0x39>
mov    %rsi,%rdi
call   1050 <strdup@plt>
mov    %rax,%r15
test   %rax,%rax
jne    116c <changeStringSetting+0x3c>
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <logMallocError@plt>
jmp    117c <changeStringSetting+0x4c>
xor    %r15d,%r15d
test   %rbp,%rbp
je     1179 <changeStringSetting+0x49>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r15,(%rbx)
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @changeStringSetting(i8** %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
store i8** %0, i8*** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = load i8**, i8*** %4
%9 = load i8*, i8** %8
%10 = icmp eq i8* %7, %9
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 1, i32* %3
br label %34
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = icmp ne i8* %13, null
br i1 %14, label %16, label %15
15: ; preds = %12
store i8* null, i8** %6
br label %23
16: ; preds = %12
%17 = load i8*, i8** %5
%18 = call i8* @strdup(i8* %17)
store i8* %18, i8** %6
%19 = icmp ne i8* %18, null
br i1 %19, label %22, label %20
20: ; preds = %16
%21 = call i32 (...) @logMallocError()
store i32 0, i32* %3
br label %34
22: ; preds = %16
br label %23
23: ; preds = %22, %15
%24 = load i8**, i8*** %4
%25 = load i8*, i8** %24
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %31
27: ; preds = %23
%28 = load i8**, i8*** %4
%29 = load i8*, i8** %28
%30 = call i32 @free(i8* %29)
br label %31
31: ; preds = %27, %23
%32 = load i8*, i8** %6
%33 = load i8**, i8*** %4
store i8* %32, i8** %33
store i32 1, i32* %3
br label %34
34: ; preds = %31, %20, %11
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
define i32 @changeStringSetting(i8** nocapture %0, i8* %1) {
%3 = load i8*, i8** %0
%4 = icmp eq i8* %3, %1
br i1 %4, label %18, label %5
5: ; preds = %2
%6 = icmp eq i8* %1, null
br i1 %6, label %12, label %7
7: ; preds = %5
%8 = tail call i8* @strdup(i8* %1)
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 (...) @logMallocError()
br label %18
12: ; preds = %5, %7
%13 = phi i8* [ %8, %7 ], [ null, %5 ]
%14 = icmp eq i8* %3, null
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = tail call i32 @free(i8* %3)
br label %17
17: ; preds = %15, %12
store i8* %13, i8** %0
br label %18
18: ; preds = %10, %17, %2
%19 = phi i32 [ 1, %2 ], [ 1, %17 ], [ 0, %10 ]
ret i32 %19
}