#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
char *malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ *openOrDie(char *, char *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ tidyStringUp(char *);
void loadListFromFile(char **out, char *optarg) {
  FILE *file = openOrDie(optarg, "r");
  int count = 0;
  char outputBuffer[256];
  while (!feof(file)) {
    if (fgets(outputBuffer, 256, file)) {
      tidyStringUp(outputBuffer);
      out[count] = malloc(256);
      if (!out[count]) {
        syslog(
            LOG_ERR,
            "Exiting with failure: malloc failed while processing arguments");
        exit(EXIT_FAILURE);
      }
      memcpy(out[count], outputBuffer, 256);
      out[count][256 - 1] = '\0';
      count++;
    }
  }
  fclose(file);
  syslog(LOG_INFO, "Using list located at %s", optarg);
}


x86 assembly (clang, -O0):
<loadListFromFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   10b0 <openOrDie@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11dc <loadListFromFile+0x4c>
jmp    1296 <loadListFromFile+0x106>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x100,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1291 <loadListFromFile+0x101>
lea    -0x120(%rbp),%rdi
call   1030 <tidyStringUp@plt>
mov    $0x100,%edi
call   1080 <malloc@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    1258 <loadListFromFile+0xc8>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
lea    0xdbf(%rip),%rsi
mov    $0x0,%al
call   1090 <syslog@plt>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x120(%rbp),%rsi
mov    $0x100,%edx
call   1070 <memcpy@plt>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movb   $0x0,0xff(%rax)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11be <loadListFromFile+0x2e>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xd8e(%rip),%rsi
mov    $0x0,%al
call   1090 <syslog@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadListFromFile>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe53(%rip),%rsi
mov    %r14,%rdi
call   10b0 <openOrDie@plt>
mov    %rax,%r13
mov    %rax,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     11f7 <loadListFromFile+0x67>
mov    %r13,%rdi
call   1040 <fclose@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
lea    0xe65(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1090 <syslog@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
xor    %ebx,%ebx
mov    %rsp,%r12
jmp    122a <loadListFromFile+0x9a>
xchg   %ax,%ax
mov    %rax,%rdi
mov    %r12,%rsi
mov    $0x100,%edx
call   1070 <memcpy@plt>
mov    (%r15,%rbx,8),%rax
movb   $0x0,0xff(%rax)
add    $0x1,%ebx
mov    %r13,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    11c4 <loadListFromFile+0x34>
mov    %r12,%rdi
mov    $0x100,%esi
mov    %r13,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     121e <loadListFromFile+0x8e>
mov    %r12,%rdi
call   1030 <tidyStringUp@plt>
mov    $0x100,%edi
call   1080 <malloc@plt>
movslq %ebx,%rbx
mov    %rax,(%r15,%rbx,8)
test   %rax,%rax
jne    1200 <loadListFromFile+0x70>
mov    0x2d64(%rip),%rax
mov    (%rax),%edi
lea    0xd95(%rip),%rsi
xor    %eax,%eax
call   1090 <syslog@plt>
mov    0x2d65(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@LOG_ERR = global i32 0
@.str.1 = [63 x i8] c"Exiting with failure: malloc failed while processing arguments\00"
@EXIT_FAILURE = global i32 0
@LOG_INFO = global i32 0
@.str.2 = [25 x i8] c"Using list located at %s\00"
define void @loadListFromFile(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca [256 x i8]
store i8** %0, i8*** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
%9 = call i32* @openOrDie(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %5
store i32 0, i32* %6
br label %10
10: ; preds = %55, %2
%11 = load i32*, i32** %5
%12 = call i32 @feof(i32* %11)
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
br i1 %14, label %15, label %56
15: ; preds = %10
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%17 = load i32*, i32** %5
%18 = call i64 @fgets(i8* %16, i32 256, i32* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %55
20: ; preds = %15
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%22 = call i32 @tidyStringUp(i8* %21)
%23 = call i8* @malloc(i32 256)
%24 = load i8**, i8*** %3
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
store i8* %23, i8** %27
%28 = load i8**, i8*** %3
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = icmp ne i8* %32, null
br i1 %33, label %39, label %34
34: ; preds = %20
%35 = load i32, i32* @LOG_ERR
%36 = call i32 (i32, i8*, ...) @syslog(i32 %35, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0))
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %20
%40 = load i8**, i8*** %3
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%46 = call i32 @memcpy(i8* %44, i8* %45, i32 256)
%47 = load i8**, i8*** %3
%48 = load i32, i32* %6
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %47, i64 %49
%51 = load i8*, i8** %50
%52 = getelementptr inbounds i8, i8* %51, i64 255
store i8 0, i8* %52
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
br label %55
55: ; preds = %39, %15
br label %10
56: ; preds = %10
%57 = load i32*, i32** %5
%58 = call i32 @fclose(i32* %57)
%59 = load i32, i32* @LOG_INFO
%60 = load i8*, i8** %4
%61 = call i32 (i32, i8*, ...) @syslog(i32 %59, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %60)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@LOG_ERR = global i32 0
@.str.1 = [63 x i8] c"Exiting with failure: malloc failed while processing arguments\00"
@EXIT_FAILURE = global i32 0
@LOG_INFO = global i32 0
@.str.2 = [25 x i8] c"Using list located at %s\00"
define void @loadListFromFile(i8** nocapture %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = tail call i32* @openOrDie(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = call i32 @feof(i32* %4)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %32
8: ; preds = %2, %28
%9 = phi i32 [ %29, %28 ], [ 0, %2 ]
%10 = call i64 @fgets(i8* %5, i32 256, i32* %4)
%11 = icmp eq i64 %10, 0
br i1 %11, label %28, label %12
12: ; preds = %8
%13 = call i32 @tidyStringUp(i8* %5)
%14 = call dereferenceable_or_null(256) i8* @malloc(i32 256)
%15 = sext i32 %9 to i64
%16 = getelementptr inbounds i8*, i8** %0, i64 %15
store i8* %14, i8** %16
%17 = icmp eq i8* %14, null
br i1 %17, label %18, label %23
18: ; preds = %12
%19 = load i32, i32* @LOG_ERR
%20 = call i32 (i32, i8*, ...) @syslog(i32 %19, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %12
%24 = call i32 @memcpy(i8* %14, i8* %5, i32 256)
%25 = load i8*, i8** %16
%26 = getelementptr inbounds i8, i8* %25, i64 255
store i8 0, i8* %26
%27 = add nsw i32 %9, 1
br label %28
28: ; preds = %23, %8
%29 = phi i32 [ %27, %23 ], [ %9, %8 ]
%30 = call i32 @feof(i32* %4)
%31 = icmp eq i32 %30, 0
br i1 %31, label %8, label %32
32: ; preds = %28, %2
%33 = call i32 @fclose(i32* %4)
%34 = load i32, i32* @LOG_INFO
%35 = call i32 (i32, i8*, ...) @syslog(i32 %34, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %1)
ret void
}