#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 */
struct minipc_ch {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, ...);
int /*<<< orphan*/ minipc_server_action(struct minipc_ch *, int);
struct minipc_ch *minipc_server_create(char *, int /*<<< orphan*/);
int /*<<< orphan*/ minipc_set_logfile(struct minipc_ch *, int /*<<< orphan*/);
scalar_t__ shm_export_functions(struct minipc_ch *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char **argv) {
  struct minipc_ch *ch;
  if (argc != 2) {
    fprintf(stderr, "%s: use \"%s <shmid>\n", argv[0], argv[0]);
    exit(1);
  }
  ch = minipc_server_create(argv[1], 0);
  if (!ch) {
    fprintf(stderr, "%s: rpc_open(%s): %s\n", argv[0], argv[1],
            strerror(errno));
    exit(1);
  }
  minipc_set_logfile(ch, stderr);
  if (shm_export_functions(ch)) {
    fprintf(stderr, "%s: exporting RPC functions: %s\n", argv[0],
            strerror(errno));
    exit(1);
  }
  while (1) {
    minipc_server_action(ch, 1000);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11bf <main+0x4f>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %esi,%esi
call   1090 <minipc_server_create@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1234 <main+0xc4>
mov    0x2dfc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    %rax,%r8
lea    0xdf2(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    0x2da1(%rip),%rax
mov    (%rax),%esi
call   1040 <minipc_set_logfile@plt>
mov    -0x18(%rbp),%rdi
call   1030 <shm_export_functions@plt>
cmp    $0x0,%rax
je     12a0 <main+0x130>
mov    0x2d80(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    0x2d61(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%rdx
mov    %rax,%rcx
lea    0xd9c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    12a5 <main+0x135>
mov    -0x18(%rbp),%rdi
mov    $0x3e8,%esi
call   1060 <minipc_server_action@plt>
jmp    12a5 <main+0x135>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
cmp    $0x2,%edi
jne    11cf <main+0x5f>
mov    0x8(%r14),%rdi
xor    %esi,%esi
call   1090 <minipc_server_create@plt>
mov    0x2e4f(%rip),%r15
mov    (%r15),%ebp
test   %rax,%rax
je     11e7 <main+0x77>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %ebp,%esi
call   1040 <minipc_set_logfile@plt>
mov    %rbx,%rdi
call   1030 <shm_export_functions@plt>
test   %rax,%rax
jne    121f <main+0xaf>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1060 <minipc_server_action@plt>
jmp    11c0 <main+0x50>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rcx
lea    0xe1e(%rip),%rsi
mov    %rcx,%rdx
jmp    1242 <main+0xd2>
mov    (%r14),%rbx
mov    0x8(%r14),%r14
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe12(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %r14,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    (%r15),%ebx
mov    (%r14),%rbp
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xdf1(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.minipc_ch = type { i32 }
@stderr = global i32 0
@.str = [21 x i8] c"%s: use \22%s <shmid>\0A\00"
@.str.1 = [22 x i8] c"%s: rpc_open(%s): %s\0A\00"
@errno = global i32 0
@.str.2 = [33 x i8] c"%s: exporting RPC functions: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.minipc_ch*
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 %19
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call %struct.minipc_ch* @minipc_server_create(i8* %22, i32 0)
store %struct.minipc_ch* %23, %struct.minipc_ch** %6
%24 = load %struct.minipc_ch*, %struct.minipc_ch** %6
%25 = icmp ne %struct.minipc_ch* %24, null
br i1 %25, label %38, label %26
26: ; preds = %19
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = load i32, i32* @errno
%35 = call i8* @strerror(i32 %34)
%36 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %30, i8* %33, i8* %35)
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %19
%39 = load %struct.minipc_ch*, %struct.minipc_ch** %6
%40 = load i32, i32* @stderr
%41 = call i32 @minipc_set_logfile(%struct.minipc_ch* %39, i32 %40)
%42 = load %struct.minipc_ch*, %struct.minipc_ch** %6
%43 = call i64 @shm_export_functions(%struct.minipc_ch* %42)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %54
45: ; preds = %38
%46 = load i32, i32* @stderr
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 0
%49 = load i8*, i8** %48
%50 = load i32, i32* @errno
%51 = call i8* @strerror(i32 %50)
%52 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %49, i8* %51)
%53 = call i32 @exit(i32 1)
unreachable
54: ; preds = %38
br label %55
55: ; preds = %54, %55
%56 = load %struct.minipc_ch*, %struct.minipc_ch** %6
%57 = call i32 @minipc_server_action(%struct.minipc_ch* %56, i32 1000)
br label %55
}

LLVM IR (-O2):
%struct.minipc_ch = type { i32 }
@stderr = global i32 0
@.str = [21 x i8] c"%s: use \22%s <shmid>\0A\00"
@.str.1 = [22 x i8] c"%s: rpc_open(%s): %s\0A\00"
@errno = global i32 0
@.str.2 = [33 x i8] c"%s: exporting RPC functions: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call %struct.minipc_ch* @minipc_server_create(i8* %11, i32 0)
%13 = icmp eq %struct.minipc_ch* %12, null
%14 = load i32, i32* @stderr
br i1 %13, label %15, label %22
15: ; preds = %9
%16 = load i8*, i8** %1
%17 = load i8*, i8** %10
%18 = load i32, i32* @errno
%19 = tail call i8* @strerror(i32 %18)
%20 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %16, i8* %17, i8* %19)
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %9
%23 = tail call i32 @minipc_set_logfile(%struct.minipc_ch* %12, i32 %14)
%24 = tail call i64 @shm_export_functions(%struct.minipc_ch* %12)
%25 = icmp eq i64 %24, 0
br i1 %25, label %33, label %26
26: ; preds = %22
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %1
%29 = load i32, i32* @errno
%30 = tail call i8* @strerror(i32 %29)
%31 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %28, i8* %30)
%32 = tail call i32 @exit(i32 1)
unreachable
33: ; preds = %22, %33
%34 = tail call i32 @minipc_server_action(%struct.minipc_ch* %12, i32 1000)
br label %33
}