#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*/ SIGPIPE;
int /*<<< orphan*/ SIG_IGN;
int getopt(int, char **, char *);
char *optarg;
int optind;
int /*<<< orphan*/ printf(char *);
int scan(char const *);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  int ret, ch;
  const char *oconn = NULL;
  while ((ch = getopt(argc, argv, "p:")) != -1) {
    switch (ch) {
    case 'p':
      oconn = optarg;
      break;
    default:
      usage(argv[0]);
    }
  }
  if (argc != optind)
    usage(argv[0]);
  signal(SIGPIPE, SIG_IGN);
  ret = scan(oconn);
  switch (ret) {
  case 0:
    printf("Looks like ClamAV daemon is not OK. Check up database integrity "
           "and restart daemon\n");
    return 0;
  case -1:
    printf("Could not verify ClamAV daemon status: socket error\n");
    break;
  default:
    break;
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe84(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     11c2 <main+0x72>
mov    -0x18(%rbp),%eax
sub    $0x70,%eax
jne    11b1 <main+0x61>
jmp    119e <main+0x4e>
mov    0x2e53(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    11bd <main+0x6d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
jmp    116e <main+0x1e>
mov    -0x8(%rbp),%eax
mov    0x2e14(%rip),%rcx
cmp    (%rcx),%eax
je     11e0 <main+0x90>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
mov    0x2de8(%rip),%rax
mov    (%rax),%esi
call   1040 <signal@plt>
mov    -0x20(%rbp),%rdi
call   1060 <scan@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0xffffffff,%eax
je     123f <main+0xef>
jmp    1217 <main+0xc7>
mov    -0x24(%rbp),%eax
test   %eax,%eax
jne    1250 <main+0x100>
jmp    1227 <main+0xd7>
lea    0xdd5(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    125c <main+0x10c>
lea    0xe11(%rip),%rdi
call   1030 <printf@plt>
jmp    1255 <main+0x105>
jmp    1255 <main+0x105>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %r14d,%r14d
lea    0xe99(%rip),%r15
mov    0x2e8a(%rip),%r12
jmp    1178 <main+0x28>
mov    (%rbx),%rdi
call   1050 <usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1070 <getopt@plt>
cmp    $0xffffffff,%eax
je     1195 <main+0x45>
cmp    $0x70,%eax
jne    1170 <main+0x20>
mov    (%r12),%r14
jmp    1178 <main+0x28>
mov    0x2e44(%rip),%rax
cmp    %ebp,(%rax)
je     11a8 <main+0x58>
mov    (%rbx),%rdi
call   1050 <usage@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
mov    0x2e20(%rip),%rax
mov    (%rax),%esi
call   1040 <signal@plt>
mov    %r14,%rdi
call   1060 <scan@plt>
test   %eax,%eax
je     11e3 <main+0x93>
mov    $0x1,%ebx
cmp    $0xffffffff,%eax
jne    11f1 <main+0xa1>
mov    $0x1,%ebx
lea    0xe22(%rip),%rdi
jmp    11ec <main+0x9c>
lea    0xe4d(%rip),%rdi
mov    %eax,%ebx
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"p:\00"
@optarg = global i8* null
@optind = global i32 0
@SIGPIPE = global i32 0
@SIG_IGN = global i32 0
@.str.1 = [84 x i8] c"Looks like ClamAV daemon is not OK. Check up database integrity and restart daemon\0A\00"
@.str.2 = [53 x i8] c"Could not verify ClamAV daemon status: socket error\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 i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %8
br label %9
9: ; preds = %23, %2
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @getopt(i32 %10, i8** %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %12, i32* %7
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %24
14: ; preds = %9
%15 = load i32, i32* %7
switch i32 %15, label %18 [
i32 112, label %16
]
16: ; preds = %14
%17 = load i8*, i8** @optarg
store i8* %17, i8** %8
br label %23
18: ; preds = %14
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 @usage(i8* %21)
br label %23
23: ; preds = %18, %16
br label %9
24: ; preds = %9
%25 = load i32, i32* %4
%26 = load i32, i32* @optind
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = call i32 @usage(i8* %31)
br label %33
33: ; preds = %28, %24
%34 = load i32, i32* @SIGPIPE
%35 = load i32, i32* @SIG_IGN
%36 = call i32 @signal(i32 %34, i32 %35)
%37 = load i8*, i8** %8
%38 = call i32 @scan(i8* %37)
store i32 %38, i32* %6
%39 = load i32, i32* %6
switch i32 %39, label %44 [
i32 0, label %40
i32 -1, label %42
]
40: ; preds = %33
%41 = call i32 @printf(i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %46
42: ; preds = %33
%43 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0))
br label %45
44: ; preds = %33
br label %45
45: ; preds = %44, %42
store i32 1, i32* %3
br label %46
46: ; preds = %45, %40
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str = [3 x i8] c"p:\00"
@optarg = global i8* null
@optind = global i32 0
@SIGPIPE = global i32 0
@SIG_IGN = global i32 0
@str = [52 x i8] c"Could not verify ClamAV daemon status: socket error\00"
@str.3 = [83 x i8] c"Looks like ClamAV daemon is not OK. Check up database integrity and restart daemon\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %7, %2
%4 = phi i8* [ %8, %7 ], [ null, %2 ]
br label %5
5: ; preds = %3, %9
%6 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %6, label %9 [
i32 -1, label %12
i32 112, label %7
]
7: ; preds = %5
%8 = load i8*, i8** @optarg
br label %3
9: ; preds = %5
%10 = load i8*, i8** %1
%11 = tail call i32 @usage(i8* %10)
br label %5
12: ; preds = %5
%13 = load i32, i32* @optind
%14 = icmp eq i32 %13, %0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i8*, i8** %1
%17 = tail call i32 @usage(i8* %16)
br label %18
18: ; preds = %15, %12
%19 = load i32, i32* @SIGPIPE
%20 = load i32, i32* @SIG_IGN
%21 = tail call i32 @signal(i32 %19, i32 %20)
%22 = tail call i32 @scan(i8* %4)
switch i32 %22, label %28 [
i32 0, label %24
i32 -1, label %23
]
23: ; preds = %18
br label %24
24: ; preds = %18, %23
%25 = phi i8* [ getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0), %23 ], [ getelementptr inbounds ([83 x i8], [83 x i8]* @str.3, i64 0, i64 0), %18 ]
%26 = phi i32 [ 1, %23 ], [ %22, %18 ]
%27 = tail call i32 @puts(i8* dereferenceable(1) %25)
br label %28
28: ; preds = %24, %18
%29 = phi i32 [ 1, %18 ], [ %26, %24 ]
ret i32 %29
}