#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*/ consumer();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ producer();
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncmp(char *, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    producer();
  } else if (argc >= 2 &&
             0 == strncmp(argv[1], "-producer", strlen("-producer"))) {
    producer();
  } else {
    consumer();
  }
  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)
cmpl   $0x2,-0x8(%rbp)
jge    117c <main+0x2c>
mov    $0x0,%al
call   1030 <producer@plt>
jmp    11d6 <main+0x86>
cmpl   $0x2,-0x8(%rbp)
jl     11ca <main+0x7a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
lea    0xe67(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%edx
lea    0xe55(%rip),%rsi
call   1040 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11ca <main+0x7a>
mov    $0x0,%al
call   1030 <producer@plt>
jmp    11d1 <main+0x81>
mov    $0x0,%al
call   1060 <consumer@plt>
jmp    11d6 <main+0x86>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jle    117e <main+0x2e>
mov    0x8(%rsi),%rbx
lea    0xe9c(%rip),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    118c <main+0x3c>
xor    %eax,%eax
call   1030 <producer@plt>
xor    %edi,%edi
call   1070 <exit@plt>
xor    %eax,%eax
call   1060 <consumer@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"-producer\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 %10
8: ; preds = %2
%9 = call i32 (...) @producer()
br label %25
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp sge i32 %11, 2
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%18 = call i64 @strncmp(i8* %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = icmp eq i64 0, %18
br i1 %19, label %20, label %22
20: ; preds = %13
%21 = call i32 (...) @producer()
br label %24
22: ; preds = %13, %10
%23 = call i32 (...) @consumer()
br label %24
24: ; preds = %22, %20
br label %25
25: ; preds = %24, %8
%26 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [10 x i8] c"-producer\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @producer()
br label %16
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%10 = tail call i64 @strncmp(i8* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = tail call i32 (...) @producer()
br label %16
14: ; preds = %6
%15 = tail call i32 (...) @consumer()
br label %16
16: ; preds = %12, %14, %4
%17 = tail call i32 @exit(i32 0)
unreachable
}