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

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ *clnt_create(char *, int, int, char *);
int /*<<< orphan*/ clnt_destroy(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int);
int main(int argn, char *argc[]) {
  int run_mode = 0;
  int test_status = 1;
  int progNum = atoi(argc[2]);
  char *proto = "tcp";
  CLIENT *clnt = NULL;
  int nbCall = atoi(argc[3]);
  int nbOk = 0;
  int i;
  for (i = 0; i < nbCall; i++) {
    clnt = clnt_create(argc[1], progNum, 1, proto);
    clnt_destroy(clnt);
    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)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x1c(%rbp)
lea    0xe85(%rip),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    11ee <main+0xae>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%rcx
mov    $0x1,%edx
call   1040 <clnt_create@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <clnt_destroy@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11a5 <main+0x65>
cmpl   $0x1,-0x14(%rbp)
jne    1216 <main+0xd6>
mov    -0x34(%rbp),%esi
lea    0xe02(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%esi
lea    0xdff(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%edx
mov    -0x34(%rbp),%esi
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    %esi,%edx
cmove  %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xdd7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r12
mov    0x10(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    0x18(%r12),%rdi
call   1060 <atoi@plt>
mov    %eax,%r14d
test   %eax,%eax
jle    11a6 <main+0x66>
lea    0xe92(%rip),%r15
mov    %r14d,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x8(%r12),%rdi
mov    %ebp,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1040 <clnt_create@plt>
mov    %rax,%rdi
call   1050 <clnt_destroy@plt>
add    $0xffffffff,%ebx
jne    1180 <main+0x40>
mov    %r14d,%eax
jmp    11a8 <main+0x68>
xor    %eax,%eax
xor    %ebx,%ebx
cmp    %r14d,%eax
setne  %bl
lea    0xe4d(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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