#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*/ O_WRONLY;
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
int strlen(char *);
int write(int, char *, int);
int set_char_option(char *conf_path, char *name, char *str) {
  int fd;
  int len, cnt;
  char fname[512];
  ;
  snprintf(fname, 512, "%s/%s", conf_path, name);
  if ((fd = open(fname, O_WRONLY)) < 0) {
    ;
    return -1;
  }
  len = strlen(str) + 1;
  cnt = write(fd, str, len);
  ;
  close(fd);
  if (cnt != len)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<set_char_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x230(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    $0x200,%esi
lea    0xe7e(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x230(%rbp),%rdi
mov    0x2e43(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    11b4 <set_char_option+0x64>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fc <set_char_option+0xac>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%edx
call   1030 <write@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
je     11f5 <set_char_option+0xa5>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fc <set_char_option+0xac>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_char_option>:
push   %rbp
push   %r14
push   %rbx
sub    $0x200,%rsp
mov    %rdx,%r14
mov    %rsi,%r8
mov    %rdi,%rcx
lea    0xe95(%rip),%rdx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x200,%esi
call   1050 <snprintf@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   1070 <open@plt>
test   %eax,%eax
js     11c1 <set_char_option+0x71>
mov    %eax,%ebp
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
add    $0x1,%ebx
mov    %ebp,%edi
mov    %r14,%rsi
mov    %ebx,%edx
call   1030 <write@plt>
mov    %eax,%r14d
mov    %ebp,%edi
call   1060 <close@plt>
xor    %eax,%eax
cmp    %ebx,%r14d
setne  %al
neg    %eax
jmp    11c6 <set_char_option+0x76>
mov    $0xffffffff,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s/%s\00"
@O_WRONLY = global i32 0
define i32 @set_char_option(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [512 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%13 = load i8*, i8** %5
%14 = load i8*, i8** %6
%15 = call i32 @snprintf(i8* %12, i32 512, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %14)
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%17 = load i32, i32* @O_WRONLY
%18 = call i32 @open(i8* %16, i32 %17)
store i32 %18, i32* %8
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %3
store i32 -1, i32* %4
br label %36
21: ; preds = %3
%22 = load i8*, i8** %7
%23 = call i32 @strlen(i8* %22)
%24 = add nsw i32 %23, 1
store i32 %24, i32* %9
%25 = load i32, i32* %8
%26 = load i8*, i8** %7
%27 = load i32, i32* %9
%28 = call i32 @write(i32 %25, i8* %26, i32 %27)
store i32 %28, i32* %10
%29 = load i32, i32* %8
%30 = call i32 @close(i32 %29)
%31 = load i32, i32* %10
%32 = load i32, i32* %9
%33 = icmp ne i32 %31, %32
br i1 %33, label %34, label %35
34: ; preds = %21
store i32 -1, i32* %4
br label %36
35: ; preds = %21
store i32 0, i32* %4
br label %36
36: ; preds = %35, %34, %20
%37 = load i32, i32* %4
ret i32 %37
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s/%s\00"
@O_WRONLY = global i32 0
define i32 @set_char_option(i8* %0, i8* %1, i8* %2) {
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%6 = call i32 @snprintf(i8* %5, i32 512, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%7 = load i32, i32* @O_WRONLY
%8 = call i32 @open(i8* %5, i32 %7)
%9 = icmp slt i32 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %3
%11 = call i32 @strlen(i8* %2)
%12 = add nsw i32 %11, 1
%13 = call i32 @write(i32 %8, i8* %2, i32 %12)
%14 = call i32 @close(i32 %8)
%15 = icmp ne i32 %13, %12
%16 = sext i1 %15 to i32
br label %17
17: ; preds = %10, %3
%18 = phi i32 [ -1, %3 ], [ %16, %10 ]
ret i32 %18
}