#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ queue_repair(char *);
char *strdup(int /*<<< orphan*/);
int main(int argc, char **argv) {
  int opt = 0;
  char *cq = NULL;
  while ((opt = getopt(argc, argv, "hq:")) != -1)
    switch (opt) {
    case 'q':
      cq = strdup(optarg);
      break;
    default:
      puts("Usage: qlen [-h] [-q queue-name] [--]");
      return EXIT_FAILURE;
    }
  queue_repair(((cq) != NULL ? (cq) : (("."))));
  return EXIT_SUCCESS;
}


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)
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe8d(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     11ce <main+0x8e>
mov    -0x14(%rbp),%eax
sub    $0x71,%eax
jne    11ac <main+0x6c>
jmp    1195 <main+0x55>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
call   1060 <strdup@plt>
mov    %rax,-0x20(%rbp)
jmp    11c9 <main+0x89>
lea    0xe51(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    120b <main+0xcb>
jmp    1165 <main+0x25>
cmpq   $0x0,-0x20(%rbp)
je     11e6 <main+0xa6>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    11f6 <main+0xb6>
lea    0xe3d(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11f6 <main+0xb6>
mov    -0x28(%rbp),%rdi
call   1040 <queue_repair@plt>
mov    0x2dca(%rip),%rax
mov    (%rax),%eax
mov    %eax,-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    0xea9(%rip),%r15
mov    0x2e9a(%rip),%r12
xchg   %ax,%ax
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1050 <getopt@plt>
cmp    $0x71,%eax
jne    1180 <main+0x40>
mov    (%r12),%edi
call   1060 <strdup@plt>
mov    %rax,%r14
jmp    1160 <main+0x20>
cmp    $0xffffffff,%eax
jne    11a1 <main+0x61>
test   %r14,%r14
lea    0xe9b(%rip),%rdi
cmovne %r14,%rdi
call   1040 <queue_repair@plt>
mov    0x2e31(%rip),%rax
jmp    11b4 <main+0x74>
lea    0xe5c(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e24(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"hq:\00"
@optarg = global i32 0
@.str.1 = [38 x i8] c"Usage: qlen [-h] [-q queue-name] [--]\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [2 x i8] c".\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i8* null, i8** %7
br label %8
8: ; preds = %21, %2
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @getopt(i32 %9, i8** %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %6
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %22
13: ; preds = %8
%14 = load i32, i32* %6
switch i32 %14, label %18 [
i32 113, label %15
]
15: ; preds = %13
%16 = load i32, i32* @optarg
%17 = call i8* @strdup(i32 %16)
store i8* %17, i8** %7
br label %21
18: ; preds = %13
%19 = call i32 @puts(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
store i32 %20, i32* %3
br label %32
21: ; preds = %15
br label %8
22: ; preds = %8
%23 = load i8*, i8** %7
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = load i8*, i8** %7
br label %28
27: ; preds = %22
br label %28
28: ; preds = %27, %25
%29 = phi i8* [ %26, %25 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %27 ]
%30 = call i32 @queue_repair(i8* %29)
%31 = load i32, i32* @EXIT_SUCCESS
store i32 %31, i32* %3
br label %32
32: ; preds = %28, %18
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [4 x i8] c"hq:\00"
@optarg = global i32 0
@.str.1 = [38 x i8] c"Usage: qlen [-h] [-q queue-name] [--]\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [2 x i8] c".\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %6, %2
%4 = phi i8* [ null, %2 ], [ %8, %6 ]
%5 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
switch i32 %5, label %9 [
i32 -1, label %11
i32 113, label %6
]
6: ; preds = %3
%7 = load i32, i32* @optarg
%8 = tail call i8* @strdup(i32 %7)
br label %3
9: ; preds = %3
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
br label %15
11: ; preds = %3
%12 = icmp eq i8* %4, null
%13 = select i1 %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %4
%14 = tail call i32 @queue_repair(i8* %13)
br label %15
15: ; preds = %11, %9
%16 = phi i32* [ @EXIT_FAILURE, %9 ], [ @EXIT_SUCCESS, %11 ]
%17 = load i32, i32* %16
ret i32 %17
}