#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 */
typedef int /*<<< orphan*/ xdrproc_t;
struct svc_req {
  int rq_proc;
};
typedef int /*<<< orphan*/ SVCXPRT;

/* Variables and functions */
scalar_t__ FALSE;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ svc_getargs(int /*<<< orphan*/ *, int /*<<< orphan*/,
                               char *);
scalar_t__ svc_sendreply(int /*<<< orphan*/ *, int /*<<< orphan*/, char *);
int /*<<< orphan*/ svcerr_decode(int /*<<< orphan*/ *);
int /*<<< orphan*/ svcerr_noproc(int /*<<< orphan*/ *);
scalar_t__ xdr_int;
scalar_t__ xdr_void;
void serverDisp(struct svc_req *rqstp, SVCXPRT *transp) {
  int numRec;
  fprintf(stderr, "in server proc\n");
  switch (rqstp->rq_proc) {
  case 0:
    if (svc_sendreply(transp, (xdrproc_t)xdr_void, 0) == FALSE) {
      fprintf(stderr, "error in null proc\n");
      exit(1);
    }
    return;
  case 10000:
    break;
  default:
    svcerr_noproc(transp);
    return;
  }
  if (!svc_getargs(transp, (xdrproc_t)xdr_int, (char *)&numRec)) {
    svcerr_decode(transp);
    return;
  }
  numRec++;
  if (svc_sendreply(transp, (xdrproc_t)xdr_int, (char *)&numRec) == FALSE) {
    fprintf(stderr, "error in sending answer\n");
    exit(1);
  }
  return;
}


x86 assembly (clang, -O0):
<serverDisp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
test   %eax,%eax
je     11ae <serverDisp+0x4e>
jmp    119b <serverDisp+0x3b>
mov    -0x18(%rbp),%eax
sub    $0x2710,%eax
je     11fb <serverDisp+0x9b>
jmp    1200 <serverDisp+0xa0>
mov    -0x10(%rbp),%rdi
mov    0x2e27(%rip),%rax
mov    (%rax),%rax
mov    %eax,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <svc_sendreply@plt>
mov    0x2dfa(%rip),%rcx
cmp    (%rcx),%rax
jne    11f6 <serverDisp+0x96>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
lea    0xe29(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    1294 <serverDisp+0x134>
jmp    120e <serverDisp+0xae>
mov    -0x10(%rbp),%rdi
call   1050 <svcerr_noproc@plt>
jmp    1294 <serverDisp+0x134>
mov    -0x10(%rbp),%rdi
mov    0x2dcf(%rip),%rax
mov    (%rax),%rax
mov    %eax,%esi
lea    -0x14(%rbp),%rdx
call   1080 <svc_getargs@plt>
cmp    $0x0,%eax
jne    123e <serverDisp+0xde>
mov    -0x10(%rbp),%rdi
call   1060 <svcerr_decode@plt>
jmp    1294 <serverDisp+0x134>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2d96(%rip),%rax
mov    (%rax),%rax
mov    %eax,%esi
lea    -0x14(%rbp),%rdx
call   1030 <svc_sendreply@plt>
mov    0x2d61(%rip),%rcx
cmp    (%rcx),%rax
jne    128f <serverDisp+0x12f>
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
lea    0xda4(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    1294 <serverDisp+0x134>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serverDisp>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2e5a(%rip),%r15
mov    (%r15),%edi
lea    0xe80(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%eax
cmp    $0x2710,%eax
je     11bd <serverDisp+0x5d>
test   %eax,%eax
jne    1210 <serverDisp+0xb0>
mov    0x2e47(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
xor    %edx,%edx
call   1030 <svc_sendreply@plt>
mov    0x2e1c(%rip),%rcx
cmp    (%rcx),%rax
jne    1229 <serverDisp+0xc9>
mov    (%r15),%edi
lea    0xe55(%rip),%rsi
jmp    1201 <serverDisp+0xa1>
mov    0x2e24(%rip),%rbx
mov    (%rbx),%esi
lea    0xc(%rsp),%rdx
mov    %r14,%rdi
call   1080 <svc_getargs@plt>
test   %eax,%eax
je     1221 <serverDisp+0xc1>
addl   $0x1,0xc(%rsp)
mov    (%rbx),%esi
lea    0xc(%rsp),%rdx
mov    %r14,%rdi
call   1030 <svc_sendreply@plt>
mov    0x2dd6(%rip),%rcx
cmp    (%rcx),%rax
jne    1229 <serverDisp+0xc9>
mov    (%r15),%edi
lea    0xe23(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    %r14,%rdi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <svcerr_noproc@plt>
mov    %r14,%rdi
call   1060 <svcerr_decode@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.svc_req = type { i32 }
@stderr = global i32 0
@.str = [16 x i8] c"in server proc\0A\00"
@xdr_void = global i64 0
@FALSE = global i64 0
@.str.1 = [20 x i8] c"error in null proc\0A\00"
@xdr_int = global i64 0
@.str.2 = [25 x i8] c"error in sending answer\0A\00"
define void @serverDisp(%struct.svc_req* %0, i32* %1) {
%3 = alloca %struct.svc_req*
%4 = alloca i32*
%5 = alloca i32
store %struct.svc_req* %0, %struct.svc_req** %3
store i32* %1, i32** %4
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%8 = load %struct.svc_req*, %struct.svc_req** %3
%9 = getelementptr inbounds %struct.svc_req, %struct.svc_req* %8, i32 0, i32 0
%10 = load i32, i32* %9
switch i32 %10, label %24 [
i32 0, label %11
i32 10000, label %23
]
11: ; preds = %2
%12 = load i32*, i32** %4
%13 = load i64, i64* @xdr_void
%14 = trunc i64 %13 to i32
%15 = call i64 @svc_sendreply(i32* %12, i32 %14, i8* null)
%16 = load i64, i64* @FALSE
%17 = icmp eq i64 %15, %16
br i1 %17, label %18, label %22
18: ; preds = %11
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %11
br label %52
23: ; preds = %2
br label %27
24: ; preds = %2
%25 = load i32*, i32** %4
%26 = call i32 @svcerr_noproc(i32* %25)
br label %52
27: ; preds = %23
%28 = load i32*, i32** %4
%29 = load i64, i64* @xdr_int
%30 = trunc i64 %29 to i32
%31 = bitcast i32* %5 to i8*
%32 = call i32 @svc_getargs(i32* %28, i32 %30, i8* %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %27
%35 = load i32*, i32** %4
%36 = call i32 @svcerr_decode(i32* %35)
br label %52
37: ; preds = %27
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
%40 = load i32*, i32** %4
%41 = load i64, i64* @xdr_int
%42 = trunc i64 %41 to i32
%43 = bitcast i32* %5 to i8*
%44 = call i64 @svc_sendreply(i32* %40, i32 %42, i8* %43)
%45 = load i64, i64* @FALSE
%46 = icmp eq i64 %44, %45
br i1 %46, label %47, label %51
47: ; preds = %37
%48 = load i32, i32* @stderr
%49 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %37
br label %52
52: ; preds = %51, %34, %24, %22
ret void
}

LLVM IR (-O2):
%struct.svc_req = type { i32 }
@stderr = global i32 0
@.str = [16 x i8] c"in server proc\0A\00"
@xdr_void = global i64 0
@FALSE = global i64 0
@.str.1 = [20 x i8] c"error in null proc\0A\00"
@xdr_int = global i64 0
@.str.2 = [25 x i8] c"error in sending answer\0A\00"
define void @serverDisp(%struct.svc_req* nocapture %0, i32* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds %struct.svc_req, %struct.svc_req* %0, i64 0, i32 0
%8 = load i32, i32* %7
switch i32 %8, label %19 [
i32 0, label %9
i32 10000, label %21
]
9: ; preds = %2
%10 = load i64, i64* @xdr_void
%11 = trunc i64 %10 to i32
%12 = tail call i64 @svc_sendreply(i32* %1, i32 %11, i8* null)
%13 = load i64, i64* @FALSE
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %40
15: ; preds = %9
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = tail call i32 @svcerr_noproc(i32* %1)
br label %40
21: ; preds = %2
%22 = load i64, i64* @xdr_int
%23 = trunc i64 %22 to i32
%24 = call i32 @svc_getargs(i32* %1, i32 %23, i8* %4)
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = call i32 @svcerr_decode(i32* %1)
br label %40
28: ; preds = %21
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
%31 = load i64, i64* @xdr_int
%32 = trunc i64 %31 to i32
%33 = call i64 @svc_sendreply(i32* %1, i32 %32, i8* %4)
%34 = load i64, i64* @FALSE
%35 = icmp eq i64 %33, %34
br i1 %35, label %36, label %40
36: ; preds = %28
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %28, %9, %26, %19
ret void
}