#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 */
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int cfgfile_string(char *option, char *value, char *name, char *location,
                   int maxsz) {
  if (strcmp(option, name) != 0)
    return 0;
  strncpy(location, value, maxsz - 1);
  location[maxsz - 1] = '\0';
  return 1;
}


x86 assembly (clang, -O0):
<cfgfile_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     115f <cfgfile_string+0x3f>
movl   $0x0,-0x4(%rbp)
jmp    118a <cfgfile_string+0x6a>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x2c(%rbp),%edx
sub    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cfgfile_string>:
push   %rbp
push   %r14
push   %rbx
mov    %r8d,%ebp
mov    %rcx,%rbx
mov    %rsi,%r14
mov    %rdx,%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    115b <cfgfile_string+0x3b>
movslq %ebp,%rbp
lea    -0x1(%rbp),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strncpy@plt>
movb   $0x0,-0x1(%rbx,%rbp,1)
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @cfgfile_string(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i32 %4, i32* %11
%12 = load i8*, i8** %7
%13 = load i8*, i8** %9
%14 = call i64 @strcmp(i8* %12, i8* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %5
store i32 0, i32* %6
br label %28
17: ; preds = %5
%18 = load i8*, i8** %10
%19 = load i8*, i8** %8
%20 = load i32, i32* %11
%21 = sub nsw i32 %20, 1
%22 = call i32 @strncpy(i8* %18, i8* %19, i32 %21)
%23 = load i8*, i8** %10
%24 = load i32, i32* %11
%25 = sub nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %23, i64 %26
store i8 0, i8* %27
store i32 1, i32* %6
br label %28
28: ; preds = %17, %16
%29 = load i32, i32* %6
ret i32 %29
}

LLVM IR (-O2):
define i32 @cfgfile_string(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = tail call i64 @strcmp(i8* %0, i8* %2)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %5
%9 = add nsw i32 %4, -1
%10 = tail call i32 @strncpy(i8* %3, i8* %1, i32 %9)
%11 = sext i32 %9 to i64
%12 = getelementptr inbounds i8, i8* %3, i64 %11
store i8 0, i8* %12
br label %13
13: ; preds = %5, %8
%14 = phi i32 [ 1, %8 ], [ 0, %5 ]
ret i32 %14
}