#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) {
  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)
cmpq   $0x0,-0x18(%rbp)
jne    1158 <changeStringSetting+0x28>
movq   $0x0,-0x20(%rbp)
jmp    1187 <changeStringSetting+0x57>
mov    -0x18(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1182 <changeStringSetting+0x52>
mov    $0x0,%al
call   1040 <logMallocError@plt>
movl   $0x0,-0x4(%rbp)
jmp    11b3 <changeStringSetting+0x83>
jmp    1187 <changeStringSetting+0x57>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     11a1 <changeStringSetting+0x71>
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   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rsi,%rsi
je     1157 <changeStringSetting+0x27>
mov    %rsi,%rdi
call   1050 <strdup@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1159 <changeStringSetting+0x29>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <logMallocError@plt>
jmp    116e <changeStringSetting+0x3e>
xor    %ebx,%ebx
mov    (%r14),%rdi
test   %rdi,%rdi
je     1166 <changeStringSetting+0x36>
call   1030 <free@plt>
mov    %rbx,(%r14)
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
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 = icmp ne i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %2
store i8* null, i8** %6
br label %17
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = call i8* @strdup(i8* %11)
store i8* %12, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = call i32 (...) @logMallocError()
store i32 0, i32* %3
br label %28
16: ; preds = %10
br label %17
17: ; preds = %16, %9
%18 = load i8**, i8*** %4
%19 = load i8*, i8** %18
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i8**, i8*** %4
%23 = load i8*, i8** %22
%24 = call i32 @free(i8* %23)
br label %25
25: ; preds = %21, %17
%26 = load i8*, i8** %6
%27 = load i8**, i8*** %4
store i8* %26, i8** %27
store i32 1, i32* %3
br label %28
28: ; preds = %25, %14
%29 = load i32, i32* %3
ret i32 %29
}

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