#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*/ exit(int);
int /*<<< orphan*/ fputs(char const *, int /*<<< orphan*/);
int getopt(int, char **, char *);
scalar_t__ optind;
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ setenv(char *, char *, int);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ zlog_fini();
int zlog_init(char *);
int main(int argc, char *argv[]) {
  int rc = 0;
  int op;
  int quiet = 0;
  static const char *help = "useage: zlog-chk-conf [conf files]...\n"
                            "\t-q,\tsuppress non-error message\n"
                            "\t-h,\tshow help message\n"
                            "zlog version: "
                            "1.2.12"
                            "\n";
  while ((op = getopt(argc, argv, "qhv")) > 0) {
    if (op == 'h') {
      fputs(help, stdout);
      return 0;
    } else if (op == 'q') {
      quiet = 1;
    }
  }
  argc -= optind;
  argv += optind;
  if (argc == 0) {
    fputs(help, stdout);
    return -1;
  }
  setenv("ZLOG_PROFILE_ERROR", "/dev/stderr", 1);
  setenv("ZLOG_CHECK_FORMAT_RULE", "1", 1);
  while (argc > 0) {
    rc = zlog_init(*argv);
    if (rc) {
      printf("\n---[%s] syntax error, see error message above\n", *argv);
      exit(2);
    } else {
      zlog_fini();
      if (!quiet) {
        printf("--[%s] syntax right\n", *argv);
      }
    }
    argc--;
    argv++;
  }
  exit(0);
}


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)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xed1(%rip),%rdx
call   1080 <getopt@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jle    11f9 <main+0x89>
cmpl   $0x68,-0x18(%rbp)
jne    11de <main+0x6e>
mov    0x2e94(%rip),%rdi
mov    0x2e0d(%rip),%rax
mov    (%rax),%esi
call   1060 <fputs@plt>
movl   $0x0,-0x4(%rbp)
jmp    1308 <main+0x198>
cmpl   $0x71,-0x18(%rbp)
jne    11ef <main+0x7f>
movl   $0x1,-0x1c(%rbp)
jmp    11f4 <main+0x84>
jmp    1194 <main+0x24>
mov    0x2de8(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2dd4(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    124e <main+0xde>
mov    0x2e24(%rip),%rdi
mov    0x2d9d(%rip),%rax
mov    (%rax),%esi
call   1060 <fputs@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1308 <main+0x198>
lea    0xe22(%rip),%rdi
lea    0xe2e(%rip),%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
lea    0xe29(%rip),%rdi
lea    0xe39(%rip),%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
cmpl   $0x0,-0x8(%rbp)
jle    1301 <main+0x191>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <zlog_init@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     12be <main+0x14e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe00(%rip),%rdi
call   1050 <printf@plt>
mov    $0x2,%edi
call   1090 <exit@plt>
mov    $0x0,%al
call   1070 <zlog_fini@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    12e2 <main+0x172>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe02(%rip),%rdi
call   1050 <printf@plt>
jmp    12e7 <main+0x177>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    127e <main+0x10e>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %edi,%r14d
lea    0xeee(%rip),%rdx
call   1080 <getopt@plt>
xor    %r15d,%r15d
test   %eax,%eax
jle    11c6 <main+0x56>
lea    0xedb(%rip),%rbp
jmp    11b8 <main+0x48>
nopw   0x0(%rax,%rax,1)
mov    $0x1,%r15d
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1080 <getopt@plt>
test   %eax,%eax
jle    11c6 <main+0x56>
cmp    $0x71,%eax
je     11a0 <main+0x30>
cmp    $0x68,%eax
jne    11a6 <main+0x36>
xor    %ebp,%ebp
jmp    11da <main+0x6a>
mov    0x2e1b(%rip),%rax
mov    (%rax),%r12
mov    $0xffffffff,%ebp
sub    %r12d,%r14d
jne    11fa <main+0x8a>
mov    0x2df7(%rip),%rax
mov    (%rax),%esi
lea    0xe16(%rip),%rdi
call   1060 <fputs@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe76(%rip),%rdi
lea    0xe82(%rip),%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
lea    0xe7d(%rip),%rdi
lea    0xe8d(%rip),%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
test   %r14d,%r14d
jle    1275 <main+0x105>
lea    (%rbx,%r12,8),%rbp
add    $0x1,%r14d
lea    0xea1(%rip),%rbx
jmp    124e <main+0xde>
add    $0x8,%rbp
add    $0xffffffff,%r14d
cmp    $0x1,%r14d
jle    1275 <main+0x105>
mov    0x0(%rbp),%rdi
call   1030 <zlog_init@plt>
test   %eax,%eax
jne    127c <main+0x10c>
xor    %eax,%eax
call   1070 <zlog_fini@plt>
test   %r15d,%r15d
jne    1240 <main+0xd0>
mov    0x0(%rbp),%rsi
mov    %rbx,%rdi
call   1050 <printf@plt>
jmp    1240 <main+0xd0>
xor    %edi,%edi
call   1090 <exit@plt>
mov    0x0(%rbp),%rsi
lea    0xe28(%rip),%rdi
call   1050 <printf@plt>
mov    $0x2,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@main.help = internal global i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str, i32 0, i32 0)
@.str = [115 x i8] c"useage: zlog-chk-conf [conf files]...\0A\09-q,\09suppress non-error message\0A\09-h,\09show help message\0Azlog version: 1.2.12\0A\00"
@.str.1 = [4 x i8] c"qhv\00"
@stdout = global i32 0
@optind = global i64 0
@.str.2 = [19 x i8] c"ZLOG_PROFILE_ERROR\00"
@.str.3 = [12 x i8] c"/dev/stderr\00"
@.str.4 = [23 x i8] c"ZLOG_CHECK_FORMAT_RULE\00"
@.str.5 = [2 x i8] c"1\00"
@.str.6 = [48 x i8] c"\0A---[%s] syntax error, see error message above\0A\00"
@.str.7 = [21 x i8] c"--[%s] syntax right\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %8
br label %9
9: ; preds = %26, %2
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @getopt(i32 %10, i8** %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32 %12, i32* %7
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %27
14: ; preds = %9
%15 = load i32, i32* %7
%16 = icmp eq i32 %15, 104
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load i8*, i8** @main.help
%19 = load i32, i32* @stdout
%20 = call i32 @fputs(i8* %18, i32 %19)
store i32 0, i32* %3
br label %75
21: ; preds = %14
%22 = load i32, i32* %7
%23 = icmp eq i32 %22, 113
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 1, i32* %8
br label %25
25: ; preds = %24, %21
br label %26
26: ; preds = %25
br label %9
27: ; preds = %9
%28 = load i64, i64* @optind
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = sub nsw i64 %30, %28
%32 = trunc i64 %31 to i32
store i32 %32, i32* %4
%33 = load i64, i64* @optind
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 %33
store i8** %35, i8*** %5
%36 = load i32, i32* %4
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %27
%39 = load i8*, i8** @main.help
%40 = load i32, i32* @stdout
%41 = call i32 @fputs(i8* %39, i32 %40)
store i32 -1, i32* %3
br label %75
42: ; preds = %27
%43 = call i32 @setenv(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 1)
%44 = call i32 @setenv(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1)
br label %45
45: ; preds = %68, %42
%46 = load i32, i32* %4
%47 = icmp sgt i32 %46, 0
br i1 %47, label %48, label %73
48: ; preds = %45
%49 = load i8**, i8*** %5
%50 = load i8*, i8** %49
%51 = call i32 @zlog_init(i8* %50)
store i32 %51, i32* %6
%52 = load i32, i32* %6
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %59
54: ; preds = %48
%55 = load i8**, i8*** %5
%56 = load i8*, i8** %55
%57 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0), i8* %56)
%58 = call i32 @exit(i32 2)
unreachable
59: ; preds = %48
%60 = call i32 (...) @zlog_fini()
%61 = load i32, i32* %8
%62 = icmp ne i32 %61, 0
br i1 %62, label %67, label %63
63: ; preds = %59
%64 = load i8**, i8*** %5
%65 = load i8*, i8** %64
%66 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %65)
br label %67
67: ; preds = %63, %59
br label %68
68: ; preds = %67
%69 = load i32, i32* %4
%70 = add nsw i32 %69, -1
store i32 %70, i32* %4
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i32 1
store i8** %72, i8*** %5
br label %45
73: ; preds = %45
%74 = call i32 @exit(i32 0)
unreachable
75: ; preds = %38, %17
%76 = load i32, i32* %3
ret i32 %76
}

LLVM IR (-O2):
@.str = [115 x i8] c"useage: zlog-chk-conf [conf files]...\0A\09-q,\09suppress non-error message\0A\09-h,\09show help message\0Azlog version: 1.2.12\0A\00"
@.str.1 = [4 x i8] c"qhv\00"
@stdout = global i32 0
@optind = global i64 0
@.str.2 = [19 x i8] c"ZLOG_PROFILE_ERROR\00"
@.str.3 = [12 x i8] c"/dev/stderr\00"
@.str.4 = [23 x i8] c"ZLOG_CHECK_FORMAT_RULE\00"
@.str.5 = [2 x i8] c"1\00"
@.str.6 = [48 x i8] c"\0A---[%s] syntax error, see error message above\0A\00"
@.str.7 = [21 x i8] c"--[%s] syntax right\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %13
5: ; preds = %2, %9
%6 = phi i32 [ %11, %9 ], [ %3, %2 ]
%7 = phi i32 [ %10, %9 ], [ 0, %2 ]
switch i32 %6, label %9 [
i32 104, label %47
i32 113, label %8
]
8: ; preds = %5
br label %9
9: ; preds = %5, %8
%10 = phi i32 [ 1, %8 ], [ %7, %5 ]
%11 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp sgt i32 %11, 0
br i1 %12, label %5, label %13
13: ; preds = %9, %2
%14 = phi i32 [ 0, %2 ], [ %10, %9 ]
%15 = load i64, i64* @optind
%16 = trunc i64 %15 to i32
%17 = sub i32 %0, %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %47, label %19
19: ; preds = %13
%20 = tail call i32 @setenv(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 1)
%21 = tail call i32 @setenv(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1)
%22 = icmp sgt i32 %17, 0
br i1 %22, label %23, label %45
23: ; preds = %19
%24 = getelementptr inbounds i8*, i8** %1, i64 %15
%25 = icmp eq i32 %14, 0
br label %26
26: ; preds = %23, %41
%27 = phi i8** [ %24, %23 ], [ %43, %41 ]
%28 = phi i32 [ %17, %23 ], [ %42, %41 ]
%29 = load i8*, i8** %27
%30 = tail call i32 @zlog_init(i8* %29)
%31 = icmp eq i32 %30, 0
br i1 %31, label %36, label %32
32: ; preds = %26
%33 = load i8*, i8** %27
%34 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0), i8* %33)
%35 = tail call i32 @exit(i32 2)
unreachable
36: ; preds = %26
%37 = tail call i32 (...) @zlog_fini()
br i1 %25, label %38, label %41
38: ; preds = %36
%39 = load i8*, i8** %27
%40 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %39)
br label %41
41: ; preds = %36, %38
%42 = add nsw i32 %28, -1
%43 = getelementptr inbounds i8*, i8** %27, i64 1
%44 = icmp sgt i32 %28, 1
br i1 %44, label %26, label %45
45: ; preds = %41, %19
%46 = tail call i32 @exit(i32 0)
unreachable
47: ; preds = %5, %13
%48 = phi i32 [ -1, %13 ], [ 0, %5 ]
%49 = load i32, i32* @stdout
%50 = tail call i32 @fputs(i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str, i64 0, i64 0), i32 %49)
ret i32 %48
}