#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);
    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    11cd <main+0x8d>
mov    -0x1c(%rbp),%edi
xor    %edx,%edx
mov    %edx,%esi
call   1060 <svcfd_create@plt>
mov    %rax,-0x28(%rbp)
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    11f5 <main+0xb5>
mov    -0x2c(%rbp),%esi
lea    0xe1f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%esi
lea    0xe1c(%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    0xdf4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    0x18(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    117c <main+0x3c>
mov    %ebx,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <svcfd_create@plt>
mov    %rax,%rdi
call   1040 <svc_destroy@plt>
add    $0xffffffff,%ebp
jne    1160 <main+0x20>
mov    %ebx,%eax
jmp    117e <main+0x3e>
xor    %eax,%eax
xor    %ebp,%ebp
cmp    %ebx,%eax
setne  %bpl
lea    0xe73(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
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 = %28, %2
%18 = load i32, i32* %12
%19 = load i32, i32* %10
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %31
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 = call i32 @svc_destroy(i32* %24)
%26 = load i32, i32* %11
%27 = add nsw i32 %26, 1
store i32 %27, i32* %11
br label %28
28: ; preds = %21
%29 = load i32, i32* %12
%30 = add nsw i32 %29, 1
store i32 %30, i32* %12
br label %17
31: ; preds = %17
%32 = load i32, i32* %6
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %39
34: ; preds = %31
%35 = load i32, i32* %10
%36 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %11
%38 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %34, %31
%40 = load i32, i32* %11
%41 = load i32, i32* %10
%42 = icmp eq i32 %40, %41
%43 = zext i1 %42 to i64
%44 = select i1 %42, i32 0, i32 1
store i32 %44, i32* %7
%45 = load i32, i32* %7
%46 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %45)
%47 = load i32, i32* %7
ret i32 %47
}

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 %13
7: ; preds = %2, %7
%8 = phi i32 [ %11, %7 ], [ 0, %2 ]
%9 = tail call i32* @svcfd_create(i32 0, i32 0, i32 0)
%10 = tail call i32 @svc_destroy(i32* %9)
%11 = add nuw nsw i32 %8, 1
%12 = icmp eq i32 %11, %5
br i1 %12, label %13, label %7
13: ; preds = %7, %2
%14 = phi i32 [ 0, %2 ], [ %5, %7 ]
%15 = icmp ne i32 %14, %5
%16 = zext i1 %15 to i32
%17 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %16)
ret i32 %16
}