#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 */
typedef int /*<<< orphan*/ uselogfile;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
void get_settings(char LogFilename[], short *uselog) {
  FILE *settings_file = NULL;
  char uselogfile[10];
  strcpy(LogFilename, "logfile.log");
  *uselog = 0;
  if ((settings_file = fopen("settings", "r")) == NULL) {
    return;
  }
  if (fgets(LogFilename, 256, settings_file) == NULL) {
    return;
  }
  LogFilename[strlen(LogFilename) - 1] = '\0';
  if (fgets(uselogfile, sizeof(uselogfile), settings_file) == NULL) {
    return;
  }
  if (strncmp(uselogfile, "true", strlen("true")) == 0) {
    *uselog = 1;
  } else {
    *uselog = 0;
  }
  fclose(settings_file);
}


x86 assembly (clang, -O0):
<get_settings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
movw   $0x0,(%rax)
lea    0xe74(%rip),%rdi
lea    0xe76(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11b7 <get_settings+0x57>
jmp    126a <get_settings+0x10a>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x100,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
jne    11d8 <get_settings+0x78>
jmp    126a <get_settings+0x10a>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
lea    -0x22(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xa,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
jne    121a <get_settings+0xba>
jmp    126a <get_settings+0x10a>
lea    -0x22(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xdee(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%edx
lea    0xddc(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1258 <get_settings+0xf8>
mov    -0x10(%rbp),%rax
movw   $0x1,(%rax)
jmp    1261 <get_settings+0x101>
mov    -0x10(%rbp),%rax
movw   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_settings>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xe8a(%rip),%rsi
call   1040 <strcpy@plt>
movw   $0x0,(%r14)
lea    0xe84(%rip),%rdi
lea    0xe86(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1209 <get_settings+0xa9>
mov    %rax,%r15
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1209 <get_settings+0xa9>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0x6(%rsp),%rdi
mov    $0xa,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1209 <get_settings+0xa9>
lea    0xe39(%rip),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x6(%rsp),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
mov    %cx,(%r14)
mov    %r15,%rdi
call   1050 <fclose@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"logfile.log\00"
@.str.1 = [9 x i8] c"settings\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [5 x i8] c"true\00"
define void @get_settings(i8* %0, i16* %1) {
%3 = alloca i8*
%4 = alloca i16*
%5 = alloca i32*
%6 = alloca [10 x i8]
store i8* %0, i8** %3
store i16* %1, i16** %4
store i32* null, i32** %5
%7 = load i8*, i8** %3
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%9 = load i16*, i16** %4
store i16 0, i16* %9
%10 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %10, i32** %5
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %13
12: ; preds = %2
br label %43
13: ; preds = %2
%14 = load i8*, i8** %3
%15 = load i32*, i32** %5
%16 = call i32* @fgets(i8* %14, i32 256, i32* %15)
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %19
18: ; preds = %13
br label %43
19: ; preds = %13
%20 = load i8*, i8** %3
%21 = load i8*, i8** %3
%22 = call i32 @strlen(i8* %21)
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %20, i64 %24
store i8 0, i8* %25
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%27 = load i32*, i32** %5
%28 = call i32* @fgets(i8* %26, i32 10, i32* %27)
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %31
30: ; preds = %19
br label %43
31: ; preds = %19
%32 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%33 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%34 = call i64 @strncmp(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = load i16*, i16** %4
store i16 1, i16* %37
br label %40
38: ; preds = %31
%39 = load i16*, i16** %4
store i16 0, i16* %39
br label %40
40: ; preds = %38, %36
%41 = load i32*, i32** %5
%42 = call i32 @fclose(i32* %41)
br label %43
43: ; preds = %40, %30, %18, %12
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"logfile.log\00"
@.str.1 = [9 x i8] c"settings\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [5 x i8] c"true\00"
define void @get_settings(i8* %0, i16* nocapture writeonly %1) {
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i16 0, i16* %1
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %24, label %8
8: ; preds = %2
%9 = tail call i32* @fgets(i8* %0, i32 256, i32* %6)
%10 = icmp eq i32* %9, null
br i1 %10, label %24, label %11
11: ; preds = %8
%12 = tail call i32 @strlen(i8* %0)
%13 = add nsw i32 %12, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
store i8 0, i8* %15
%16 = call i32* @fgets(i8* %4, i32 10, i32* %6)
%17 = icmp eq i32* %16, null
br i1 %17, label %24, label %18
18: ; preds = %11
%19 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%20 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = icmp eq i64 %20, 0
%22 = zext i1 %21 to i16
store i16 %22, i16* %1
%23 = call i32 @fclose(i32* %6)
br label %24
24: ; preds = %11, %8, %2, %18
ret void
}