#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 be_consumer();
int be_producer();
int create_queue();
int print_usage(char *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  if (argc < 2) {
    return print_usage(argv[0]);
  }
  if (strcmp(argv[1], "create") == 0) {
    return create_queue();
  }
  if (strcmp(argv[1], "consume") == 0) {
    return be_consumer();
  }
  if (strcmp(argv[1], "produce") == 0) {
    return be_producer();
  }
  return print_usage(argv[0]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1184 <main+0x34>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    121a <main+0xca>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11b1 <main+0x61>
mov    $0x0,%al
call   1030 <create_queue@plt>
mov    %eax,-0x4(%rbp)
jmp    121a <main+0xca>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe47(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11de <main+0x8e>
mov    $0x0,%al
call   1060 <be_consumer@plt>
mov    %eax,-0x4(%rbp)
jmp    121a <main+0xca>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe22(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    120b <main+0xbb>
mov    $0x0,%al
call   1040 <be_producer@plt>
mov    %eax,-0x4(%rbp)
jmp    121a <main+0xca>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <print_usage@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x1,%edi
jle    1198 <main+0x48>
mov    0x8(%rbx),%rdi
lea    0xe9c(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11a1 <main+0x51>
mov    0x8(%rbx),%rdi
lea    0xe8e(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11a9 <main+0x59>
mov    0x8(%rbx),%rdi
lea    0xe81(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11b1 <main+0x61>
mov    (%rbx),%rdi
pop    %rbx
jmp    1070 <print_usage@plt>
xor    %eax,%eax
pop    %rbx
jmp    1030 <create_queue@plt>
xor    %eax,%eax
pop    %rbx
jmp    1060 <be_consumer@plt>
xor    %eax,%eax
pop    %rbx
jmp    1040 <be_producer@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"create\00"
@.str.1 = [8 x i8] c"consume\00"
@.str.2 = [8 x i8] c"produce\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 0
%11 = load i8*, i8** %10
%12 = call i32 @print_usage(i8* %11)
store i32 %12, i32* %3
br label %42
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = call i32 (...) @create_queue()
store i32 %20, i32* %3
br label %42
21: ; preds = %13
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = call i32 (...) @be_consumer()
store i32 %28, i32* %3
br label %42
29: ; preds = %21
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %29
%36 = call i32 (...) @be_producer()
store i32 %36, i32* %3
br label %42
37: ; preds = %29
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = call i32 @print_usage(i8* %40)
store i32 %41, i32* %3
br label %42
42: ; preds = %37, %35, %27, %19, %8
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str = [7 x i8] c"create\00"
@.str.1 = [8 x i8] c"consume\00"
@.str.2 = [8 x i8] c"produce\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 i8*, i8** %1
%6 = tail call i32 @print_usage(i8* %5)
br label %29
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 (...) @create_queue()
br label %29
14: ; preds = %7
%15 = load i8*, i8** %8
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = tail call i32 (...) @be_consumer()
br label %29
20: ; preds = %14
%21 = load i8*, i8** %8
%22 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = tail call i32 (...) @be_producer()
br label %29
26: ; preds = %20
%27 = load i8*, i8** %1
%28 = tail call i32 @print_usage(i8* %27)
br label %29
29: ; preds = %26, %24, %18, %12, %4
%30 = phi i32 [ %6, %4 ], [ %13, %12 ], [ %19, %18 ], [ %25, %24 ], [ %28, %26 ]
ret i32 %30
}