#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 EOF;
int EX_OK;
int EX_OSERR;
int /*<<< orphan*/ EX_USAGE;
int /*<<< orphan*/ err(int, char *, char *);
int /*<<< orphan*/ errx(int, char *, ...);
int fclose(int /*<<< orphan*/ *const);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *const);
scalar_t__ ferror(int /*<<< orphan*/ *const);
int fgetc(int /*<<< orphan*/ *const);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int /*<<< orphan*/ warn(char *, char *);
int /*<<< orphan*/ warnx(char *, char *);
int main(int argc, char **argv) {
  if (argc < 2)
    errx(EX_USAGE, "Error: No arguments given");
  else if (argc > 2)
    errx(EX_USAGE, "Error: Too many arguments given");
  else if (!strncmp(argv[1], "-h", 2))
    errx(EX_OK, "Usage: confdump [-h] FILE");
  else if (!strncmp(argv[1], "-V", 2))
    errx(EX_OK, "version %s", "0.1");
  FILE *const fp = fopen(argv[1], "r");
  if (!fp)
    err(EX_OSERR, "Cannot open config file %s", argv[1]);
  int c;
  while ((c = fgetc(fp)) != EOF) {
  }
finish_parse:
  if (ferror(fp) != 0) {
    warn("Error reading from config file %s", argv[1]);
    if (fclose(fp) == EOF)
      err(EX_OSERR, "Could not close config file %s", argv[1]);
    return EX_OSERR;
  }
  if (!feof(fp)) {
    warnx("Unknown error reading from config file %s", argv[1]);
    if (fclose(fp) == EOF)
      err(EX_OSERR, "Could not close config file %s", argv[1]);
    return EX_OSERR;
  }
  if (fclose(fp) == EOF)
    err(EX_OSERR, "Could not close config file %s", argv[1]);
  return EX_OK;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11dc <main+0x3c>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
lea    0xe30(%rip),%rsi
mov    $0x0,%al
call   1070 <errx@plt>
jmp    128f <main+0xef>
cmpl   $0x2,-0x8(%rbp)
jle    1202 <main+0x62>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
lea    0xe24(%rip),%rsi
mov    $0x0,%al
call   1070 <errx@plt>
jmp    128a <main+0xea>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe29(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1240 <main+0xa0>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
lea    0xe09(%rip),%rsi
mov    $0x0,%al
call   1070 <errx@plt>
jmp    1285 <main+0xe5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe08(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1280 <main+0xe0>
mov    0x2d67(%rip),%rax
mov    (%rax),%edi
lea    0xde8(%rip),%rsi
lea    0xdec(%rip),%rdx
mov    $0x0,%al
call   1070 <errx@plt>
jmp    1285 <main+0xe5>
jmp    128a <main+0xea>
jmp    128f <main+0xef>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdcb(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12cf <main+0x12f>
mov    0x2d0f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xda1(%rip),%rsi
call   10b0 <err@plt>
jmp    12d4 <main+0x134>
mov    -0x18(%rbp),%rdi
call   1090 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2cf9(%rip),%rcx
cmp    (%rcx),%eax
je     12f4 <main+0x154>
jmp    12d4 <main+0x134>
jmp    12f9 <main+0x159>
mov    -0x18(%rbp),%rdi
call   1050 <ferror@plt>
cmp    $0x0,%rax
je     1366 <main+0x1c6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd6b(%rip),%rdi
call   1040 <warn@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
mov    0x2cb0(%rip),%rcx
cmp    (%rcx),%eax
jne    1355 <main+0x1b5>
mov    0x2c89(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd58(%rip),%rsi
call   10b0 <err@plt>
mov    0x2c6c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1413 <main+0x273>
mov    -0x18(%rbp),%rdi
call   10a0 <feof@plt>
cmp    $0x0,%eax
jne    13d2 <main+0x232>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd40(%rip),%rdi
call   1080 <warnx@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
mov    0x2c44(%rip),%rcx
cmp    (%rcx),%eax
jne    13c1 <main+0x221>
mov    0x2c1d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xcec(%rip),%rsi
call   10b0 <err@plt>
mov    0x2c00(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1413 <main+0x273>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
mov    0x2bfe(%rip),%rcx
cmp    (%rcx),%eax
jne    1407 <main+0x267>
mov    0x2bd7(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xca6(%rip),%rsi
call   10b0 <err@plt>
mov    0x2bc2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
cmp    $0x1,%edi
jg     11bf <main+0x1f>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
lea    0xe43(%rip),%rsi
jmp    1238 <main+0x98>
cmp    $0x2,%edi
jne    1216 <main+0x76>
mov    0x8(%r14),%rdi
lea    0xe6b(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1228 <main+0x88>
mov    0x8(%r14),%rdi
lea    0xe6f(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    123f <main+0x9f>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
lea    0xe58(%rip),%rdx
xor    %eax,%eax
call   1070 <errx@plt>
jmp    123f <main+0x9f>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
lea    0xdf4(%rip),%rsi
jmp    1238 <main+0x98>
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
lea    0xe05(%rip),%rsi
xor    %eax,%eax
call   1070 <errx@plt>
mov    0x8(%r14),%rdi
lea    0xe1f(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1270 <main+0xd0>
mov    0x2d6a(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r14),%rdx
lea    0xe00(%rip),%rsi
call   10b0 <err@plt>
mov    0x2d69(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1090 <fgetc@plt>
cmp    (%r15),%eax
jne    1280 <main+0xe0>
mov    %rbx,%rdi
call   1050 <ferror@plt>
test   %rax,%rax
je     12df <main+0x13f>
mov    0x8(%r14),%rsi
lea    0xde1(%rip),%rdi
call   1040 <warn@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    0x2d0f(%rip),%rbx
cmp    (%r15),%eax
jne    12d7 <main+0x137>
mov    0x2d03(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r14),%rdx
lea    0xdd6(%rip),%rsi
call   10b0 <err@plt>
mov    (%rbx),%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %rbx,%rdi
call   10a0 <feof@plt>
test   %eax,%eax
je     1301 <main+0x161>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    0x2cd6(%rip),%rbx
cmp    (%r15),%eax
je     12be <main+0x11e>
jmp    12d7 <main+0x137>
mov    0x8(%r14),%rsi
lea    0xdbb(%rip),%rdi
call   1080 <warnx@plt>
jmp    12aa <main+0x10a>

LLVM IR (-O0):
@EX_USAGE = global i32 0
@.str = [26 x i8] c"Error: No arguments given\00"
@.str.1 = [32 x i8] c"Error: Too many arguments given\00"
@.str.2 = [3 x i8] c"-h\00"
@EX_OK = global i32 0
@.str.3 = [26 x i8] c"Usage: confdump [-h] FILE\00"
@.str.4 = [3 x i8] c"-V\00"
@.str.5 = [11 x i8] c"version %s\00"
@.str.6 = [4 x i8] c"0.1\00"
@.str.7 = [2 x i8] c"r\00"
@EX_OSERR = global i32 0
@.str.8 = [27 x i8] c"Cannot open config file %s\00"
@EOF = global i32 0
@.str.9 = [34 x i8] c"Error reading from config file %s\00"
@.str.10 = [31 x i8] c"Could not close config file %s\00"
@.str.11 = [42 x i8] c"Unknown error reading from config file %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @EX_USAGE
%12 = call i32 (i32, i8*, ...) @errx(i32 %11, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %40
13: ; preds = %2
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 2
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* @EX_USAGE
%18 = call i32 (i32, i8*, ...) @errx(i32 %17, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %39
19: ; preds = %13
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @strncmp(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%24 = icmp ne i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %19
%26 = load i32, i32* @EX_OK
%27 = call i32 (i32, i8*, ...) @errx(i32 %26, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %38
28: ; preds = %19
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @strncmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 2)
%33 = icmp ne i32 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %28
%35 = load i32, i32* @EX_OK
%36 = call i32 (i32, i8*, ...) @errx(i32 %35, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %37
37: ; preds = %34, %28
br label %38
38: ; preds = %37, %25
br label %39
39: ; preds = %38, %16
br label %40
40: ; preds = %39, %10
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
%44 = call i32* @fopen(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %44, i32** %6
%45 = load i32*, i32** %6
%46 = icmp ne i32* %45, null
br i1 %46, label %53, label %47
47: ; preds = %40
%48 = load i32, i32* @EX_OSERR
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 1
%51 = load i8*, i8** %50
%52 = call i32 @err(i32 %48, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i8* %51)
br label %53
53: ; preds = %47, %40
br label %54
54: ; preds = %59, %53
%55 = load i32*, i32** %6
%56 = call i32 @fgetc(i32* %55)
store i32 %56, i32* %7
%57 = load i32, i32* @EOF
%58 = icmp ne i32 %56, %57
br i1 %58, label %59, label %60
59: ; preds = %54
br label %54
60: ; preds = %54
br label %61
61: ; preds = %60
%62 = load i32*, i32** %6
%63 = call i64 @ferror(i32* %62)
%64 = icmp ne i64 %63, 0
br i1 %64, label %65, label %82
65: ; preds = %61
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 1
%68 = load i8*, i8** %67
%69 = call i32 @warn(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i8* %68)
%70 = load i32*, i32** %6
%71 = call i32 @fclose(i32* %70)
%72 = load i32, i32* @EOF
%73 = icmp eq i32 %71, %72
br i1 %73, label %74, label %80
74: ; preds = %65
%75 = load i32, i32* @EX_OSERR
%76 = load i8**, i8*** %5
%77 = getelementptr inbounds i8*, i8** %76, i64 1
%78 = load i8*, i8** %77
%79 = call i32 @err(i32 %75, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i8* %78)
br label %80
80: ; preds = %74, %65
%81 = load i32, i32* @EX_OSERR
store i32 %81, i32* %3
br label %116
82: ; preds = %61
%83 = load i32*, i32** %6
%84 = call i32 @feof(i32* %83)
%85 = icmp ne i32 %84, 0
br i1 %85, label %103, label %86
86: ; preds = %82
%87 = load i8**, i8*** %5
%88 = getelementptr inbounds i8*, i8** %87, i64 1
%89 = load i8*, i8** %88
%90 = call i32 @warnx(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.11, i64 0, i64 0), i8* %89)
%91 = load i32*, i32** %6
%92 = call i32 @fclose(i32* %91)
%93 = load i32, i32* @EOF
%94 = icmp eq i32 %92, %93
br i1 %94, label %95, label %101
95: ; preds = %86
%96 = load i32, i32* @EX_OSERR
%97 = load i8**, i8*** %5
%98 = getelementptr inbounds i8*, i8** %97, i64 1
%99 = load i8*, i8** %98
%100 = call i32 @err(i32 %96, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i8* %99)
br label %101
101: ; preds = %95, %86
%102 = load i32, i32* @EX_OSERR
store i32 %102, i32* %3
br label %116
103: ; preds = %82
%104 = load i32*, i32** %6
%105 = call i32 @fclose(i32* %104)
%106 = load i32, i32* @EOF
%107 = icmp eq i32 %105, %106
br i1 %107, label %108, label %114
108: ; preds = %103
%109 = load i32, i32* @EX_OSERR
%110 = load i8**, i8*** %5
%111 = getelementptr inbounds i8*, i8** %110, i64 1
%112 = load i8*, i8** %111
%113 = call i32 @err(i32 %109, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i8* %112)
br label %114
114: ; preds = %108, %103
%115 = load i32, i32* @EX_OK
store i32 %115, i32* %3
br label %116
116: ; preds = %114, %101, %80
%117 = load i32, i32* %3
ret i32 %117
}

LLVM IR (-O2):
@EX_USAGE = global i32 0
@.str = [26 x i8] c"Error: No arguments given\00"
@.str.1 = [32 x i8] c"Error: Too many arguments given\00"
@.str.2 = [3 x i8] c"-h\00"
@EX_OK = global i32 0
@.str.3 = [26 x i8] c"Usage: confdump [-h] FILE\00"
@.str.4 = [3 x i8] c"-V\00"
@.str.5 = [11 x i8] c"version %s\00"
@.str.6 = [4 x i8] c"0.1\00"
@.str.7 = [2 x i8] c"r\00"
@EX_OSERR = global i32 0
@.str.8 = [27 x i8] c"Cannot open config file %s\00"
@EOF = global i32 0
@.str.9 = [34 x i8] c"Error reading from config file %s\00"
@.str.10 = [31 x i8] c"Could not close config file %s\00"
@.str.11 = [42 x i8] c"Unknown error reading from config file %s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @EX_USAGE
%6 = tail call i32 (i32, i8*, ...) @errx(i32 %5, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %27
7: ; preds = %2
%8 = icmp eq i32 %0, 2
br i1 %8, label %12, label %9
9: ; preds = %7
%10 = load i32, i32* @EX_USAGE
%11 = tail call i32 (i32, i8*, ...) @errx(i32 %10, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %27
12: ; preds = %7
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32 @strncmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i32, i32* @EX_OK
%19 = tail call i32 (i32, i8*, ...) @errx(i32 %18, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %27
20: ; preds = %12
%21 = load i8*, i8** %13
%22 = tail call i32 @strncmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 2)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i32, i32* @EX_OK
%26 = tail call i32 (i32, i8*, ...) @errx(i32 %25, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %27
27: ; preds = %9, %20, %24, %17, %4
%28 = getelementptr inbounds i8*, i8** %1, i64 1
%29 = load i8*, i8** %28
%30 = tail call i32* @fopen(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %36
32: ; preds = %27
%33 = load i32, i32* @EX_OSERR
%34 = load i8*, i8** %28
%35 = tail call i32 @err(i32 %33, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %32, %27
br label %37
37: ; preds = %36, %37
%38 = tail call i32 @fgetc(i32* %30)
%39 = load i32, i32* @EOF
%40 = icmp eq i32 %38, %39
br i1 %40, label %41, label %37
41: ; preds = %37
%42 = tail call i64 @ferror(i32* %30)
%43 = icmp eq i64 %42, 0
br i1 %43, label %50, label %44
44: ; preds = %41
%45 = load i8*, i8** %28
%46 = tail call i32 @warn(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i8* %45)
%47 = tail call i32 @fclose(i32* %30)
%48 = load i32, i32* @EOF
%49 = icmp eq i32 %47, %48
br i1 %49, label %63, label %68
50: ; preds = %41
%51 = tail call i32 @feof(i32* %30)
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %59
53: ; preds = %50
%54 = load i8*, i8** %28
%55 = tail call i32 @warnx(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.11, i64 0, i64 0), i8* %54)
%56 = tail call i32 @fclose(i32* %30)
%57 = load i32, i32* @EOF
%58 = icmp eq i32 %56, %57
br i1 %58, label %63, label %68
59: ; preds = %50
%60 = tail call i32 @fclose(i32* %30)
%61 = load i32, i32* @EOF
%62 = icmp eq i32 %60, %61
br i1 %62, label %63, label %68
63: ; preds = %59, %53, %44
%64 = phi i32* [ @EX_OSERR, %44 ], [ @EX_OSERR, %53 ], [ @EX_OK, %59 ]
%65 = load i32, i32* @EX_OSERR
%66 = load i8*, i8** %28
%67 = tail call i32 @err(i32 %65, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i8* %66)
br label %68
68: ; preds = %63, %59, %53, %44
%69 = phi i32* [ @EX_OSERR, %44 ], [ @EX_OSERR, %53 ], [ @EX_OK, %59 ], [ %64, %63 ]
%70 = load i32, i32* %69
ret i32 %70
}