#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*/ SVCXPRT;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ svc_destroy(int /*<<< orphan*/ *);
int /*<<< orphan*/ *svcfd_create(int, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argn, char *argc[]) {
  int run_mode = 0;
  int test_status = 1;
  int fd = 0;
  SVCXPRT *svcr = NULL;
  int nbCall = atoi(argc[3]);
  int nbOk = 0;
  int i;
  for (i = 0; i < nbCall; i++) {
    svcr = svcfd_create(fd, 0, 0);
    if (svcr == NULL)
      continue;
    svc_destroy(svcr);
    nbOk++;
  }
  if (run_mode == 1) {
    printf("Aimed : %d\n", nbCall);
    printf("Got : %d\n", nbOk);
  }
  test_status = (nbOk == nbCall) ? 0 : 1;
  printf("%d\n", test_status);
  return test_status;
}


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)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11dd <main+0x9d>
mov    -0x1c(%rbp),%edi
xor    %edx,%edx
mov    %edx,%esi
call   1060 <svcfd_create@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11bd <main+0x7d>
jmp    11cf <main+0x8f>
mov    -0x28(%rbp),%rdi
call   1040 <svc_destroy@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1191 <main+0x51>
cmpl   $0x1,-0x14(%rbp)
jne    1205 <main+0xc5>
mov    -0x2c(%rbp),%esi
lea    0xe0f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%esi
lea    0xe0c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%edx
mov    -0x2c(%rbp),%esi
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    %esi,%edx
cmove  %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xde4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    0x18(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%r14d
xor    %ebx,%ebx
test   %eax,%eax
jle    1182 <main+0x42>
mov    %r14d,%ebp
jmp    1165 <main+0x25>
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%ebp
je     1182 <main+0x42>
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <svcfd_create@plt>
test   %rax,%rax
je     1160 <main+0x20>
mov    %rax,%rdi
call   1040 <svc_destroy@plt>
add    $0x1,%ebx
jmp    1160 <main+0x20>
xor    %ebp,%ebp
cmp    %r14d,%ebx
setne  %bpl
lea    0xe6e(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Aimed : %d\0A\00"
@.str.1 = [10 x i8] c"Got : %d\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 1, i32* %7
store i32 0, i32* %8
store i32* null, i32** %9
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 3
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
br label %17
17: ; preds = %32, %2
%18 = load i32, i32* %12
%19 = load i32, i32* %10
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %35
21: ; preds = %17
%22 = load i32, i32* %8
%23 = call i32* @svcfd_create(i32 %22, i32 0, i32 0)
store i32* %23, i32** %9
%24 = load i32*, i32** %9
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %27
26: ; preds = %21
br label %32
27: ; preds = %21
%28 = load i32*, i32** %9
%29 = call i32 @svc_destroy(i32* %28)
%30 = load i32, i32* %11
%31 = add nsw i32 %30, 1
store i32 %31, i32* %11
br label %32
32: ; preds = %27, %26
%33 = load i32, i32* %12
%34 = add nsw i32 %33, 1
store i32 %34, i32* %12
br label %17
35: ; preds = %17
%36 = load i32, i32* %6
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = load i32, i32* %10
%40 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %11
%42 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %38, %35
%44 = load i32, i32* %11
%45 = load i32, i32* %10
%46 = icmp eq i32 %44, %45
%47 = zext i1 %46 to i64
%48 = select i1 %46, i32 0, i32 1
store i32 %48, i32* %7
%49 = load i32, i32* %7
%50 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %49)
%51 = load i32, i32* %7
ret i32 %51
}

LLVM IR (-O2):
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 3
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %19
7: ; preds = %2, %15
%8 = phi i32 [ %17, %15 ], [ 0, %2 ]
%9 = phi i32 [ %16, %15 ], [ 0, %2 ]
%10 = tail call i32* @svcfd_create(i32 0, i32 0, i32 0)
%11 = icmp eq i32* %10, null
br i1 %11, label %15, label %12
12: ; preds = %7
%13 = tail call i32 @svc_destroy(i32* %10)
%14 = add nsw i32 %9, 1
br label %15
15: ; preds = %7, %12
%16 = phi i32 [ %9, %7 ], [ %14, %12 ]
%17 = add nuw nsw i32 %8, 1
%18 = icmp eq i32 %17, %5
br i1 %18, label %19, label %7
19: ; preds = %15, %2
%20 = phi i32 [ 0, %2 ], [ %16, %15 ]
%21 = icmp ne i32 %20, %5
%22 = zext i1 %21 to i32
%23 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %22)
ret i32 %22
}