#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 */
unsigned int atoi(char *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ message_rcv_async();
int /*<<< orphan*/ message_rcv_sync();
int /*<<< orphan*/ message_reply_async();
int /*<<< orphan*/ message_reply_sync();
int /*<<< orphan*/ message_send_async();
int /*<<< orphan*/ message_send_receive();
int /*<<< orphan*/ message_send_receive_a();
int /*<<< orphan*/ message_send_sync();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int main(int argc, char **argv) {
  unsigned int temp_var;
  if (argc != 2) {
    printf("\nWrong Arguments USAGE: <msg_demo><1(Sender)/0(Receiver)>\n");
    return -1;
  }
  temp_var = atoi(argv[1]);
  printf("\nSTARTING THE MQSv DEMO\n");
  printf("======================\n");
  if (temp_var == 1) {
    printf("MessageQ Sender Application \n");
    sleep(2);
    message_send_sync();
    printf("Press Enter Key to Continue...\n");
    getchar();
    message_send_async();
    printf("Press Enter Key to Continue...\n");
    getchar();
    message_send_receive();
    printf("Press Enter Key to Continue...\n");
    getchar();
    message_send_receive_a();
    printf("Press Enter Key to Continue...\n");
    getchar();
  } else {
    printf("MessageQ Receiver Application \n");
    message_rcv_sync();
    printf("Press Enter Key to Continue...\n");
    getchar();
    message_rcv_async();
    printf("Press Enter Key to Continue...\n");
    getchar();
    message_reply_sync();
    printf("Press Enter Key to Continue...\n");
    getchar();
    message_reply_async();
    printf("Press Enter Key to Continue...\n");
    getchar();
  }
  printf("End of MessageService Demo. Press Enter Key to Quit\n");
  getchar();
  return 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)
je     11f8 <main+0x38>
lea    0xe19(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    133b <main+0x17b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x14(%rbp)
lea    0xe2c(%rip),%rdi
call   1050 <printf@plt>
lea    0xe39(%rip),%rdi
call   1050 <printf@plt>
cmpl   $0x1,-0x14(%rbp)
jne    12ad <main+0xed>
lea    0xe3b(%rip),%rdi
call   1050 <printf@plt>
mov    $0x2,%edi
call   10e0 <sleep@plt>
mov    $0x0,%al
call   1030 <message_send_sync@plt>
lea    0xe3c(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    $0x0,%al
call   1090 <message_send_async@plt>
lea    0xe22(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    $0x0,%al
call   1080 <message_send_receive@plt>
lea    0xe08(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    $0x0,%al
call   10a0 <message_send_receive_a@plt>
lea    0xdee(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
jmp    1321 <main+0x161>
lea    0xdf6(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <message_rcv_sync@plt>
lea    0xdc3(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    $0x0,%al
call   10b0 <message_rcv_async@plt>
lea    0xda9(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    $0x0,%al
call   10d0 <message_reply_sync@plt>
lea    0xd8f(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    $0x0,%al
call   1040 <message_reply_async@plt>
lea    0xd75(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
lea    0xda2(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    125a <main+0x9a>
mov    0x8(%rsi),%rdi
call   10c0 <atoi@plt>
mov    %eax,%ebx
lea    0xe24(%rip),%rdi
call   1050 <puts@plt>
lea    0xe30(%rip),%rdi
call   1050 <puts@plt>
cmp    $0x1,%ebx
jne    1270 <main+0xb0>
lea    0xe89(%rip),%rdi
call   1050 <puts@plt>
mov    $0x2,%edi
call   10e0 <sleep@plt>
xor    %eax,%eax
call   1030 <message_send_sync@plt>
lea    0xe89(%rip),%rbx
mov    %rbx,%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
call   1090 <message_send_async@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
call   1080 <message_send_receive@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
call   10a0 <message_send_receive_a@plt>
jmp    12cc <main+0x10c>
lea    0xe5d(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%ebx
jmp    12f4 <main+0x134>
lea    0xdb8(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1060 <message_rcv_sync@plt>
lea    0xe15(%rip),%rbx
mov    %rbx,%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
call   10b0 <message_rcv_async@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
call   10d0 <message_reply_sync@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
call   1040 <message_reply_async@plt>
lea    0xdcc(%rip),%rdi
call   1050 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <getchar@plt>
lea    0xd66(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [59 x i8] c"\0AWrong Arguments USAGE: <msg_demo><1(Sender)/0(Receiver)>\0A\00"
@.str.1 = [25 x i8] c"\0ASTARTING THE MQSv DEMO\0A\00"
@.str.2 = [24 x i8] c"======================\0A\00"
@.str.3 = [30 x i8] c"MessageQ Sender Application \0A\00"
@.str.4 = [32 x i8] c"Press Enter Key to Continue...\0A\00"
@.str.5 = [32 x i8] c"MessageQ Receiver Application \0A\00"
@.str.6 = [53 x i8] c"End of MessageService Demo. Press Enter Key to Quit\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %52
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %6
%16 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%18 = load i32, i32* %6
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %35
20: ; preds = %11
%21 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @sleep(i32 2)
%23 = call i32 (...) @message_send_sync()
%24 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%25 = call i32 (...) @getchar()
%26 = call i32 (...) @message_send_async()
%27 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%28 = call i32 (...) @getchar()
%29 = call i32 (...) @message_send_receive()
%30 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%31 = call i32 (...) @getchar()
%32 = call i32 (...) @message_send_receive_a()
%33 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%34 = call i32 (...) @getchar()
br label %49
35: ; preds = %11
%36 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%37 = call i32 (...) @message_rcv_sync()
%38 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%39 = call i32 (...) @getchar()
%40 = call i32 (...) @message_rcv_async()
%41 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%42 = call i32 (...) @getchar()
%43 = call i32 (...) @message_reply_sync()
%44 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%45 = call i32 (...) @getchar()
%46 = call i32 (...) @message_reply_async()
%47 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%48 = call i32 (...) @getchar()
br label %49
49: ; preds = %35, %20
%50 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0))
%51 = call i32 (...) @getchar()
store i32 0, i32* %3
br label %52
52: ; preds = %49, %9
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@str = [24 x i8] c"\0ASTARTING THE MQSv DEMO\00"
@str.7 = [23 x i8] c"======================\00"
@str.8 = [31 x i8] c"MessageQ Receiver Application \00"
@str.13 = [52 x i8] c"End of MessageService Demo. Press Enter Key to Quit\00"
@str.14 = [29 x i8] c"MessageQ Sender Application \00"
@str.18 = [31 x i8] c"Press Enter Key to Continue...\00"
@str.19 = [58 x i8] c"\0AWrong Arguments USAGE: <msg_demo><1(Sender)/0(Receiver)>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str.19, i64 0, i64 0))
br label %44
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.7, i64 0, i64 0))
%12 = icmp eq i32 %9, 1
br i1 %12, label %13, label %26
13: ; preds = %6
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.14, i64 0, i64 0))
%15 = tail call i32 @sleep(i32 2)
%16 = tail call i32 (...) @message_send_sync()
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.18, i64 0, i64 0))
%18 = tail call i32 (...) @getchar()
%19 = tail call i32 (...) @message_send_async()
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.18, i64 0, i64 0))
%21 = tail call i32 (...) @getchar()
%22 = tail call i32 (...) @message_send_receive()
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.18, i64 0, i64 0))
%24 = tail call i32 (...) @getchar()
%25 = tail call i32 (...) @message_send_receive_a()
br label %38
26: ; preds = %6
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.8, i64 0, i64 0))
%28 = tail call i32 (...) @message_rcv_sync()
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.18, i64 0, i64 0))
%30 = tail call i32 (...) @getchar()
%31 = tail call i32 (...) @message_rcv_async()
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.18, i64 0, i64 0))
%33 = tail call i32 (...) @getchar()
%34 = tail call i32 (...) @message_reply_sync()
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.18, i64 0, i64 0))
%36 = tail call i32 (...) @getchar()
%37 = tail call i32 (...) @message_reply_async()
br label %38
38: ; preds = %26, %13
%39 = phi i8* [ getelementptr inbounds ([31 x i8], [31 x i8]* @str.18, i64 0, i64 0), %26 ], [ getelementptr inbounds ([31 x i8], [31 x i8]* @str.18, i64 0, i64 0), %13 ]
%40 = tail call i32 @puts(i8* dereferenceable(1) %39)
%41 = tail call i32 (...) @getchar()
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.13, i64 0, i64 0))
%43 = tail call i32 (...) @getchar()
br label %44
44: ; preds = %38, %4
%45 = phi i32 [ -1, %4 ], [ 0, %38 ]
ret i32 %45
}